I created an “Idle” animation clip with no properties (there are no key frames, nothing is changed). While “idle” I want the object (a card) to do nothing, no property changes from whatever state it’s currently in (dealt, hidden, showing, etc…).
The editor state of my card prefab object has everything visible so I can view it in the inspector. However, when my game starts on Awake() I set the GameObject.setActive(false) for all game objects containing visible components to hide the card.
The perplexing behavior I’ve observed is this:
- In Awake() all visible components are setActive(false); in a script
- In Start() all visible components are still (correctly) activeSelf == false;
- In the first frame of Update() my “Idle” animation (correctly) begins to play
- Immediately after my “Idle” animation starts, all visible components activeSelf == true (WRONG! WHY??)
The above is observed via Debug.Log.
Additionally if I explicitly set my visible components’ activeSelf = false at the start of my “Idle” animation clip, everything works as expected (but this is not what I want to do as sometimes I want to idle while the card is visible).
Currently there is no other code referencing my Card prefab/instance and within my Card script I only set Animator property values to control which animation is played. So I can’t imagine any other variables/code/behaviors that could be at play here besides my animations.
Why are properties changing when none are set in my animation clip? Is this a bug? Is this expected behavior?
Thanks.