Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Assets/UIController/Scripts/UIControllerStateMachine.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

Expand All @@ -20,14 +19,7 @@ public override void OnStateUpdate (Animator animator, AnimatorStateInfo stateIn
if (this.normalizedTimes[stateInfo.fullPathHash] < 1 && stateInfo.normalizedTime >= 1) {
UIController uiController;
if (this.TryGetComponent<UIController> (animator.gameObject, out uiController)) {
uiController.StartCoroutine (this.WaitForEndOfFrame (() => {
if (stateInfo.IsName ("Show")) {
uiController.SendMessage ("OnShow");
}
else if (stateInfo.IsName ("Hide")) {
uiController.SendMessage ("OnHide");
}
}));
uiController.StartCoroutine (this.WaitForSendMessage (uiController, stateInfo));
}
}
this.normalizedTimes[stateInfo.fullPathHash] = stateInfo.normalizedTime;
Expand All @@ -41,8 +33,13 @@ private bool TryGetComponent<T> (GameObject go, out T t) where T : Component {
t = outT;
return t != null;
}
private IEnumerator WaitForEndOfFrame (Action onWait) {
private IEnumerator WaitForSendMessage (UIController uiController, AnimatorStateInfo stateInfo) {
yield return new WaitForEndOfFrame ();
onWait ();
if (stateInfo.IsName ("Show")) {
uiController.SendMessage ("OnShow");
}
else if (stateInfo.IsName ("Hide")) {
uiController.SendMessage ("OnHide");
}
}
}
}