using UnityEngine;
using System.Collections;
[B]public class Purchased : MonoBehaviour[/B]
{
public static bool BuildingUnowned;
public GameObject ConstructionPlaneUI;
public GameObject BuyBuildingButtonUI;
public GameObject BuildingUpgradeUI;
public AnimationClip plane;
private Animation myAnimation;
// Use this for initialization
[B] void Start()[/B]
{
BuildingUnowned = true;
BuildingUpgradeUI.SetActive(false);
myAnimation.enabled = false;
}
// Update is called once per frame
[B] void Update()[/B]
{
if (BuildingUnowned == false)
{
Invoke("ConstructionPlane", 5);
BuyBuildingButtonUI.SetActive(false);
}
}
[B]public void ConstructionPlane()[/B]
{
ConstructionPlaneUI.SetActive(false);
BuildingUpgradeUI.SetActive(true);
myAnimation.Play(plane.name);
}
}
There is the code attached to the GameManager for my game, and I have attached the animation inside the inspector. Except, even though the animation enabled is set to false in the start update it will still play - I want it to only play when the BuildingUnowned returns true. Thus far, everything else is working, my panels will appear/disappear as instructed when invoked - except the animation. Any ideas on why?
Unity is throwing an error on line 23 (object reference is not set to an instance.)