public void GetStates_WithNoStates_IEnumerator_Current_Throws() { SimpleAnimation animation = Instantiate(); IEnumerable <SimpleAnimation.State> states = animation.GetStates(); var it = states.GetEnumerator(); Assert.Throws <InvalidOperationException>(() => { SimpleAnimation.State state = it.Current; }); }
public IAnimationState GetState(string stateName) { SimpleAnimation.State state = impl[stateName]; if (state != null) { return(new SimpleAnimationStateProxy(state)); } return(null); }
/** 再生中かどうか。取得。 */ public bool IsPlay(string a_state_name) { #if (USE_DEF_FEE_SIMPLEANIMATION) { SimpleAnimation.State t_state = this.raw.GetState(a_state_name); return(t_state.enabled); } #else { Tool.Assert(false); return(false); } #endif }
/** ブレンド率。取得。 */ public float GetBlendWeight(string a_state_name) { #if (USE_DEF_FEE_SIMPLEANIMATION) { SimpleAnimation.State t_state = this.raw.GetState(a_state_name); return(t_state.weight); } #else { Tool.Assert(false); return(0.0f); } #endif }
public void GetStates_WithSingleState_IEnumerator_Returns_ValidState() { SimpleAnimation animation = Instantiate(); var clip = Resources.Load <AnimationClip>("LinearX"); var clipInstance = Object.Instantiate <AnimationClip>(clip); animation.AddClip(clipInstance, "SingleClip"); IEnumerable <SimpleAnimation.State> states = animation.GetStates(); var it = states.GetEnumerator(); it.MoveNext(); SimpleAnimation.State state = it.Current; Assert.AreEqual("SingleClip", state.name); }
public SimpleAnimationStateProxy(SimpleAnimation.State state) { m_State = state; }
private void Update() { if (!Application.isPlaying) { return; } if (hitboxes != null) { ; var nowstates = simpleAnimation.GetStates().FirstOrDefault(s => s.enabled); if (nowstates == null) { return; } //var newKeyframesIndex = Convert.ToInt32(Math.Floor(hitboxes[nowstates.name].keyframes.Count * elapsedTime)); var newKeyframesIndex = GetNowKeyFrame(); if (prestate == null || stateChanged) { prestate = nowstates; foreach (var e in nowColliders) { if (e.Key != null) { Destroy(e.Key.gameObject); } } nowColliders.Clear(); preveousKeyFrameIndex = -1; stateChanged = false; } if (preveousKeyFrameIndex != newKeyframesIndex) { var destroylist = new List <GameObject>(); ///生存期間のすぎたcolliderのリスト化 nowColliders.RemoveAll((KVPair <GameObject, KeyFrameCollider> e) => { var elapsed = newKeyframesIndex - e.Value.startframe; if (elapsed >= e.Value.dulation && e.Key.activeSelf) { destroylist.Add(e.Key); return(true); } return(false); }); /// 生存期間の過ぎたcolliderの削除 foreach (var e in destroylist) { Destroy(e); } //新たに発生したcolliderの追加 if (hitboxes.data.Find(e => e.Key == nowstates.name) != null) { for (int i = preveousKeyFrameIndex + 1; i <= newKeyframesIndex; i++) { foreach (var e in hitboxes[nowstates.name].keyframes[i].colliders) { Debug.Log("create col"); var col = AddColliderComponentFromParam(e); nowColliders.Add(new KVPair <GameObject, KeyFrameCollider>(col, e)); } } } /* * if (KeyframesIndex == 0) * { * nowkeyframedata.colliders.Add(new KeyFrameCollider()); * var obj = new GameObject("test"); * var objtrans = obj.GetComponent<Transform>(); * var rigidbody = obj.AddComponent<Rigidbody>(); * rigidbody.useGravity = false; * var col = obj.AddComponent<CapsuleCollider>(); * nowkeyframedata.colliders[0].collider = col; * col.center = new Vector3(3, 0); * col.radius = 1; * col.height = 2; * col.tag = "test"; * col.isTrigger = true; * * objtrans.SetParent(gameObject.transform, false); * * } */ } preveousKeyFrameIndex = newKeyframesIndex; } }