private IEnumerator Change(string _name, bool _animated, params object[] _data) { if (loadingView != null && _animated) { yield return(loadingView.StartAnimation()); } var beforeState = currentState; if (beforeState != null) { beforeState.Release(); Destroy(beforeState.gameObject); } if (states.ContainsKey(_name)) { currentState = Instantiate(states[_name]); } else { Debug.LogFormat("state key is not contain : {0}", _name); currentState = beforeState; } yield return(currentState.Initialize(_data)); if (loadingView != null && _animated) { //loadingView.SetActive(false); yield return(loadingView.FinishAnimation()); } currentState.Begin(); }