- Home /
Question by
Andre_Vitor · Oct 24, 2014 at 08:53 AM ·
arraylist
how to change a variable from? an object in this array with a gui.button
well I'm trying to make a rts and like any rts, when you select your "troops" they are shown in a window with your photos and hp ...
I managed, but it activates the bool of the first object it finds the object of inves array that pressed the gui
public Texture boneco;
private Interface _interface;
private Inventory inventory;
private Vector2 _initialPosition;
private Vector2 _finalPosition;
public Texture2D RectangleTexture;
public static List<BaseUnit> _unitsInScene = new List<BaseUnit>();
public Camera mainCamera;
public BaseUnit[] _selectedUnits;
public GameObject unidade;
public bool showTroppsWindows = false;
private Rect troppsRect = new Rect(0, 400, 300, 100);
public Interface intface = new Interface();
public bool mouseOverWindows = false;
private Rect avatarRect = new Rect(0, 0, 25, 25);
public int unitsX = 4;
public int unitsY = 2;
void Awake ()
{
_unitsInScene = new List<BaseUnit>();
_selectedUnits = new BaseUnit[0];
GameObject.FindGameObjectsWithTag("Player");
}
void Update ()
{
}
void OnGUI ()
{
for(int i=0;i < _selectedUnits.Length;i++)
{
if (GUI.Button(new Rect(10, 150 +(i * 50),50,50), boneco))
{
_interface = GameObject.FindGameObjectWithTag("Player").GetComponent<Interface>();
_interface.interfacebox = !_interface.interfacebox;
Debug.Log("Show Interface of unit: " + i);
}
}
Comment