I have a player object with this bit of code on a script:
private void Awake()
{
if (Once == false)
{
slider = GetComponent<Slider>();
Debug.Log(slider);
unitCanvasGroup = GetComponentInParent<CanvasGroup>();
Debug.Log(unitCanvasGroup);
Once = true;
}
}
With this outcome on the console:
HealthBar (UnityEngine.UI.Slider)
UnityEngine.Debug:Log (object)
HealthBar:Awake () (at Assets/Scripts/HealthBar.cs:17)
UnitCanvas (UnityEngine.CanvasGroup)
UnityEngine.Debug:Log (object)
HealthBar:Awake () (at Assets/Scripts/HealthBar.cs:19)
Null
UnityEngine.Debug:Log (object)
HealthBar:Awake () (at Assets/Scripts/HealthBar.cs:17)
Null
UnityEngine.Debug:Log (object)
HealthBar:Awake () (at Assets/Scripts/HealthBar.cs:19)
Not only is it running twice when it shouldn’t, it is yielding two different outcomes. Reimported the project, unloaded the scene, got to it through a different path. This hasn’t really happened to me before all these years. The Gameobject is only once in the scene, the script is attached to it only once. Made a new scene with only said object, error persists. I’m at a complete loss.