I am making a List
of GameObjects
called checkpoints. At the start, all of the GameObjects
are set to inactive in the editor. When the player starts an event, checkpoint
s get activated one by one in a sequence. When a vehicle triggers a checkpoint
, the next checkpoint
gets activated. Everything works fine in Unity Play Mode without any error or warning.
However, in the Android build, the following statement checkPoints[currentCheckPoint].SetActive(true);
doesn’t work and all the code after it does not get executed. I’m only posting relevant code because the full script is a bit lengthy.
public List<GameObject> checkPoints;
static int tottalCheckPoints = 0;
int currentCheckPoint = 0;
private void Start()
{
tottalCheckPoints = transform.childCount;
for (int i = 0; i < tottalCheckPoints; i++)
{
if (transform.GetChild(i).tag == "CheckPoint" || transform.GetChild(i).tag == "FinaleCheckPoint")
{
checkPoints.Add(transform.GetChild(i).gameObject);
}
}
}
public void CheckPointTriggered()
{
if (currentCheckPoint < tottalCheckPoints)
{
checkPoints[currentCheckPoint].SetActive(true); /*<------ that statement and all the statements after that doesn't get executed in android build.*/
currentCheckPoint++;
}
}
I used text logging in Android by printing specific text on screen after every statement to see from where the code stops working and found that the following statement doesn’t get executed (or any other statement after that). checkPoints[currentCheckPoint].SetActive(true);
I am using latest version of Unity 2018.1.4.f1.