internal void Clone(SpriteAnimationState other, string name) { if (curve == null) { curve = new AnimationLinearCurve( other.curve.startTime, other.curve.startValue, other.curve.endTime, other.curve.endValue); } else { curve.SetTime(other.curve.startTime, other.curve.startValue, other.curve.endTime, other.curve.endValue); } wrapMode = other.wrapMode; _clip = other.clip; _animation = other._animation; normalizedSpeed = other.normalizedSpeed; componentEnable = new byte[clip.subComponents.Length + 1]; for (int i = 0, e = componentEnable.Length; i < e; i++) { componentEnable[i] = 1; } _name = name; _layer = other._layer; _weight = other._weight; }
/// <summary> /// Initialize clip internal state. /// </summary> /// <param name="calcComp">Is need re-init sub compoent curves?</param> public void Init(bool calcComp) { root.clip = this; root.index = -1; root._fullPath = "/root"; root._fullPathHash = EasyMotion2DUtility.GetHashCode(root._fullPath); tick = 1f / frameRate; maxFrameIndex = getMaxComponentIndex(root); _length = maxFrameIndex * tick; CalcCurve(calcComp); CalcEvents(); float l = length; float eIdx = (l / tick); playingCurve.SetTime(0, 0, _length, Mathf.Floor(eIdx) + 0.051f); }
void OnEnable() { root.clip = this; root.index = -1; root._fullPath = "/root"; root._fullPathHash = root._fullPath.GetHashCode(); { float l = length; float eIdx = (l / tick) + 1f; playingCurve.SetTime(0, 0, _length, Mathf.Floor(eIdx) + 0.051f); } }
internal void Init(SpriteAnimationClip clip, SpriteAnimation animation, string name) { // remove from SpriteTransform foreach (SpriteTransform.StateComponentPair pair in referenceList) { pair.applyTo.DetachState(pair.state, pair.component); } //set playing curve if (curve == null) { curve = new AnimationLinearCurve( clip.playingCurve.startTime, clip.playingCurve.startValue, clip.playingCurve.endTime, clip.playingCurve.endValue); } else { curve.SetTime(clip.playingCurve.startTime, clip.playingCurve.startValue, clip.playingCurve.endTime, clip.playingCurve.endValue); } wrapMode = clip.wrapMode; _clip = clip; _animation = animation; normalizedSpeed = 1f / clip.length; componentEnable = new byte[clip.subComponents.Length + 1]; for (int i = 0, e = componentEnable.Length; i < e; i++) { componentEnable[i] = 1; } this.name = name; }