Hi.
I have a panel that popup when clickng an object, so i have this code on the object
using UnityEngine;
using UnityEngine.UI;
public class YardScript : MonoBehaviour
{
public GameObject yardPanel;
void OnMouseDown()
{
yardPanel.SetActive(true);
}
}
But when i set on the inspector the gameObject that contains the panel and click on override doesn’t work, every time i instantiate a new clone of it, have to mannualy assign the panel.
I tried to assign it manually from script like this:
using UnityEngine;
using UnityEngine.UI;
public class YardScript : MonoBehaviour
{
public GameObject yardPanel;
void Start()
{
yardPanel = GameObject.Find("Yard Panel");
}
void OnMouseDown()
{
yardPanel.SetActive(true);
}
}
But the variable still being “None (Game Object)”.
Any idea?