- Home /
How to enable object by clicking on the button through the Massive(array)?
That is, you press a button and enabled the subsequent object in the Massive(array), and the previous turns off. Here is a script I wrote, just the fact that the loop is executed before I click on the button.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MassiveRuss : MonoBehaviour
{
public GameObject[] page;
private static int Choose;
public GameObject[] GetPage()
{
return page;
}
public void SetPage(GameObject[] A)
{
page = A;
}
void Start ()
{
}
// Update is called once per frame
void Update ()
{
switch (gameObject.name)
{
case "Next":
Choose = 0;
Choose++;
for (Choose = 0; Choose < 5; Choose++)
{
page [Choose].SetActive (true);
}
Debug.Log (Choose);
break;
}
/*for (int i = 0; i < 22; i++)
{
page [i].SetActive (true);
}*/
}
}
Comment
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Array empties values on RunTime? 1 Answer
Any way to check if an object is active? 1 Answer
Multiple Cars not working 1 Answer