public WrapMode wrapMode; // animation wrap mode #endregion Fields #region Methods public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { int frameRate = seq.take.frameRate; float waitTime = getWaitTime(frameRate, 0.0f); Animation anim = (target as GameObject).GetComponent<Animation>(); float duration = wrapMode == WrapMode.Once ? amClip.length : ((seq.take.getLastFrame()-frame)+1)/(float)frameRate; Holoville.HOTween.Plugins.Core.ABSTweenPlugin plug; if(crossfade) { if(index > 0) { AMAnimationKey prevKey = track.keys[index - 1] as AMAnimationKey; plug = new AMPlugAnimationCrossFade(anim, crossfadeTime, prevKey.amClip.name, prevKey.wrapMode, prevKey.getWaitTime(frameRate, 0.0f), amClip.name, wrapMode, waitTime); } else plug = new AMPlugAnimation(anim, amClip.name, wrapMode, true, crossfadeTime); } else plug = new AMPlugAnimation(anim, amClip.name, wrapMode, false, 0.0f); seq.sequence.Insert(waitTime, HOTween.To(target, duration, new TweenParms().Prop("animation", plug))); //seq.Insert(new AMActionAnimation(this, seq.take.frameRate, (target as GameObject).animation)); //seq.sequence.InsertCallback(getWaitTime(seq.take.frameRate, 0.0f), OnMethodCallbackParams, (target as GameObject).animation, (float)seq.take.frameRate); }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { if(methodName == null) return; //get component and fill the cached method info Component comp; if(seq.target.isMeta) { if(string.IsNullOrEmpty(componentName)) return; comp = (target as GameObject).GetComponent(componentName); } else { if(component == null) return; comp = component; } if(cachedMethodInfo == null) cachedMethodInfo = comp.GetType().GetMethod(methodName, GetParamTypes()); float waitTime = getWaitTime(seq.take.frameRate, 0.0f); if(useSendMessage) { if(parameters == null || parameters.Count <= 0) seq.sequence.InsertCallback(waitTime, comp.gameObject, methodName, null, SendMessageOptions.DontRequireReceiver); else seq.sequence.InsertCallback(waitTime, comp.gameObject, methodName, parameters[0].toObject(), SendMessageOptions.DontRequireReceiver); } else { seq.sequence.InsertCallback(waitTime, OnMethodCallbackParams, comp, (object)buildParams()); } }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { GameObject go = target as GameObject; if(go == null) return; //active won't really be set, it's just a filler along with ease seq.Insert(new AMActionGOActive(this, seq.take.frameRate, go, setActive)); }
public override void buildSequenceStart(AMSequence seq) { GameObject go = GetTarget(seq.target) as GameObject; //need to add activate game object on start to 'reset' properly during reverse if(keys.Count > 0 && keys[0].frame > 0) { seq.Insert(new AMActionGOActive(0.0f, keys[0].getWaitTime(seq.take.frameRate, 0.0f), go, startActive)); } }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj) { Transform target = obj as Transform; int frameRate = seq.take.frameRate; //allow tracks with just one key if(track.keys.Count == 1) interp = (int)Interpolation.None; if(!canTween) { switch((track as AMRotationEulerTrack).axis) { case AMRotationEulerTrack.Axis.X: seq.Insert(new AMActionTransLocalRotEulerX(this, frameRate, target, rotation.x)); break; case AMRotationEulerTrack.Axis.Y: seq.Insert(new AMActionTransLocalRotEulerY(this, frameRate, target, rotation.y)); break; case AMRotationEulerTrack.Axis.Z: seq.Insert(new AMActionTransLocalRotEulerZ(this, frameRate, target, rotation.z)); break; default: seq.Insert(new AMActionTransLocalRotEuler(this, frameRate, target, rotation)); break; } } else if(endFrame == -1) return; else { Vector3 endRotation = (track.keys[index + 1] as AMRotationEulerKey).rotation; TweenParms tParms = new TweenParms(); switch((track as AMRotationEulerTrack).axis) { case AMRotationEulerTrack.Axis.X: tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEulerX(target, endRotation.x)); break; case AMRotationEulerTrack.Axis.Y: tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEulerY(target, endRotation.y)); break; case AMRotationEulerTrack.Axis.Z: tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEulerZ(target, endRotation.z)); break; default: tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEuler(target, endRotation)); break; } if(hasCustomEase()) tParms = tParms.Ease(easeCurve); else tParms = tParms.Ease((EaseType)easeType, amplitude, period); seq.Insert(this, HOTween.To(this, getTime(frameRate), tParms)); } }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { // if targets are equal do nothing if(endFrame == -1 || !hasTargets(seq.target) || targetsAreEqual(seq.target)) return; Camera[] allCameras = (track as AMCameraSwitcherTrack).GetCachedCameras(seq.target); //use 'this' with property 'type' as a placeholder since AMPlugCameraSwitcher does not require any property seq.Insert(this, HOTween.To(this, getTime(seq.take.frameRate), new TweenParms().Prop("type", new AMPlugCameraSwitcher(this, seq.take.frameRate, seq.target, allCameras)))); }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj) { int frameRate = seq.take.frameRate; //allow tracks with just one key if(track.keys.Count == 1) interp = (int)Interpolation.None; AMTranslationTrack tTrack = track as AMTranslationTrack; bool pixelSnap = tTrack.pixelSnap; float ppu = tTrack.pixelPerUnit; if(!canTween) { //TODO: world position seq.Insert(new AMActionTransLocalPos(this, frameRate, obj as Transform, pixelSnap ? new Vector3(Mathf.Round(position.x*ppu)/ppu, Mathf.Round(position.y*ppu)/ppu, Mathf.Round(position.z*ppu)/ppu) : position)); } else { if(path.Length <= 1) return; if(getNumberOfFrames(seq.take.frameRate) <= 0) return; object tweenTarget = obj; string tweenProp = "localPosition"; Tweener ret = null; bool isRelative = false; if(hasCustomEase()) { if(path.Length == 2) ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative, PathType.Linear) : new PlugVector3Path(path, isRelative, PathType.Linear)).Ease(easeCurve)); else { PlugVector3Path p = pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative) : new PlugVector3Path(path, isRelative); p.ClosePath(isClosed); ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, p).Ease(easeCurve)); } } else { if(path.Length == 2) ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative, PathType.Linear) : new PlugVector3Path(path, isRelative, PathType.Linear)).Ease((EaseType)easeType, amplitude, period)); else { PlugVector3Path p = pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative) : new PlugVector3Path(path, isRelative); p.ClosePath(isClosed); ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, p).Ease((EaseType)easeType, amplitude, period)); } } seq.Insert(this, ret); } }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj) { if(!obj) return; int frameRate = seq.take.frameRate; if(!canTween) { seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(GetTarget(seq.target), null)))); } if(endFrame == -1) return; Transform tgt = GetTarget(seq.target), tgte = (track.keys[index+1] as AMOrientationKey).GetTarget(seq.target); if(tgt == tgte) { seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(tgt, null)))); } else { if(hasCustomEase()) { seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(tgt, tgte)).Ease(easeCurve))); } else { seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(tgt, tgte)).Ease((EaseType)easeType, amplitude, period))); } } }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj) { int frameRate = seq.take.frameRate; //allow tracks with just one key if(track.keys.Count == 1) interp = (int)Interpolation.None; if(!canTween) { seq.Insert(new AMActionTransLocalRot(this, frameRate, obj as Transform, rotation)); } else if(endFrame == -1) return; else { Quaternion endRotation = (track.keys[index + 1] as AMRotationKey).rotation; if(hasCustomEase()) seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("localRotation", new AMPlugQuaternionSlerp(endRotation)).Ease(easeCurve))); else seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("localRotation", new AMPlugQuaternionSlerp(endRotation)).Ease((EaseType)easeType, amplitude, period))); } }
/// <summary> /// Use sequence to insert callbacks, or some other crap, just don't insert the tweener you are returning! /// target is set if required. index = this key's index in the track /// </summary> public virtual void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { Debug.LogError("Animator: No override for build."); }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { AMMaterialTrack matTrack = track as AMMaterialTrack; Material matInst = matTrack.materialInstance; string prop = matTrack.property; AMMaterialTrack.ValueType propType = matTrack.propertyType; int frameRate = seq.take.frameRate; switch(propType) { case AMMaterialTrack.ValueType.Float: case AMMaterialTrack.ValueType.Range: if(!canTween || matTrack.keys.Count == 1) //allow one key seq.Insert(new AMActionMaterialFloatSet(this, frameRate, matInst, prop, val)); else { AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey; if(targetsAreEqual(propType, endKey)) return; if(hasCustomEase()) seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialFloat(matInst, prop, endKey.val)).Ease(easeCurve))); else seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialFloat(matInst, prop, endKey.val)).Ease((EaseType)easeType, amplitude, period))); } break; case AMMaterialTrack.ValueType.Vector: if(!canTween || matTrack.keys.Count == 1) //allow one key seq.Insert(new AMActionMaterialVectorSet(this, frameRate, matInst, prop, vector)); else { AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey; if(targetsAreEqual(propType, endKey)) return; if(hasCustomEase()) seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialVector4(matInst, prop, endKey.vector)).Ease(easeCurve))); else seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialVector4(matInst, prop, endKey.vector)).Ease((EaseType)easeType, amplitude, period))); } break; case AMMaterialTrack.ValueType.Color: if(!canTween || matTrack.keys.Count == 1) //allow one key seq.Insert(new AMActionMaterialColorSet(this, frameRate, matInst, prop, color)); else { AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey; if(targetsAreEqual(propType, endKey)) return; if(hasCustomEase()) seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialColor(matInst, prop, endKey.color)).Ease(easeCurve))); else seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialColor(matInst, prop, endKey.color)).Ease((EaseType)easeType, amplitude, period))); } break; case AMMaterialTrack.ValueType.TexOfs: if(!canTween || matTrack.keys.Count == 1) //allow one key seq.Insert(new AMActionMaterialTexOfsSet(this, frameRate, matInst, prop, texOfs)); else { AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey; if(targetsAreEqual(propType, endKey)) return; if(hasCustomEase()) seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexOfs(matInst, prop, endKey.texOfs)).Ease(easeCurve))); else seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexOfs(matInst, prop, endKey.texOfs)).Ease((EaseType)easeType, amplitude, period))); } break; case AMMaterialTrack.ValueType.TexScale: if(!canTween || matTrack.keys.Count == 1) //allow one key seq.Insert(new AMActionMaterialTexScaleSet(this, frameRate, matInst, prop, texScale)); else { AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey; if(targetsAreEqual(propType, endKey)) return; if(hasCustomEase()) seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexScale(matInst, prop, endKey.texScale)).Ease(easeCurve))); else seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexScale(matInst, prop, endKey.texScale)).Ease((EaseType)easeType, amplitude, period))); } break; case AMMaterialTrack.ValueType.TexEnv: seq.Insert(new AMActionMaterialTexSet(this, frameRate, matInst, prop, texture)); break; } }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj) { seq.sequence.InsertCallback(getWaitTime(seq.take.frameRate, 0.0f), seq.triggerCallback, this, new AMTriggerData() { valueString=this.valueString, valueInt=this.valueInt, valueFloat=this.valueFloat }); }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { float sTime = getWaitTime(seq.take.frameRate, 0.0f); seq.sequence.InsertCallback(sTime, OnMethodCallbackParams, target as AudioSource); }
void Awake() { if(!Application.isPlaying) return; _dataHolder.SetActive(false); List<AMTakeData> _t = _takes; mSequences = new AMSequence[_t.Count]; for(int i = 0; i < mSequences.Length; i++) mSequences[i] = new AMSequence(this, i, _t[i]); }
void AMITarget.SequenceTrigger(AMSequence seq, AMKey key, AMTriggerData trigDat) { if(takeTriggerCallback != null) takeTriggerCallback(this, seq.take, key, trigDat); }
public virtual void buildSequenceStart(AMSequence sequence) { }
public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target) { AMPropertyTrack propTrack = track as AMPropertyTrack; if(endFrame == -1 && canTween && propTrack.canTween) return; int valueType = propTrack.valueType; //get component and fill the cached method info Component comp = propTrack.GetTargetComp(target as GameObject); if(comp == null) return; string varName = propTrack.getMemberName(); int frameRate = seq.take.frameRate; //change to use setvalue track in AMSequence if(!string.IsNullOrEmpty(varName)) { if(propTrack.canTween) { //allow tracks with just one key if(track.keys.Count == 1) interp = (int)Interpolation.None; if(!canTween) { object obj = null; switch((AMPropertyTrack.ValueType)valueType) { case AMPropertyTrack.ValueType.Integer: obj = System.Convert.ToInt32(val); break; case AMPropertyTrack.ValueType.Float: obj = System.Convert.ToSingle(val); break; case AMPropertyTrack.ValueType.Double: obj = val; break; case AMPropertyTrack.ValueType.Long: obj = System.Convert.ToInt64(val); break; case AMPropertyTrack.ValueType.Vector2: obj = vect2; break; case AMPropertyTrack.ValueType.Vector3: obj = vect3; break; case AMPropertyTrack.ValueType.Color: obj = color; break; case AMPropertyTrack.ValueType.Rect: obj = rect; break; case AMPropertyTrack.ValueType.Vector4: obj = vect4; break; case AMPropertyTrack.ValueType.Quaternion: obj = quat; break; } if(obj != null) seq.Insert(GenerateActionData(propTrack, frameRate, comp, obj)); } else { //grab end frame AMPropertyKey endKey = track.keys[index + 1] as AMPropertyKey; if(targetsAreEqual(valueType, endKey)) return; if(hasCustomEase()) { switch((AMPropertyTrack.ValueType)valueType) { case AMPropertyTrack.ValueType.Integer: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToInt32(endKey.val)).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Float: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToSingle(endKey.val)).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Double: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugDouble(endKey.val)).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Long: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugLong(System.Convert.ToInt64(endKey.val))).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Vector2: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect2).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Vector3: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect3).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Color: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.color).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Rect: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.rect).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Vector4: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect4).Ease(easeCurve))); break; case AMPropertyTrack.ValueType.Quaternion: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugQuaternionSlerp(endKey.quat)).Ease(easeCurve))); break; } } else { switch((AMPropertyTrack.ValueType)valueType) { case AMPropertyTrack.ValueType.Integer: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToInt32(endKey.val)).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Float: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToSingle(endKey.val)).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Double: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugDouble(endKey.val)).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Long: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugLong(System.Convert.ToInt64(endKey.val))).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Vector2: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect2).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Vector3: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect3).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Color: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.color).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Rect: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.rect).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Vector4: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect4).Ease((EaseType)easeType, amplitude, period))); break; case AMPropertyTrack.ValueType.Quaternion: seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugQuaternionSlerp(endKey.quat)).Ease((EaseType)easeType, amplitude, period))); break; } } } } else { if(endFrame == -1) endFrame = frame + 1; if(valueType == (int)AMPropertyTrack.ValueType.Bool) { seq.Insert(GenerateActionData(propTrack, frameRate, comp, val > 0.0f)); } else if(valueType == (int)AMPropertyTrack.ValueType.String) { seq.Insert(GenerateActionData(propTrack, frameRate, comp, valString)); } else if(valueType == (int)AMPropertyTrack.ValueType.Sprite) { seq.Insert(new AMActionSpriteSet(this, frameRate, comp as SpriteRenderer, valObj as Sprite)); } else if(valueType == (int)AMPropertyTrack.ValueType.Enum) { System.Type infType = propTrack.GetCachedInfoType(seq.target); object enumVal = infType != null ? System.Enum.ToObject(infType, (int)val) : null; if(enumVal != null) { seq.Insert(GenerateActionData(propTrack, frameRate, comp, enumVal)); } else { Debug.LogError("Invalid enum value."); } } } } else Debug.LogError("Animator: No FieldInfo or PropertyInfo set."); return; }
public override void buildSequenceStart(AMSequence sequence) { //cache material instance Init(sequence.target); }
void AMITarget.SequenceComplete(AMSequence seq) { //end camera fade if(AMCameraFade.hasInstance()) { AMCameraFade cf = AMCameraFade.getCameraFade(); cf.playParam = null; } mLastPlayingTakeIndex = mNowPlayingTakeIndex; mNowPlayingTakeIndex = -1; if(takeCompleteCallback != null) takeCompleteCallback(this, seq.take); }