internal SpriteAnimationState AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame, bool addLoopFrame) { if (clip == null) { Debug.LogError("A null clip add to animation!"); return(null); } SpriteAnimationState state = animationStates[newName] as SpriteAnimationState; if (state == null) { state = new SpriteAnimationState(clip, this, newName); AddState(state); } else { state.Init(clip, this, newName); } List <SpriteAnimationClip> tmpAnis = new List <SpriteAnimationClip>(animations); if (!tmpAnis.Contains(clip)) { tmpAnis.Add(clip); animations = tmpAnis.ToArray(); } return(state); }
internal void fini() { for (int i = 0, e = componentEnable.Length; i < e; i++) { componentEnable[i] = 0; } enableList.Clear(); // remove from SpriteTransform tmpBuffer.AddRange(referenceList); foreach (SpriteTransform.StateComponentPair pair in tmpBuffer) { pair.applyTo.DetachState(pair.state, pair.component); } tmpBuffer.Clear(); referenceList.Clear(); subClipState.Clear(); if (subClipState.Count > 0) { Debug.LogError("sub state not empty " + _name); subClipState.Clear(); } _name = string.Empty; parentTransform = null; _clip = null; _animation = null; parentState = null; isRemoving = false; }
internal int GetMaxIndex() { int idx = keyFrames.Length - 1; int ret = 0; if (idx >= 0) { if (keyFrames[idx].isRefClip) { ret = keyFrames[idx].frameIndex; SpriteAnimationClip refClip = keyFrames[idx].refClip; int ml = refClip.getMaxComponentIndex(refClip.root); float t_tick = 1f / (float)refClip.frameRate; float tick = 1f / (float)clip.frameRate; int l = (int)((ml * t_tick) / tick); ret += l; } else { ret = keyFrames[idx].frameIndex; } } return(ret); }
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> /// Clone a SpriteAnimationClip. /// </summary> /// <param name="source">Clip source.</param> /// <param name="init">Is need init the clone instance.</param> /// <returns>The clone instance.</returns> public static SpriteAnimationClip Duplicate(SpriteAnimationClip source, bool init) { SpriteAnimationClip ret = ScriptableObject.CreateInstance <SpriteAnimationClip>(); ret.name = source.name; ret.dataFormatVersion = source.dataFormatVersion; ret.frameRate = source.frameRate; ret.wrapMode = source.wrapMode; ret.events = source.events; ret.root = SpriteAnimationComponent.Duplicate(source.root); ret.root.clip = ret; ret.subComponents = new SpriteAnimationComponent[source.subComponents.Length]; foreach (SpriteAnimationComponent comp in source.subComponents) { SpriteAnimationComponent tmpComp = SpriteAnimationComponent.Duplicate(comp); tmpComp.clip = ret; ret.subComponents[tmpComp.index] = tmpComp; } if (init) { ret.Init(false); } return(ret); }
internal SpriteAnimationState AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame, bool addLoopFrame) { if (clip == null || (clip != null && !clip)) { Debug.LogError("A null clip/missing clip add to animation!"); return(null); } SpriteAnimationState state = this[newName]; if (state == null) { state = SpriteAnimationState.CreateState(); state.Init(clip, this, newName); AddState(state); } else { state.Init(clip, this, newName); } SetClipRange(newName, firstFrame * clip.tick, lastFrame * clip.tick); List <SpriteAnimationClip> tmpAnis = new List <SpriteAnimationClip>(animations); if (!tmpAnis.Contains(clip)) { tmpAnis.Add(clip); animations = tmpAnis.ToArray(); } return(state); }
internal void Init(SpriteAnimationClip clip, SpriteAnimation animation, string name) { ClearState(); //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); } blendMode = AnimationBlendMode.Blend; wrapMode = clip.wrapMode; _clip = clip; _animation = animation; if (clip.length <= 0f) { normalizedSpeed = 1f; } else { normalizedSpeed = 1f / length; } if (componentEnable == null) { componentEnable = new byte[clip.subComponents.Length + 1]; } else if (componentEnable.Length < clip.subComponents.Length + 1) { componentEnable = new byte[clip.subComponents.Length + 1]; } for (int i = 0, e = componentEnable.Length; i < e; i++) { componentEnable[i] = 1; } this.name = name; }
/// <summary> /// Replace nested clip in clip. Usually use to implement avatar charcter animation. /// </summary> /// <param name="clip">The clip need replace.</param> /// <param name="src">The source clips array.</param> /// <param name="dest">The clips want replace to.</param> public static void ReplaceRefClipInClipKeyframe(SpriteAnimationClip clip, SpriteAnimationClip[] src, SpriteAnimationClip[] dest) { ReplaceRefClipInComponent(clip.root, src, dest); foreach (SpriteAnimationComponent comp in clip.subComponents) { ReplaceRefClipInComponent(comp, src, dest); } }
public static SpriteAnimationEvent GetAnimationClipEventAtIndex(SpriteAnimationClip clip, int idx) { foreach (SpriteAnimationEvent evt in clip.events) { if (evt.frameIndex == idx) return evt; } return null; }
/// <summary> /// Adds clip to the only play between firstFrame and lastFrame. The new clip will also be added to the animation with name newName.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> /// <param name="newName">The new name of clip.</param> /// <param name="firstFrame">The first frame the in clip use as start.</param> /// <param name="lastFrame">The last frame the in clip use as end.</param> public void AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame) { if (clip == null || (clip != null && !clip)) { Debug.LogError("A null clip/missing clip add to animation!"); return; } AddClip(clip, newName, firstFrame, lastFrame, false); }
/// <summary> /// Adds a clip to the animation with clip name.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> public void AddClip(SpriteAnimationClip clip) { if (clip == null || (clip != null && !clip)) { Debug.LogError("A null clip/missing clip add to animation!"); return; } AddClip(clip, clip.name, 0, clip.maxFrameIndex, false); }
public static SpriteAnimationEvent GetAnimationClipEventAtIndex(SpriteAnimationClip clip, int idx) { foreach (SpriteAnimationEvent evt in clip.events) { if (evt.frameIndex == idx) { return(evt); } } return(null); }
internal void Init(SpriteAnimationClip clip, SpriteAnimation animation, string name) { //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; if (componentEnable == null) { componentEnable = new byte[clip.subComponents.Length + 1]; } else if (componentEnable.Length < clip.subComponents.Length + 1) { System.Array.Resize(ref componentEnable, clip.subComponents.Length + 1); } for (int i = 0, e = componentEnable.Length; i < e; i++) { componentEnable[i] = 1; } this.name = name; }
/// <summary> /// Remove clip from the animation list. /// This willl remove the clip and any animation states based on it. /// </summary> public void RemoveClip(SpriteAnimationClip clip) { List <SpriteAnimationState> tmp = new List <SpriteAnimationState>(allStates); tmp.RemoveAll(delegate(SpriteAnimationState state) { bool needRemove = state.clip == clip; if (needRemove) { animationStates.Remove(state.name); } return(needRemove); }); allStates = tmp.ToArray(); }
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; }
/// <summary> /// Clone all field from another keyframe. /// </summary> public void Clone(SpriteAnimationKeyFrame other) { if (other == null) { return; } //frameIndex = other.frameIndex; //time = other.time; sprite = other.sprite; position = other.position; rotation = other.rotation; scale = other.scale; shear = other.shear; color = other.color; refClip = other.refClip; isSpriteValid = other.isSpriteValid; isRefClip = other.isRefClip; }
private void ClearState() { //internal bool _enabled = false; _enabled = false; //internal SpriteAnimationClip _clip; _clip = null; //internal string _name; _name = string.Empty; //internal SpriteAnimation _animation; _animation = null; //internal float _speed = 1f; _speed = 1f; //internal float _normalizedSpeed = 0f; _normalizedSpeed = 0f; //internal float lastTime = 0f; lastTime = 0f; //internal int lastFrameIndex = 0; lastFrameIndex = 0; //internal float lastEvaluateTime = 0f; lastEvaluateTime = 0f; //internal float _startTime = 0; _startTime = 0; //internal int _layer = 0; _layer = 0; //internal float _endTime = 0f; _endTime = 0f; //internal bool useCurveInState = false; useCurveInState = false; //internal AnimationLinearCurve curve = null; //internal bool _isPaused = false; _isPaused = false; //internal float _weight = 1f; _weight = 1f; //internal float blendStep = 0f; blendStep = 0f; //internal bool removeAfterStop = false; removeAfterStop = false; //internal int parentComponentLayer = 0; parentComponentLayer = 0; //internal SpriteTransform parentTransform = null; parentTransform = null; }
/// <summary> /// Release all clips. /// </summary> public void Clear() { StopAll(); removeList.Clear(); removeList.AddRange(allStates); foreach (SpriteAnimationState state in removeList) { RemoveState(state); } animations = new SpriteAnimationClip[] { }; removeList.Clear(); crossFadeQueue.Clear(); playingQueue.Clear(); clip = null; }
/// <summary> /// Release all clips. /// </summary> public void Clear() { StopAll(); removeList.Clear(); removeList.AddRange(allStates); foreach (SpriteAnimationState state in removeList) RemoveState(state); animations = new SpriteAnimationClip[] { }; removeList.Clear(); crossFadeQueue.Clear(); playingQueue.Clear(); clip = null; }
/// <summary> /// Adds a clip to the animation with name newName.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> /// <param name="newName">The new name of clip.</param> public void AddClip(SpriteAnimationClip clip, string newName) { AddClip(clip, newName, 0, clip.maxFrameIndex, false); }
public static SpriteAnimationEvent[] GetAnimationClipEvents(SpriteAnimationClip clip) { return clip.events; }
/// <summary> /// Recalculate all curves in SpriteAnimationCLip. Usually use in editor script when you modify keyframe data. /// </summary> public static void RecalcCurve(SpriteAnimationClip clip) { clip.Init( true ); }
/// <summary> /// Replace nested clip in clip. Usually use to implement avatar charcter animation. /// </summary> /// <param name="clip">The clip need replace.</param> /// <param name="src">The source clips array.</param> /// <param name="dest">The clips want replace to.</param> public static void ReplaceRefClipInClipKeyframe(SpriteAnimationClip clip, SpriteAnimationClip[] src, SpriteAnimationClip[] dest) { ReplaceRefClipInComponent(clip.root, src, dest); foreach (SpriteAnimationComponent comp in clip.subComponents) ReplaceRefClipInComponent(comp, src, dest); }
/// <summary> /// Recalculate all curves in SpriteAnimationCLip. Usually use in editor script when you modify keyframe data. /// </summary> public static void RecalcCurve(SpriteAnimationClip clip) { clip.Init(); clip.CalcCurve(); }
/// <summary> /// Remove clip from the animation list. /// This willl remove the clip and any animation states based on it. /// </summary> public void RemoveClip(SpriteAnimationClip clip) { _removeClip = clip; allStates.RemoveAll(removeAllClip); _removeClip = null; }
/// <summary> /// Adds a clip to the animation with name newName.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> /// <param name="newName">The new name of clip.</param> public void AddClip(SpriteAnimationClip clip, string newName) { AddClip(clip, newName, 0, clip.maxFrameIndex, false); }
/// <summary> /// Adds a clip to the animation with clip name.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> public void AddClip(SpriteAnimationClip clip) { AddClip(clip, clip.name, 0, clip.maxFrameIndex, false); }
internal void SetClips(SpriteAnimationClip[] clips) { animations = clips; }
/// <summary> /// Remove clip from the animation list. /// This willl remove the clip and any animation states based on it. /// </summary> public void RemoveClip(SpriteAnimationClip clip) { List<SpriteAnimationState> tmp = new List<SpriteAnimationState>(allStates); tmp.RemoveAll( delegate( SpriteAnimationState state) { bool needRemove = state.clip == clip; if ( needRemove ) animationStates.Remove( state.name ); return needRemove; }); allStates = tmp.ToArray(); }
internal SpriteAnimationState AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame, bool addLoopFrame) { if (clip == null) { Debug.LogError("A null clip add to animation!"); return null; } SpriteAnimationState state = animationStates[newName] as SpriteAnimationState; if (state == null) { state = new SpriteAnimationState(clip, this, newName); AddState(state); } else { state.Init(clip, this, newName); } List<SpriteAnimationClip> tmpAnis = new List<SpriteAnimationClip>(animations); if (!tmpAnis.Contains(clip)) { tmpAnis.Add(clip); animations = tmpAnis.ToArray(); } return state; }
/// <summary> /// Adds clip to the only play between firstFrame and lastFrame. The new clip will also be added to the animation with name newName.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> /// <param name="newName">The new name of clip.</param> /// <param name="firstFrame">The first frame the in clip use as start.</param> /// <param name="lastFrame">The last frame the in clip use as end.</param> public void AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame) { AddClip(clip, newName, firstFrame, lastFrame, false); }
/// <summary> /// Adds clip to the only play between firstFrame and lastFrame. The new clip will also be added to the animation with name newName.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> /// <param name="newName">The new name of clip.</param> /// <param name="firstFrame">The first frame the in clip use as start.</param> /// <param name="lastFrame">The last frame the in clip use as end.</param> public void AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame) { if (clip == null || (clip != null && !clip)) { Debug.LogError("A null clip/missing clip add to animation!"); return; } AddClip(clip, newName, firstFrame, lastFrame, false); }
/// <summary> /// Remove clip from the animation list. /// This willl remove the clip and any animation states based on it. /// </summary> public void RemoveClip(SpriteAnimationClip clip) { _removeClip = clip; allStates.RemoveAll(removeAllClip); _removeClip = null; }
/// <summary> /// Adds clip to the only play between firstFrame and lastFrame. The new clip will also be added to the animation with name newName.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> /// <param name="newName">The new name of clip.</param> /// <param name="firstFrame">The first frame the in clip use as start.</param> /// <param name="lastFrame">The last frame the in clip use as end.</param> public void AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame) { AddClip(clip, newName, firstFrame, lastFrame, false); }
/// <summary> /// Sets the array of SpriteAnimationClips to be referenced in the Animation component /// </summary> public static void SetAnimationClips(SpriteAnimation animation, SpriteAnimationClip[] clips) { animation.SetClips(clips); }
public static bool Upgrade(SpriteAnimationClip clip) { return(clip.Upgrade()); }
/// <summary> /// Clone a SpriteAnimationClip. /// </summary> /// <param name="clip">Source Clip.</param> /// <param name="init">Need initialize instance?</param> /// <returns>Instance of clip.</returns> public static SpriteAnimationClip Duplicate(SpriteAnimationClip clip, bool init) { return SpriteAnimationClip.Duplicate(clip, init); }
public static SpriteAnimationComponent GetComponentByHashCode(SpriteAnimationClip clip, int hashcode) { return(clip.GetComponentById(hashcode)); }
internal static void ReplaceRefClipInComponent(SpriteAnimationComponent component, SpriteAnimationClip[] src, SpriteAnimationClip[] dest) { foreach (SpriteAnimationKeyFrame kf in component.keyFrames) { int idx = -1; for (int i = 0; i < src.Length; i++) { if (kf.refClip == src[i]) { idx = i; break; } } if (idx >= 0) kf.refClip = dest[idx]; } }
public static void EnumComponent(SpriteAnimationClip clip, ComponentDelegate callback, bool skipNotExpand) { EnumComponent(clip.root, callback, skipNotExpand); }
public static void SetAnimationClipEvents(SpriteAnimationClip clip, SpriteAnimationEvent[] events) { clip.events = events; clip.CalcEvents(); }
public static void EnumComponent(SpriteAnimationClip clip, ComponentDelegate callback, bool skipNotExpand) { EnumComponent(clip.root, callback, skipNotExpand); }
public static SpriteAnimationComponent GetComponentByPath(SpriteAnimationClip clip, string path) { return clip.GetComponentByPathHash( EasyMotion2DUtility.GetHashCode( path )); }
/// <summary> /// Adds a clip to the animation with clip name.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> public void AddClip(SpriteAnimationClip clip) { AddClip(clip, clip.name, 0, clip.maxFrameIndex, false); }
public static SpriteAnimationComponent GetComponentByHashCode(SpriteAnimationClip clip, int hashcode) { return clip.GetComponentById(hashcode); }
private SpriteAnimationState(SpriteAnimationClip clip, SpriteAnimation animation, string name) { Init(clip, animation, name); }
public static bool Upgrade(SpriteAnimationClip clip) { return clip.Upgrade(); }
public static SpriteAnimationEvent[] GetAnimationClipEvents(SpriteAnimationClip clip) { return(clip.events); }
/// <summary> /// Adds a clip to the animation with clip name.<br/> /// If a clip with that name already exists it will be replaced with the new clip. /// </summary> /// <param name="clip">The clip you want add.</param> public void AddClip(SpriteAnimationClip clip) { if (clip == null || (clip != null && !clip)) { Debug.LogError("A null clip/missing clip add to animation!"); return; } AddClip(clip, clip.name, 0, clip.maxFrameIndex, false); }
public static void SetAnimationClipEvents(SpriteAnimationClip clip, SpriteAnimationEvent[] events) { clip.events = events; clip.CalcEvents(); }
internal SpriteAnimationState AddClip(SpriteAnimationClip clip, string newName, int firstFrame, int lastFrame, bool addLoopFrame) { if (clip == null || ( clip != null && !clip ) ) { Debug.LogError("A null clip/missing clip add to animation!"); return null; } SpriteAnimationState state = this[newName]; if ( state == null ) { state = SpriteAnimationState.CreateState(); state.Init(clip, this, newName); AddState(state); } else { state.Init(clip, this, newName); } SetClipRange(newName, firstFrame * clip.tick, lastFrame * clip.tick); List<SpriteAnimationClip> tmpAnis = new List<SpriteAnimationClip>(animations); if (!tmpAnis.Contains(clip)) { tmpAnis.Add(clip); animations = tmpAnis.ToArray(); } return state; }
/// <summary> /// Evaluate the component state at time. /// </summary> public SpriteAnimationKeyFrame Evaluate(float time, ref Vector2 position, ref float rotation, ref Vector2 scale, ref Vector2 shear, ref Color color, ref Sprite spr, ref SpriteAnimationClip refClip) { SpriteAnimationKeyFrame ret = keyFrames[0]; foreach (SpriteAnimationCurve curve in curves) { switch (curve.type) { case SpriteAnimationCurveType.KeyframeIndex: { int idx = (int)curve.curve.Evaluate(time); if ((keyFrames.Length - 1) >= idx) { ret = keyFrames[idx]; spr = ret.sprite; refClip = ret.refClip; } } break; case SpriteAnimationCurveType.PositionX: position.x = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.PositionY: position.y = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.Rotate: rotation = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ScaleX: scale.x = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ScaleY: scale.y = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ShearX: shear.x = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ShearY: shear.y = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorR: color.r = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorG: color.g = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorB: color.b = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorA: color.a = curve.curve.Evaluate(time); break; } } return ret; }
internal void SetClips(SpriteAnimationClip[] clips) { Clear(); if ( clips != null ) foreach (SpriteAnimationClip clip in clips) AddClip(clip); }
/// <summary> /// Clone a SpriteAnimationClip. /// </summary> /// <param name="source">Clip source.</param> /// <param name="init">Is need init the clone instance.</param> /// <returns>The clone instance.</returns> public static SpriteAnimationClip Duplicate(SpriteAnimationClip source, bool init) { SpriteAnimationClip ret = ScriptableObject.CreateInstance<SpriteAnimationClip>(); ret.name = source.name; ret.dataFormatVersion = source.dataFormatVersion; ret.frameRate = source.frameRate; ret.wrapMode = source.wrapMode; ret.events = source.events; ret.root = SpriteAnimationComponent.Duplicate(source.root); ret.root.clip = ret; ret.subComponents = new SpriteAnimationComponent[ source.subComponents.Length ]; foreach (SpriteAnimationComponent comp in source.subComponents) { SpriteAnimationComponent tmpComp = SpriteAnimationComponent.Duplicate(comp); tmpComp.clip = ret; ret.subComponents[ tmpComp.index ] = tmpComp; } if ( init ) ret.Init(false); return ret; }
/// <summary> /// Evaluate the component state at time. /// </summary> public SpriteAnimationKeyFrame Evaluate(float time, ref Vector2 position, ref float rotation, ref Vector2 scale, ref Vector2 shear, ref Color color, ref Sprite spr, ref SpriteAnimationClip refClip) { SpriteAnimationKeyFrame ret = keyFrames[0]; foreach (SpriteAnimationCurve curve in curves) { switch (curve.type) { case SpriteAnimationCurveType.KeyframeIndex: { int idx = (int)curve.curve.Evaluate(time); if ((keyFrames.Length - 1) >= idx) { ret = keyFrames[idx]; spr = ret.sprite; refClip = ret.refClip; } } break; case SpriteAnimationCurveType.PositionX: position.x = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.PositionY: position.y = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.Rotate: rotation = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ScaleX: scale.x = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ScaleY: scale.y = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ShearX: shear.x = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ShearY: shear.y = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorR: color.r = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorG: color.g = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorB: color.b = curve.curve.Evaluate(time); break; case SpriteAnimationCurveType.ColorA: color.a = curve.curve.Evaluate(time); break; } } return(ret); }
public void SetClip(SpriteAnimationClip clip) { refClip = clip; isRefClip = refClip != null; }