public int ChessOn1, ChessOn2, ChessOn3, ChessOn4, ChessOn5, ChessOn6, ChessOn7, ChessOn8; // check whose chess is on position, 0 for red, 1 for blue;
void PosToPut(int curchess)
{
if (gameObject.transform.name.ToString() == "Chess (0)")
{
ChessOn1 = curchess;
} else if (gameObject.transform.name.ToString() == "Chess (1)")
{
ChessOn2 = curchess;
} else if (gameObject.transform.name.ToString() == "Chess (2)")
{
ChessOn3 = curchess;
} else if (gameObject.transform.name.ToString() == "Chess (3)")
{
ChessOn4 = curchess;
} else if (gameObject.transform.name.ToString() == "Chess (4)")
{
ChessOn5 = curchess;
} else if (gameObject.transform.name.ToString() == "Chess (5)")
{
ChessOn6 = curchess;
} else if (gameObject.transform.name.ToString() == "Chess (6)")
{
ChessOn7 = curchess;
} else if (gameObject.transform.name.ToString() == "Chess (7)")
{
ChessOn8 = curchess;
}
}
Hey, buddy, new bee need help here, please.
i have nine gameobject chess(0) - (8), and nine variables ChessOn1 - 9.
ChessOn1 - 9 are initialized as 0, and it is changed when the object is clicked.
it works fine in single gameobject, when i click it, its corresponding variable would change, but in other gameobjects the variables remain 0.
i want the nine objects to share the changes in the variables, how should i do that ? thx in advanced!