public override void ActionAnimAssignValues(ActionAnim action, List <ActionParameter> parameters) { action.runtimeAnimator = action.AssignFile <Animator> (parameters, action.parameterID, action.constantID, action.animator); if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue) { switch (action.mecanimParameterType) { case MecanimParameterType.Bool: BoolValue boolValue = (action.parameterValue <= 0f) ? BoolValue.False : BoolValue.True; boolValue = action.AssignBoolean(parameters, action.parameterValueParameterID, boolValue); action.parameterValue = (boolValue == BoolValue.True) ? 1f : 0f; break; case MecanimParameterType.Int: action.parameterValue = (float)action.AssignInteger(parameters, action.parameterValueParameterID, (int)action.parameterValue); break; case MecanimParameterType.Float: action.parameterValue = action.AssignFloat(parameters, action.parameterValueParameterID, action.parameterValue); break; default: break; } } }
public override void ActionAnimSkip(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action._anim2D && action.clip2D != "") { if (action.method == AnimMethod.PlayCustom) { if (action.wrapMode2D == ActionAnim.WrapMode2D.Loop) { tk2DIntegration.PlayAnimation(action._anim2D, action.clip2D, true, WrapMode.Loop); } else if (action.wrapMode2D == ActionAnim.WrapMode2D.PingPong) { tk2DIntegration.PlayAnimation(action._anim2D, action.clip2D, true, WrapMode.PingPong); } else { tk2DIntegration.PlayAnimation(action._anim2D, action.clip2D, true, WrapMode.Once); } } else if (action.method == AnimMethod.StopCustom) { tk2DIntegration.StopAnimation(action._anim2D); } } } }
public override void ActionAnimSkip(ActionAnim action) { if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue && action.animator && action.parameterName != "") { if (action.mecanimParameterType == MecanimParameterType.Float) { action.animator.SetFloat(action.parameterName, action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Int) { action.animator.SetInteger(action.parameterName, (int)action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Bool) { bool paramValue = false; if (action.parameterValue > 0f) { paramValue = true; } action.animator.SetBool(action.parameterName, paramValue); } else if (action.mecanimParameterType == MecanimParameterType.Trigger) { action.animator.SetTrigger(action.parameterName); } } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom && action.animator) { if (action.clip2D != "") { action.animator.CrossFade(action.clip2D, action.fadeTime, action.layerInt); } } }
public override void ActionAnimSkip(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.runtimeAnim2D != null && !string.IsNullOrEmpty(action.clip2D)) { if (action.method == AnimMethod.PlayCustom) { if (action.wrapMode2D == ActionAnim.WrapMode2D.Loop) { tk2DIntegration.PlayAnimation(action.runtimeAnim2D, action.clip2D, true, WrapMode.Loop); } else if (action.wrapMode2D == ActionAnim.WrapMode2D.PingPong) { tk2DIntegration.PlayAnimation(action.runtimeAnim2D, action.clip2D, true, WrapMode.PingPong); } else { tk2DIntegration.PlayAnimation(action.runtimeAnim2D, action.clip2D, true, WrapMode.Once); } } else if (action.method == AnimMethod.StopCustom) { tk2DIntegration.StopAnimation(action.runtimeAnim2D); } } } }
public override void ActionAnimSkip(ActionAnim action) { if (action.method == AnimMethod.PlayCustom && action.runtimeAnim && action.clip) { AdvGame.CleanUnusedClips(action.runtimeAnim); WrapMode wrap = WrapMode.Once; if (action.playMode == AnimPlayMode.PlayOnceAndClamp) { wrap = WrapMode.ClampForever; } else if (action.playMode == AnimPlayMode.Loop) { wrap = WrapMode.Loop; } AdvGame.PlayAnimClipFrame(action.runtimeAnim, 0, action.clip, action.blendMode, wrap, 0f, null, 1f); } else if (action.method == AnimMethod.StopCustom && action.runtimeAnim && action.clip) { AdvGame.CleanUnusedClips(action.runtimeAnim); action.runtimeAnim.Blend(action.clip.name, 0f, 0f); } else if (action.method == AnimMethod.BlendShape && action.shapeKey > -1) { if (action.runtimeShapeObject != null) { action.runtimeShapeObject.Change(action.shapeKey, action.shapeValue, 0f); } } }
public override void ActionAnimGUI(ActionAnim action, List <ActionParameter> parameters) { #if UNITY_EDITOR action.methodMecanim = (AnimMethodMecanim)EditorGUILayout.EnumPopup("Method:", action.methodMecanim); if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue || action.methodMecanim == AnimMethodMecanim.PlayCustom) { action.parameterID = AC.Action.ChooseParameterGUI("Animator:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.animator = null; } else { action.animator = (Animator)EditorGUILayout.ObjectField("Animator:", action.animator, typeof(Animator), true); action.constantID = action.FieldToID <Animator> (action.animator, action.constantID); action.animator = action.IDToField <Animator> (action.animator, action.constantID, false); } } if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue) { action.parameterNameID = Action.ChooseParameterGUI("Parameter to affect:", parameters, action.parameterNameID, ParameterType.String); if (action.parameterNameID < 0) { action.parameterName = EditorGUILayout.TextField("Parameter to affect:", action.parameterName); } action.mecanimParameterType = (MecanimParameterType)EditorGUILayout.EnumPopup("Parameter type:", action.mecanimParameterType); if (action.mecanimParameterType != MecanimParameterType.Trigger) { action.parameterValue = EditorGUILayout.FloatField("Set as value:", action.parameterValue); } } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom) { action.clip2DParameterID = Action.ChooseParameterGUI("Clip:", parameters, action.clip2DParameterID, ParameterType.String); if (action.clip2DParameterID < 0) { action.clip2D = EditorGUILayout.TextField("Clip:", action.clip2D); } action.layerInt = EditorGUILayout.IntField("Mecanim layer:", action.layerInt); action.fadeTime = EditorGUILayout.Slider("Transition time:", action.fadeTime, 0f, 2f); action.willWait = EditorGUILayout.Toggle("Wait until finish?", action.willWait); } else if (action.methodMecanim == AnimMethodMecanim.BlendShape) { EditorGUILayout.HelpBox("This method is not compatible with Sprites Unity Complex.", MessageType.Info); } if (GUI.changed) { EditorUtility.SetDirty(action); } #endif }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.runtimeAnim2D != null && !string.IsNullOrEmpty(action.clip2D)) { if (action.method == AnimMethod.PlayCustom) { if (action.wrapMode2D == ActionAnim.WrapMode2D.Loop) { tk2DIntegration.PlayAnimation(action.runtimeAnim2D, action.clip2D, true, WrapMode.Loop); } else if (action.wrapMode2D == ActionAnim.WrapMode2D.PingPong) { tk2DIntegration.PlayAnimation(action.runtimeAnim2D, action.clip2D, true, WrapMode.PingPong); } else { tk2DIntegration.PlayAnimation(action.runtimeAnim2D, action.clip2D, true, WrapMode.Once); } if (action.willWait) { return(action.defaultPauseTime); } } else if (action.method == AnimMethod.StopCustom) { tk2DIntegration.StopAnimation(action.runtimeAnim2D); } else if (action.method == AnimMethod.BlendShape) { action.ReportWarning("BlendShapes are not available for 2D animation."); return(0f); } } } else { if (action.runtimeAnim2D != null && !string.IsNullOrEmpty(action.clip2D)) { if (!tk2DIntegration.IsAnimationPlaying(action.runtimeAnim2D, action.clip2D)) { action.isRunning = false; } else { return(Time.deltaTime); } } } return(0f); }
public override bool RequiresRememberAnimator(ActionAnim action) { if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue || action.methodMecanim == AnimMethodMecanim.PlayCustom) { return(true); } return(false); }
public override void ActionAnimSkip(ActionAnim action) { if (action.runtimeAnimator && !string.IsNullOrEmpty(action.clip2D)) { if (action.method == AnimMethod.PlayCustom) { action.runtimeAnimator.Play(action.clip2D, action.layerInt, 0.8f); } } }
public override void ActionAnimSkip(ActionAnim action) { if (action.animator && action.clip2D != "") { if (action.method == AnimMethod.PlayCustom) { action.animator.Play(action.clip2D, action.layerInt, 0.8f); } } }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.runtimeAnimator && !string.IsNullOrEmpty(action.clip2D)) { if (action.method == AnimMethod.PlayCustom) { #if UNITY_EDITOR int hash = Animator.StringToHash(action.clip2D); if (!action.runtimeAnimator.HasState(action.layerInt, hash)) { action.ReportWarning("Cannot play clip " + action.clip2D + " on " + action.runtimeAnimator.name, action.runtimeAnimator.gameObject); } #endif action.runtimeAnimator.CrossFade(action.clip2D, action.fadeTime, action.layerInt); if (action.willWait) { // In 2019, sometimes more than 1 frame is necessary for the transition to kick in #if UNITY_2019_1_OR_NEWER return(Time.fixedDeltaTime * 2f); #else return(action.defaultPauseTime); #endif } } else if (action.method == AnimMethod.BlendShape) { action.ReportWarning("BlendShapes not available for 2D animation."); return(0f); } } } else { if (action.runtimeAnimator && !string.IsNullOrEmpty(action.clip2D)) { if (action.runtimeAnimator.GetCurrentAnimatorStateInfo(action.layerInt).normalizedTime < 1f) { return(action.defaultPauseTime / 6f); } else { action.isRunning = false; return(0f); } } } return(0f); }
/** * <summary>Creates a new instance of the 'Object: Animate' Action, set to change an Animator's trigger parameter value using the 'Mecanim' engine</summary> * <param name = "animator">The Animator to manipulate</param> * <param name = "parameterName">The name of the parameter</param> * <param name = "newValue">The parameter's new value</param> * <returns>The generated Action</returns> */ public static ActionAnim CreateNew_Mecanim_ChangeParameterValue(Animator animator, string parameterName) { ActionAnim newAction = (ActionAnim)CreateInstance <ActionAnim>(); newAction.animationEngine = AnimationEngine.Mecanim; newAction.methodMecanim = AnimMethodMecanim.ChangeParameterValue; newAction.animator = animator; newAction.parameterName = parameterName; newAction.mecanimParameterType = MecanimParameterType.Trigger; newAction.parameterValue = 0f; return(newAction); }
/** * <summary>Creates a new instance of the 'Object: Animate' Action, set to change an Animator's bool parameter value using the 'Sprites Unity Complex' engine</summary> * <param name = "animator">The Animator to manipulate</param> * <param name = "parameterName">The name of the parameter</param> * <param name = "newValue">The parameter's new value</param> * <returns>The generated Action</returns> */ public static ActionAnim CreateNew_SpritesUnityComplex_ChangeParameterValue(Animator animator, string parameterName, bool newValue) { ActionAnim newAction = (ActionAnim)CreateInstance <ActionAnim>(); newAction.animationEngine = AnimationEngine.SpritesUnityComplex; newAction.methodMecanim = AnimMethodMecanim.ChangeParameterValue; newAction.animator = animator; newAction.parameterName = parameterName; newAction.mecanimParameterType = MecanimParameterType.Bool; newAction.parameterValue = (newValue) ? 1f : 0f; return(newAction); }
/** * <summary>Creates a new instance of the 'Object: Animate' Action, set to play a custom animation using the 'Sprites Unity' engine</summary> * <param name = "animator">The Animator to manipulate</param> * <param name = "clipName">The animation clip name to play</param> * <param name = "layerIndex">The index number on the Animator Controller that the animation clip is located in</param> * <param name = "transitionTime">The time, in seconds, to take when transitioning from the old to the new animation</param> * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param> * <returns>The generated Action</returns> */ public static ActionAnim CreateNew_SpritesUnity_PlayCustom(Animator animator, string clipName, int layerIndex, float transitionTime = 0f, bool waitUntilFinish = false) { ActionAnim newAction = (ActionAnim)CreateInstance <ActionAnim>(); newAction.animationEngine = AnimationEngine.SpritesUnity; newAction.animator = animator; newAction.clip2D = clipName; newAction.layerInt = layerIndex; newAction.fadeTime = transitionTime; newAction.willWait = waitUntilFinish; return(newAction); }
public override void ActionAnimGUI(ActionAnim action, List<ActionParameter> parameters) { #if UNITY_EDITOR action.methodMecanim = (AnimMethodMecanim) EditorGUILayout.EnumPopup ("Method:", action.methodMecanim); if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue || action.methodMecanim == AnimMethodMecanim.PlayCustom) { action.parameterID = AC.Action.ChooseParameterGUI ("Animator:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.animator = null; } else { action.animator = (Animator) EditorGUILayout.ObjectField ("Animator:", action.animator, typeof (Animator), true); action.constantID = action.FieldToID <Animator> (action.animator, action.constantID); action.animator = action.IDToField <Animator> (action.animator, action.constantID, false); } } if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue) { action.parameterName = EditorGUILayout.TextField ("Parameter to affect:", action.parameterName); action.mecanimParameterType = (MecanimParameterType) EditorGUILayout.EnumPopup ("Parameter type:", action.mecanimParameterType); if (action.mecanimParameterType != MecanimParameterType.Trigger) { action.parameterValue = EditorGUILayout.FloatField ("Set as value:", action.parameterValue); } } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom) { action.clip2D = EditorGUILayout.TextField ("Clip:", action.clip2D); action.layerInt = EditorGUILayout.IntField ("Mecanim layer:", action.layerInt); action.fadeTime = EditorGUILayout.Slider ("Transition time:", action.fadeTime, 0f, 2f); action.willWait = EditorGUILayout.Toggle ("Wait until finish?", action.willWait); } else if (action.methodMecanim == AnimMethodMecanim.BlendShape) { EditorGUILayout.HelpBox ("This method is not compatible with Sprites Unity Complex.", MessageType.Info); } if (GUI.changed) { EditorUtility.SetDirty (action); } #endif }
public override void ActionAnimSkip(ActionAnim action) { if (action.methodMecanim == AnimMethodMecanim.BlendShape) { if (action.shapeObject) { action.shapeObject.Change(action.shapeKey, action.shapeValue, action.fadeTime); } } else { ActionAnimProcess(action, true); } }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.runtimeAnimator && !string.IsNullOrEmpty(action.clip2D)) { if (action.method == AnimMethod.PlayCustom) { #if UNITY_EDITOR && (UNITY_5 || UNITY_2017_1_OR_NEWER) int hash = Animator.StringToHash(action.clip2D); if (!action.runtimeAnimator.HasState(action.layerInt, hash)) { ACDebug.LogWarning("Cannot play clip " + action.clip2D + " on " + action.runtimeAnimator.name, action.runtimeAnimator.gameObject); } #endif action.runtimeAnimator.CrossFade(action.clip2D, action.fadeTime, action.layerInt); if (action.willWait) { return(action.defaultPauseTime); } } else if (action.method == AnimMethod.BlendShape) { ACDebug.LogWarning("BlendShapes not available for 2D animation."); return(0f); } } } else { if (action.runtimeAnimator && !string.IsNullOrEmpty(action.clip2D)) { if (action.runtimeAnimator.GetCurrentAnimatorStateInfo(action.layerInt).normalizedTime < 1f) { return(action.defaultPauseTime / 6f); } else { action.isRunning = false; return(0f); } } } return(0f); }
/** * <summary>Creates a new instance of the 'Object: Animate' Action, set to control Blendshapes</summary> * <param name = "shapeable">The Shapeable to manipulate</param> * <param name = "shapeKey">The ID of the key to affect</param> * <param name = "shape">The shape key's new value</param> * <param name = "transitionTime">The time, in seconds, to take when transitioning</param> * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param> * <returns>The generated Action</returns> */ public static ActionAnim CreateNew_BlendShape(Shapeable shapeable, int shapeKey, float shapeValue, float transitionTime = 1f, bool waitUntilFinish = false) { ActionAnim newAction = (ActionAnim)CreateInstance <ActionAnim>(); newAction.animationEngine = AnimationEngine.Mecanim; newAction.methodMecanim = AnimMethodMecanim.BlendShape; newAction.shapeObject = shapeable; newAction.shapeKey = shapeKey; newAction.shapeValue = shapeValue; newAction.fadeTime = transitionTime; newAction.willWait = waitUntilFinish; return(newAction); }
public override void ActionAnimGUI(ActionAnim action, List <ActionParameter> parameters) { #if UNITY_EDITOR action.method = (AnimMethod)EditorGUILayout.EnumPopup("Method:", action.method); action.parameterID = AC.Action.ChooseParameterGUI("Object:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action._anim2D = null; } else { action._anim2D = (Transform)EditorGUILayout.ObjectField("Object:", action._anim2D, typeof(Transform), true); action.constantID = action.FieldToID(action._anim2D, action.constantID); action._anim2D = action.IDToField(action._anim2D, action.constantID, false); } if (action.method == AnimMethod.PlayCustom) { action.clip2DParameterID = Action.ChooseParameterGUI("Clip:", parameters, action.clip2DParameterID, ParameterType.String); if (action.clip2DParameterID < 0) { action.clip2D = EditorGUILayout.TextField("Clip:", action.clip2D); } action.wrapMode2D = (ActionAnim.WrapMode2D)EditorGUILayout.EnumPopup("Play mode:", action.wrapMode2D); if (action.wrapMode2D == ActionAnim.WrapMode2D.Once) { action.willWait = EditorGUILayout.Toggle("Wait until finish?", action.willWait); } else { action.willWait = false; } } else if (action.method == AnimMethod.BlendShape) { EditorGUILayout.HelpBox("BlendShapes are not available in 2D animation.", MessageType.Info); } if (GUI.changed && action != null) { EditorUtility.SetDirty(action); } #endif }
public override string ActionAnimLabel(ActionAnim action) { string label = ""; if (action.animator) { label = action.animator.name; if (action.method == AnimMethod.PlayCustom && action.clip2D != "") { label += " - " + action.clip2D; } } return label; }
public override string ActionAnimLabel(ActionAnim action) { string label = ""; if (action.animator) { label = action.animator.name; if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue && action.parameterName != "") { label += " - " + action.parameterName; } } return(label); }
public override string ActionAnimLabel(ActionAnim action) { string label = ""; if (action.animator) { label = action.animator.name; if (action.method == AnimMethod.PlayCustom && action.clip2D != "") { label += " - " + action.clip2D; } } return(label); }
public override string ActionAnimLabel(ActionAnim action) { string label = ""; if (action._anim2D) { label = action._anim2D.name; if (action.method == AnimMethod.PlayCustom && !string.IsNullOrEmpty(action.clip2D)) { label += " - " + action.clip2D; } } return(label); }
public override void ActionAnimGUI(ActionAnim action, List <ActionParameter> parameters) { #if UNITY_EDITOR action.method = (AnimMethod)EditorGUILayout.EnumPopup("Method:", action.method); if (action.method == AnimMethod.PlayCustom) { action.parameterID = AC.Action.ChooseParameterGUI("Animator:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.animator = null; } else { action.animator = (Animator)EditorGUILayout.ObjectField("Animator:", action.animator, typeof(Animator), true); action.constantID = action.FieldToID <Animator> (action.animator, action.constantID); action.animator = action.IDToField <Animator> (action.animator, action.constantID, false); } action.clip2DParameterID = Action.ChooseParameterGUI("Clip:", parameters, action.clip2DParameterID, ParameterType.String); if (action.clip2DParameterID < 0) { action.clip2D = EditorGUILayout.TextField("Clip:", action.clip2D); } action.layerInt = EditorGUILayout.IntField("Mecanim layer:", action.layerInt); action.fadeTime = EditorGUILayout.Slider("Transition time:", action.fadeTime, 0f, 2f); action.willWait = EditorGUILayout.Toggle("Wait until finish?", action.willWait); } else if (action.method == AnimMethod.StopCustom) { EditorGUILayout.HelpBox("'Stop Custom' is not available for Unity-based 2D animation.", MessageType.Info); } else if (action.method == AnimMethod.BlendShape) { EditorGUILayout.HelpBox("BlendShapes are not available in 2D animation.", MessageType.Info); } if (GUI.changed) { EditorUtility.SetDirty(action); } #endif }
public override void ActionAnimGUI(ActionAnim action, List<ActionParameter> parameters) { #if UNITY_EDITOR action.method = (AnimMethod) EditorGUILayout.EnumPopup ("Method:", action.method); action.parameterID = AC.Action.ChooseParameterGUI ("Object:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action._anim2D = null; } else { action._anim2D = (Transform) EditorGUILayout.ObjectField ("Object:", action._anim2D, typeof (Transform), true); action.constantID = action.FieldToID (action._anim2D, action.constantID); action._anim2D = action.IDToField (action._anim2D, action.constantID, false); } if (action.method == AnimMethod.PlayCustom) { action.clip2D = EditorGUILayout.TextField ("Clip:", action.clip2D); action.wrapMode2D = (ActionAnim.WrapMode2D) EditorGUILayout.EnumPopup ("Play mode:", action.wrapMode2D); if (action.wrapMode2D == ActionAnim.WrapMode2D.Once) { action.willWait = EditorGUILayout.Toggle ("Wait until finish?", action.willWait); } else { action.willWait = false; } } else if (action.method == AnimMethod.BlendShape) { EditorGUILayout.HelpBox ("BlendShapes are not available in 2D animation.", MessageType.Info); } if (GUI.changed) { EditorUtility.SetDirty (action); } #endif }
public override void ActionAnimGUI(ActionAnim action, List<ActionParameter> parameters) { #if UNITY_EDITOR action.method = (AnimMethod) EditorGUILayout.EnumPopup ("Method:", action.method); if (action.method == AnimMethod.PlayCustom) { action.parameterID = AC.Action.ChooseParameterGUI ("Animator:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.animator = null; } else { action.animator = (Animator) EditorGUILayout.ObjectField ("Animator:", action.animator, typeof (Animator), true); action.constantID = action.FieldToID <Animator> (action.animator, action.constantID); action.animator = action.IDToField <Animator> (action.animator, action.constantID, false); } action.clip2D = EditorGUILayout.TextField ("Clip:", action.clip2D); action.layerInt = EditorGUILayout.IntField ("Mecanim layer:", action.layerInt); action.fadeTime = EditorGUILayout.Slider ("Transition time:", action.fadeTime, 0f, 2f); action.willWait = EditorGUILayout.Toggle ("Wait until finish?", action.willWait); } else if (action.method == AnimMethod.StopCustom) { EditorGUILayout.HelpBox ("'Stop Custom' is not available for Unity-based 2D animation.", MessageType.Info); } else if (action.method == AnimMethod.BlendShape) { EditorGUILayout.HelpBox ("BlendShapes are not available in 2D animation.", MessageType.Info); } if (GUI.changed) { EditorUtility.SetDirty (action); } #endif }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.animator && action.clip2D != "") { if (action.method == AnimMethod.PlayCustom) { action.animator.CrossFade(action.clip2D, action.fadeTime, action.layerInt); if (action.willWait) { return(action.defaultPauseTime); } } else if (action.method == AnimMethod.BlendShape) { ACDebug.LogWarning("BlendShapes not available for 2D animation."); return(0f); } } } else { if (action.animator && action.clip2D != "") { if (action.animator.GetCurrentAnimatorStateInfo(action.layerInt).normalizedTime < 1f) { return(action.defaultPauseTime / 6f); } else { action.isRunning = false; return(0f); } } } return(0f); }
public override string ActionAnimLabel(ActionAnim action) { string label = string.Empty; if (action._anim) { label = action._anim.name; if (action.method == AnimMethod.PlayCustom && action.clip) { label += " - Play " + action.clip.name; } else if (action.method == AnimMethod.StopCustom && action.clip) { label += " - Stop " + action.clip.name; } else if (action.method == AnimMethod.BlendShape) { label += " - Shapekey"; } } return(label); }
public override void ActionAnimSkip(ActionAnim action) { if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue && action.animator && action.parameterName != "") { if (action.mecanimParameterType == MecanimParameterType.Float) { action.animator.SetFloat (action.parameterName, action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Int) { action.animator.SetInteger (action.parameterName, (int) action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Bool) { bool paramValue = false; if (action.parameterValue > 0f) { paramValue = true; } action.animator.SetBool (action.parameterName, paramValue); } else if (action.mecanimParameterType == MecanimParameterType.Trigger) { action.animator.SetTrigger (action.parameterName); } } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom && action.animator) { if (action.clip2D != "") { action.animator.CrossFade (action.clip2D, action.fadeTime, action.layerInt); } } }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue && action.animator && action.parameterName != "") { if (action.mecanimParameterType == MecanimParameterType.Float) { action.animator.SetFloat (action.parameterName, action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Int) { action.animator.SetInteger (action.parameterName, (int) action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Bool) { bool paramValue = false; if (action.parameterValue > 0f) { paramValue = true; } action.animator.SetBool (action.parameterName, paramValue); } else if (action.mecanimParameterType == MecanimParameterType.Trigger) { action.animator.SetTrigger (action.parameterName); } return 0f; } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom && action.animator) { if (action.clip2D != "") { action.animator.CrossFade (action.clip2D, action.fadeTime, action.layerInt); if (action.willWait) { return (action.defaultPauseTime); } } } } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom) { if (action.animator && action.clip2D != "") { if (action.animator.GetCurrentAnimatorStateInfo (action.layerInt).normalizedTime < 1f) { return (action.defaultPauseTime / 6f); } else { action.isRunning = false; return 0f; } } } return 0f; }
private float ActionAnimProcess(ActionAnim action, bool isSkipping) { if (!action.isRunning) { action.isRunning = true; if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue && action.animator && action.parameterName != "") { if (action.mecanimParameterType == MecanimParameterType.Float) { action.animator.SetFloat(action.parameterName, action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Int) { action.animator.SetInteger(action.parameterName, (int)action.parameterValue); } else if (action.mecanimParameterType == MecanimParameterType.Bool) { bool paramValue = (action.parameterValue > 0f) ? true : false; action.animator.SetBool(action.parameterName, paramValue); } else if (action.mecanimParameterType == MecanimParameterType.Trigger) { if (!isSkipping || action.parameterValue != 1f) { action.animator.SetTrigger(action.parameterName); } } return(0f); } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom && action.animator) { if (action.clip2D != "") { #if UNITY_EDITOR && UNITY_5 int hash = Animator.StringToHash(action.clip2D); if (action.animator.HasState(0, hash)) { action.animator.CrossFade(hash, action.fadeTime, action.layerInt); } else { ACDebug.LogError("Cannot play clip " + action.clip2D + " on " + action.animator.name); } #else try { action.animator.CrossFade(action.clip2D, action.fadeTime, action.layerInt); } catch {} #endif if (action.willWait) { return(action.defaultPauseTime); } } } else if (action.methodMecanim == AnimMethodMecanim.BlendShape && action.shapeKey > -1) { if (action.shapeObject) { action.shapeObject.Change(action.shapeKey, action.shapeValue, action.fadeTime); if (action.willWait) { return(action.fadeTime); } } } } else { if (action.methodMecanim == AnimMethodMecanim.BlendShape && action.shapeObject) { action.isRunning = false; return(0f); } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom) { if (action.animator && action.clip2D != "") { if (action.animator.GetCurrentAnimatorStateInfo(action.layerInt).normalizedTime < 1f) { return(action.defaultPauseTime / 6f); } else { action.isRunning = false; return(0f); } } } } return(0f); }
public override void ActionAnimSkip(ActionAnim action) { if (action.method == AnimMethod.PlayCustom && action._anim && action.clip) { AdvGame.CleanUnusedClips (action._anim); WrapMode wrap = WrapMode.Once; if (action.playMode == AnimPlayMode.PlayOnceAndClamp) { wrap = WrapMode.ClampForever; } else if (action.playMode == AnimPlayMode.Loop) { wrap = WrapMode.Loop; } AdvGame.PlayAnimClipFrame (action._anim, 0, action.clip, action.blendMode, wrap, 0f, null, 1f); } else if (action.method == AnimMethod.StopCustom && action._anim && action.clip) { AdvGame.CleanUnusedClips (action._anim); action._anim.Blend (action.clip.name, 0f, 0f); } else if (action.method == AnimMethod.BlendShape && action.shapeKey > -1) { if (action.shapeObject) { action.shapeObject.Change (action.shapeKey, action.shapeValue, 0f); } } }
public override void ActionAnimAssignValues(ActionAnim action, List <ActionParameter> parameters) { action.runtimeAnim2D = action.AssignFile(parameters, action.parameterID, action.constantID, action._anim2D); }
public virtual void ActionAnimAssignValues(ActionAnim action, List<ActionParameter> parameters) { }
public override string ActionAnimLabel(ActionAnim action) { string label = ""; if (action.animator) { label = action.animator.name; if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue && action.parameterName != "") { label += " - " + action.parameterName; } } return label; }
public override void ActionAnimAssignValues(ActionAnim action, List<ActionParameter> parameters) { action._anim2D = action.AssignFile (parameters, action.parameterID, action.constantID, action._anim2D); }
public override void ActionAnimSkip(ActionAnim action) { if (action.methodMecanim == AnimMethodMecanim.BlendShape) { if (action.shapeObject) { action.shapeObject.Change (action.shapeKey, action.shapeValue, action.fadeTime); } } else { ActionAnimRun (action); } }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.method == AnimMethod.PlayCustom && action.runtimeAnim != null && action.clip != null) { AdvGame.CleanUnusedClips(action.runtimeAnim); WrapMode wrap = WrapMode.Once; if (action.playMode == AnimPlayMode.PlayOnceAndClamp) { wrap = WrapMode.ClampForever; } else if (action.playMode == AnimPlayMode.Loop) { wrap = WrapMode.Loop; } AdvGame.PlayAnimClip(action.runtimeAnim, 0, action.clip, action.blendMode, wrap, action.fadeTime, null, false); } else if (action.method == AnimMethod.StopCustom && action.runtimeAnim && action.clip) { AdvGame.CleanUnusedClips(action.runtimeAnim); action.runtimeAnim.Blend(action.clip.name, 0f, action.fadeTime); } else if (action.method == AnimMethod.BlendShape && action.shapeKey > -1) { if (action.runtimeShapeObject != null) { action.runtimeShapeObject.Change(action.shapeKey, action.shapeValue, action.fadeTime); if (action.willWait) { return(action.fadeTime); } } } if (action.willWait) { return(action.defaultPauseTime); } } else { if (action.method == AnimMethod.PlayCustom && action.runtimeAnim && action.clip) { if (!action.runtimeAnim.IsPlaying(action.clip.name)) { action.isRunning = false; return(0f); } else { return(action.defaultPauseTime); } } else if (action.method == AnimMethod.BlendShape && action.runtimeShapeObject != null) { action.isRunning = false; return(0f); } } return(0f); }
public override string ActionAnimLabel(ActionAnim action) { string label = ""; if (action._anim) { label = action._anim.name; if (action.method == AnimMethod.PlayCustom && action.clip) { label += " - Play " + action.clip.name; } else if (action.method == AnimMethod.StopCustom && action.clip) { label += " - Stop " + action.clip.name; } else if (action.method == AnimMethod.BlendShape) { label += " - Shapekey"; } } return label; }
public override void ActionAnimAssignValues(ActionAnim action, List<ActionParameter> parameters) { action.animator = action.AssignFile <Animator> (parameters, action.parameterID, action.constantID, action.animator); }
public virtual void ActionAnimSkip(ActionAnim action) { ActionAnimRun (action); }
public virtual string ActionAnimLabel(ActionAnim action) { return ""; }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action._anim2D && action.clip2D != "") { if (action.method == AnimMethod.PlayCustom) { if (action.wrapMode2D == ActionAnim.WrapMode2D.Loop) { tk2DIntegration.PlayAnimation (action._anim2D, action.clip2D, true, WrapMode.Loop); } else if (action.wrapMode2D == ActionAnim.WrapMode2D.PingPong) { tk2DIntegration.PlayAnimation (action._anim2D, action.clip2D, true, WrapMode.PingPong); } else { tk2DIntegration.PlayAnimation (action._anim2D, action.clip2D, true, WrapMode.Once); } if (action.willWait) { return (action.defaultPauseTime); } } else if (action.method == AnimMethod.StopCustom) { tk2DIntegration.StopAnimation (action._anim2D); } else if (action.method == AnimMethod.BlendShape) { Debug.LogWarning ("BlendShapes not available for 2D animation."); return 0f; } } } else { if (action._anim2D && action.clip2D != "") { if (!tk2DIntegration.IsAnimationPlaying (action._anim2D, action.clip2D)) { action.isRunning = false; } else { return (Time.deltaTime); } } } return 0f; }
public virtual void ActionAnimGUI(ActionAnim action, List<ActionParameter> parameters) { #if UNITY_EDITOR #endif }
public override float ActionAnimRun(ActionAnim action) { return(ActionAnimProcess(action, false)); }
public override void ActionAnimGUI(ActionAnim action, List<ActionParameter> parameters) { #if UNITY_EDITOR action.methodMecanim = (AnimMethodMecanim) EditorGUILayout.EnumPopup ("Method:", action.methodMecanim); if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue || action.methodMecanim == AnimMethodMecanim.PlayCustom) { action.parameterID = AC.Action.ChooseParameterGUI ("Animator:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.animator = null; } else { action.animator = (Animator) EditorGUILayout.ObjectField ("Animator:", action.animator, typeof (Animator), true); action.constantID = action.FieldToID <Animator> (action.animator, action.constantID); action.animator = action.IDToField <Animator> (action.animator, action.constantID, false); } } if (action.methodMecanim == AnimMethodMecanim.ChangeParameterValue) { action.parameterName = EditorGUILayout.TextField ("Parameter to affect:", action.parameterName); action.mecanimParameterType = (MecanimParameterType) EditorGUILayout.EnumPopup ("Parameter type:", action.mecanimParameterType); if (action.mecanimParameterType != MecanimParameterType.Trigger) { action.parameterValue = EditorGUILayout.FloatField ("Set as value:", action.parameterValue); } } else if (action.methodMecanim == AnimMethodMecanim.PlayCustom) { action.clip2D = EditorGUILayout.TextField ("Clip:", action.clip2D); action.layerInt = EditorGUILayout.IntField ("Mecanim layer:", action.layerInt); action.fadeTime = EditorGUILayout.Slider ("Transition time:", action.fadeTime, 0f, 2f); action.willWait = EditorGUILayout.Toggle ("Wait until finish?", action.willWait); } else if (action.methodMecanim == AnimMethodMecanim.BlendShape) { action.isPlayer = EditorGUILayout.Toggle ("Is player?", action.isPlayer); if (!action.isPlayer) { action.parameterID = AC.Action.ChooseParameterGUI ("Object:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.shapeObject = null; } else { action.shapeObject = (Shapeable) EditorGUILayout.ObjectField ("Object:", action.shapeObject, typeof (Shapeable), true); action.constantID = action.FieldToID <Shapeable> (action.shapeObject, action.constantID); action.shapeObject = action.IDToField <Shapeable> (action.shapeObject, action.constantID, false); } } action.shapeKey = EditorGUILayout.IntField ("Shape key:", action.shapeKey); action.shapeValue = EditorGUILayout.Slider ("Shape value:", action.shapeValue, 0f, 100f); action.fadeTime = EditorGUILayout.Slider ("Transition time:", action.fadeTime, 0f, 2f); action.willWait = EditorGUILayout.Toggle ("Wait until finish?", action.willWait); } if (GUI.changed) { EditorUtility.SetDirty (action); } #endif }
public virtual float ActionAnimRun(ActionAnim action) { return 0f; }
public override void ActionAnimSkip(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action._anim2D && action.clip2D != "") { if (action.method == AnimMethod.PlayCustom) { if (action.wrapMode2D == ActionAnim.WrapMode2D.Loop) { tk2DIntegration.PlayAnimation (action._anim2D, action.clip2D, true, WrapMode.Loop); } else if (action.wrapMode2D == ActionAnim.WrapMode2D.PingPong) { tk2DIntegration.PlayAnimation (action._anim2D, action.clip2D, true, WrapMode.PingPong); } else { tk2DIntegration.PlayAnimation (action._anim2D, action.clip2D, true, WrapMode.Once); } } else if (action.method == AnimMethod.StopCustom) { tk2DIntegration.StopAnimation (action._anim2D); } } } }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.method == AnimMethod.PlayCustom && action._anim && action.clip) { AdvGame.CleanUnusedClips (action._anim); WrapMode wrap = WrapMode.Once; if (action.playMode == AnimPlayMode.PlayOnceAndClamp) { wrap = WrapMode.ClampForever; } else if (action.playMode == AnimPlayMode.Loop) { wrap = WrapMode.Loop; } AdvGame.PlayAnimClip (action._anim, 0, action.clip, action.blendMode, wrap, action.fadeTime, null, false); } else if (action.method == AnimMethod.StopCustom && action._anim && action.clip) { AdvGame.CleanUnusedClips (action._anim); action._anim.Blend (action.clip.name, 0f, action.fadeTime); } else if (action.method == AnimMethod.BlendShape && action.shapeKey > -1) { if (action.shapeObject) { action.shapeObject.Change (action.shapeKey, action.shapeValue, action.fadeTime); if (action.willWait) { return (action.fadeTime); } } } if (action.willWait) { return (action.defaultPauseTime); } } else { if (action.method == AnimMethod.PlayCustom && action._anim && action.clip) { if (!action._anim.IsPlaying (action.clip.name)) { action.isRunning = false; return 0f; } else { return action.defaultPauseTime; } } else if (action.method == AnimMethod.BlendShape && action.shapeObject) { action.isRunning = false; return 0f; } } return 0f; }
public override void ActionAnimGUI(ActionAnim action, List <ActionParameter> parameters) { #if UNITY_EDITOR action.method = (AnimMethod)EditorGUILayout.EnumPopup("Method:", action.method); if (action.method == AnimMethod.PlayCustom || action.method == AnimMethod.StopCustom) { action.parameterID = Action.ChooseParameterGUI("Object:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action._anim = null; } else { action._anim = (Animation)EditorGUILayout.ObjectField("Object:", action._anim, typeof(Animation), true); action.constantID = action.FieldToID <Animation> (action._anim, action.constantID); action._anim = action.IDToField <Animation> (action._anim, action.constantID, false); } action.clip = (AnimationClip)EditorGUILayout.ObjectField("Clip:", action.clip, typeof(AnimationClip), true); if (action.method == AnimMethod.PlayCustom) { action.playMode = (AnimPlayMode)EditorGUILayout.EnumPopup("Play mode:", action.playMode); action.blendMode = (AnimationBlendMode)EditorGUILayout.EnumPopup("Blend mode:", action.blendMode); } action.fadeTime = EditorGUILayout.Slider("Transition time:", action.fadeTime, 0f, 1f); } else if (action.method == AnimMethod.BlendShape) { action.isPlayer = EditorGUILayout.Toggle("Is player?", action.isPlayer); if (!action.isPlayer) { action.parameterID = Action.ChooseParameterGUI("Object:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.shapeObject = null; } else { action.shapeObject = (Shapeable)EditorGUILayout.ObjectField("Object:", action.shapeObject, typeof(Shapeable), true); action.constantID = action.FieldToID <Shapeable> (action.shapeObject, action.constantID); action.shapeObject = action.IDToField <Shapeable> (action.shapeObject, action.constantID, false); } } action.shapeKey = EditorGUILayout.IntField("Shape key:", action.shapeKey); action.shapeValue = EditorGUILayout.Slider("Shape value:", action.shapeValue, 0f, 100f); action.fadeTime = EditorGUILayout.Slider("Transition time:", action.fadeTime, 0f, 2f); } action.willWait = EditorGUILayout.Toggle("Wait until finish?", action.willWait); if (GUI.changed) { EditorUtility.SetDirty(action); } #endif }
public override void ActionAnimGUI(ActionAnim action, List<ActionParameter> parameters) { #if UNITY_EDITOR action.method = (AnimMethod) EditorGUILayout.EnumPopup ("Method:", action.method); if (action.method == AnimMethod.PlayCustom || action.method == AnimMethod.StopCustom) { action.parameterID = Action.ChooseParameterGUI ("Object:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action._anim = null; } else { action._anim = (Animation) EditorGUILayout.ObjectField ("Object:", action._anim, typeof (Animation), true); action.constantID = action.FieldToID <Animation> (action._anim, action.constantID); action._anim = action.IDToField <Animation> (action._anim, action.constantID, false); } action.clip = (AnimationClip) EditorGUILayout.ObjectField ("Clip:", action.clip, typeof (AnimationClip), true); if (action.method == AnimMethod.PlayCustom) { action.playMode = (AnimPlayMode) EditorGUILayout.EnumPopup ("Play mode:", action.playMode); action.blendMode = (AnimationBlendMode) EditorGUILayout.EnumPopup ("Blend mode:",action.blendMode); } action.fadeTime = EditorGUILayout.Slider ("Transition time:", action.fadeTime, 0f, 1f); } else if (action.method == AnimMethod.BlendShape) { action.isPlayer = EditorGUILayout.Toggle ("Is player?", action.isPlayer); if (!action.isPlayer) { action.parameterID = Action.ChooseParameterGUI ("Object:", parameters, action.parameterID, ParameterType.GameObject); if (action.parameterID >= 0) { action.constantID = 0; action.shapeObject = null; } else { action.shapeObject = (Shapeable) EditorGUILayout.ObjectField ("Object:", action.shapeObject, typeof (Shapeable), true); action.constantID = action.FieldToID <Shapeable> (action.shapeObject, action.constantID); action.shapeObject = action.IDToField <Shapeable> (action.shapeObject, action.constantID, false); } } action.shapeKey = EditorGUILayout.IntField ("Shape key:", action.shapeKey); action.shapeValue = EditorGUILayout.Slider ("Shape value:", action.shapeValue, 0f, 100f); action.fadeTime = EditorGUILayout.Slider ("Transition time:", action.fadeTime, 0f, 2f); } action.willWait = EditorGUILayout.Toggle ("Wait until finish?", action.willWait); if (GUI.changed) { EditorUtility.SetDirty (action); } #endif }
public override void ActionAnimAssignValues(ActionAnim action, List <ActionParameter> parameters) { action.runtimeAnim = action.AssignFile <Animation> (parameters, action.parameterID, action.constantID, action._anim); action.runtimeShapeObject = action.AssignFile <Shapeable> (parameters, action.parameterID, action.constantID, action.shapeObject); }
public override float ActionAnimRun(ActionAnim action) { if (!action.isRunning) { action.isRunning = true; if (action.animator && action.clip2D != "") { if (action.method == AnimMethod.PlayCustom) { action.animator.CrossFade (action.clip2D, action.fadeTime, action.layerInt); if (action.willWait) { return (action.defaultPauseTime); } } else if (action.method == AnimMethod.BlendShape) { ACDebug.LogWarning ("BlendShapes not available for 2D animation."); return 0f; } } } else { if (action.animator && action.clip2D != "") { if (action.animator.GetCurrentAnimatorStateInfo (action.layerInt).normalizedTime < 1f) { return (action.defaultPauseTime / 6f); } else { action.isRunning = false; return 0f; } } } return 0f; }
public override void ActionAnimAssignValues(ActionAnim action, List<ActionParameter> parameters) { action._anim = action.AssignFile <Animation> (parameters, action.parameterID, action.constantID, action._anim); action.shapeObject = action.AssignFile <Shapeable> (parameters, action.parameterID, action.constantID, action.shapeObject); }
public override void ActionAnimSkip(ActionAnim action) { if (action.animator && action.clip2D != "") { if (action.method == AnimMethod.PlayCustom) { action.animator.Play (action.clip2D, action.layerInt, 0.8f); } } }