OK so I am trying to implement a simple check in Start(), where if the player has completed in app purchase, the button no longer shows. My code works perfectly in Unity editor preview, the button disappears from view, and also disappears from the hierarchy. But when i build and run to my android device, the button stays visable, and I can still click it ( ie run animation), just nothing happens.
public void Start()
{
Load();
audioSource = gameObject.AddComponent<AudioSource>();
if (paid == 1)
{
GameObject.Destroy(GameObject.Find("StopAudio"));
Education = Resources.LoadAll<AudioClip>("Sounds/Paid/");
Debug.Log("The length of the audio array is: " + Education.Length);
}
else
{
Education = Resources.LoadAll<AudioClip>("Sounds/Education/");
Debug.Log("The length of the audio array is: " + Education.Length);
}
I have tried checking to make sure Find(GameObject) is not returning null, and it is not, I am just at my wits end to work out why it works in editor and not on phone.
The GameObject is called “StopAudio” in hierarchy [used to be a stop button I repurposed, have not got round to renaming it yet].
I have also tried DestroyImmediate.