public AddClip ( |
||
clip | ||
newName | string | |
Résultat | void |
private void InitAnimations() { animation = GetComponentInChildren<Animation> (); animation.AddClip (walk, "Walk"); animation.AddClip (aim, "Aim"); animation.AddClip (kick, "Kick"); animation ["Walk"].layer = 0; animation ["Aim"].layer = 1; animation ["Aim"].AddMixingTransform (transform.Find ("player/Armature/root/stomach/upper_arm_L")); animation ["Aim"].AddMixingTransform (transform.Find ("player/Armature/root/stomach/upper_arm_R")); animation ["Kick"].AddMixingTransform (transform.Find ("player/Armature/root/stomach/upper_leg_R")); animation.wrapMode = WrapMode.Loop; }
private float idleSwitchDelay; // A random time to play RandomIdle animation void Start () { monster = GetComponent<Monster>(); animation = monster.monsterGameObject.GetComponent<Animation>(); // Initialize monster animator if(animationClips.idle != null) animation.AddClip(animationClips.idle, "Idle"); if(animationClips.randomIdle != null) { animation.AddClip(animationClips.randomIdle, "RandomIdle"); idleSwitchDelay = (Length("Idle") * UnityEngine.Random.Range(4, 8)) + Time.time; } if(animationClips.moveForward != null) animation.AddClip(animationClips.moveForward, "MoveForward"); if(animationClips.moveBackward != null) animation.AddClip(animationClips.moveBackward, "MoveBackward"); if(animationClips.physicalAttack != null) animation.AddClip(animationClips.physicalAttack, "PhysicalAttack"); if(animationClips.specialAttack != null) animation.AddClip(animationClips.specialAttack, "SpecialAttack"); if(animationClips.takeDamage != null) animation.AddClip(animationClips.takeDamage, "TakeDamage"); if(animationClips.dead != null) animation.AddClip(animationClips.dead, "Dead"); Play("Idle"); }
public override void CreateEffect() { base.CreateEffect(); m_animation = GetComponent<Animation>(); if( m_animation == null) { m_animation = this.gameObject.AddComponent<Animation>(); if(ShowAnim != null) m_animation.AddClip(ShowAnim, "ShowAnim"); if(HideAnim != null) m_animation.AddClip(HideAnim, "HideAnim"); if(IdleAnim != null) m_animation.AddClip(IdleAnim, "IdelAnim"); } }
public void TransferAnimation(Animation target, Transform avatar) { Debug.LogWarning("here"); target.AddClip(clip, clip.name); target[clip.name].layer = animationLayer; //StartCoroutine(MixingTransforms( addMixingTransforms, removeMixingTransforms, clip)); //yield return null; if(addMixingTransforms.Count>0) { for (int i = 0; i < addMixingTransforms.Count; i++) { target[clip.name].AddMixingTransform(GetBone(addMixingTransforms[i], avatar), false); //yield return null; } } if(removeMixingTransforms.Count>0) { for (int i = 0; i < removeMixingTransforms.Count; i++) { target[clip.name].RemoveMixingTransform(GetBone(removeMixingTransforms[i], avatar)); //yield return null; } } }
// Use this for initialization void Start() { animation = GetComponent<Animation>(); animation.AddClip(animationClip, "animationClip"); animation["animationClip"].speed = speed; animation.wrapMode = WrapMode.Loop; }
void Init() { for (int i = 0; i < m_AnimationClip.AnimationClip.Length; i++) { m_Animation.AddClip(m_AnimationClip.AnimationClip[i], m_AnimationClip.AnimationClip[i].name); } }
private AnimationState LoadAnim(AnimGroup group, AnimIndex anim) { if (anim == AnimIndex.None) { return(null); } var animGroup = AnimationGroup.Get(Definition.AnimGroupName, group); var animName = animGroup[anim]; AnimationState state; if (!_loadedAnims.ContainsKey(animName)) { var clip = Importing.Conversion.Animation.Load(animGroup.FileName, animName, _frames); _loadedAnims.Add(animName, clip); _anim.AddClip(clip.Clip, animName); state = _anim[animName]; } else { state = _anim[animName]; } return(state); }
static public int AddClip(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 3) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); self.AddClip(a1, a2); pushValue(l, true); return(1); } else if (argc == 5) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); self.AddClip(a1, a2, a3, a4); pushValue(l, true); return(1); } else if (argc == 6) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); System.Boolean a5; checkType(l, 6, out a5); self.AddClip(a1, a2, a3, a4, a5); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
public void Create(Creature ac) { m_ac = ac; m_ac.OnDead += OnDead; m_ac.OnTakeDamage += OnTakeDamage; m_anim_ctl = ResMgr.Instance.CreateGameObject(string.Format("Creature/{0}/{1}", ac.Proto.Key, ac.Proto.Key), gameObject).GetComponent<Animation>(); m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/FIdle", ac.Proto.Key)) as AnimationClip, "FIdle"); m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/Fight", ac.Proto.Key)) as AnimationClip, "Fight"); m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/Die", ac.Proto.Key)) as AnimationClip, "Die"); m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/Walk", ac.Proto.Key)) as AnimationClip, "Walk"); m_anim_ctl.AddClip(ResMgr.Instance.Load(string.Format("Creature/{0}/BeHit", ac.Proto.Key)) as AnimationClip, "BeHit"); m_anim_ctl["BeHit"].layer = 2; m_prog_hp = ResMgr.Instance.CreateGameObject("UI/PlaneProgHP", Launcher.Instance.CanvasUI.gameObject); m_img_prog_hp = Util.FindGameObjectByName(m_prog_hp, "Fill").GetComponent<Image>(); m_img_prog_hp.fillAmount = 1; Idle(); }
public static AnimationClip SetAnimation(Animation tarAnimation, int tarIndex, AnimationClip srcClip) { int nCount = 0; AnimationClip[] backClip = new AnimationClip[tarAnimation.GetClipCount() - tarIndex + 1]; foreach (AnimationState clip in tarAnimation) { if (tarIndex == nCount) tarAnimation.RemoveClip(clip.clip); if (tarIndex < nCount) { backClip[nCount - tarIndex - 1] = clip.clip; tarAnimation.RemoveClip(clip.clip); } } tarAnimation.AddClip(srcClip, srcClip.name); for (int n = 0; n < backClip.Length; n++) tarAnimation.AddClip(backClip[n], backClip[n].name); return srcClip; }
public static void AddClips(this UnityEngine.Animation anim, UnityEngine.Animation originAnim, params string[] animNames) { AnimationClip clip; foreach (string clipName in animNames) { clip = originAnim.GetClip(clipName); if (clip != null) { anim.AddClip(clip, clipName); } } }
static public int AddClip(IntPtr l) { try{ if (matchType(l, 2, typeof(UnityEngine.AnimationClip), typeof(string))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); self.AddClip(a1, a2); return(0); } else if (matchType(l, 2, typeof(UnityEngine.AnimationClip), typeof(string), typeof(int), typeof(int), typeof(bool))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); System.Boolean a5; checkType(l, 6, out a5); self.AddClip(a1, a2, a3, a4, a5); return(0); } else if (matchType(l, 2, typeof(UnityEngine.AnimationClip), typeof(string), typeof(int), typeof(int))) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); self.AddClip(a1, a2, a3, a4); return(0); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
public IEnumerator TransferAnimation(Animation target, ArmorAnimation anim, Avatar avatar) { target.AddClip(anim.clip, anim.clip.name); target[anim.clip.name].layer = anim.animationLayer; target[anim.clip.name].speed = anim.speed; //StartCoroutine(MixingTransforms( anim.addMixingTransforms, anim.removeMixingTransforms, anim.clip)); yield return new WaitForEndOfFrame(); if(!anim.useWholeBody) { if(anim.useArmLBones) { target[anim.clip.name].AddMixingTransform(avatar.clavicleL, false); target[anim.clip.name].AddMixingTransform(avatar.shoulderL, false); target[anim.clip.name].AddMixingTransform(avatar.shoulderGuardL, false); target[anim.clip.name].AddMixingTransform(avatar.elbowL, false); target[anim.clip.name].AddMixingTransform(avatar.forearmL, false); target[anim.clip.name].AddMixingTransform(avatar.handL, false); } if(anim.useArmRBones) { target[anim.clip.name].AddMixingTransform(avatar.clavicleR, false); target[anim.clip.name].AddMixingTransform(avatar.shoulderR, false); target[anim.clip.name].AddMixingTransform(avatar.shoulderGuardR, false); target[anim.clip.name].AddMixingTransform(avatar.elbowR, false); target[anim.clip.name].AddMixingTransform(avatar.forearmR, false); target[anim.clip.name].AddMixingTransform(avatar.handR, false); } if(anim.useVerticalBones) { target[anim.clip.name].AddMixingTransform(avatar.spine2, false); target[anim.clip.name].AddMixingTransform(avatar.neckHorizontal, false); } } /*if(anim.addMixingTransforms.Count>0) { for (int i = 0; i < anim.addMixingTransforms.Count; i++) { target[anim.clip.name].AddMixingTransform(GetBone(anim.addMixingTransforms[i], avatar), false); } } if(anim.removeMixingTransforms.Count>0) { for (int i = 0; i < anim.removeMixingTransforms.Count; i++) { target[anim.clip.name].RemoveMixingTransform(GetBone(anim.removeMixingTransforms[i], avatar)); } }*/ }
private void PlayAnimation(AnimationClip clip) { graphicRaycaster.enabled = false; if (animator.isPlaying) { animator.Stop(); } animator.RemoveClip(animator.clip); animator.clip = clip; animator.AddClip(clip, clip.name); animator.Play(); Debug.Log("Playing " + clip.name, clip); StopAnimationEndAwaiter(); _animationWaitCoroutine = StartCoroutine(WaitForAnimationEnd(clip)); }
public static int AddClip_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.Animation obj = get_obj(nThisPtr); UnityEngine.AnimationClip arg0 = FCGetObj.GetObj <UnityEngine.AnimationClip>(FCLibHelper.fc_get_wrap_objptr(L, 0)); string arg1 = FCLibHelper.fc_get_string_a(L, 1); obj.AddClip(arg0, arg1); } catch (Exception e) { Debug.LogException(e); } return(0); }
private void AssignAnimations() { UnityEngine.Animation sourceAnimations = _SourceAnimation.Object; if (sourceAnimations == null) { Debug.LogError("Set valid Source Animation"); return; } bool isAllNull = true; for (int i = 0; i < _DestinationsView.Controls.Count; i++) { if (((Skill.Editor.UI.ObjectField <UnityEngine.Animation>)_DestinationsView.Controls[i]).Object != null) { isAllNull = false; break; } } if (isAllNull) { Debug.LogError("Set valid Destination Animation"); return; } for (int i = 0; i < _DestinationsView.Controls.Count; i++) { UnityEngine.Animation anim = ((Skill.Editor.UI.ObjectField <UnityEngine.Animation>)_DestinationsView.Controls[i]).Object; if (anim != null) { foreach (AnimationState state in sourceAnimations) { AnimationState destState = anim[state.name]; if (destState == null) { anim.AddClip(state.clip, state.name); } } EditorUtility.SetDirty(anim); } } Debug.Log("Animations Assigned"); }
static int AddClip(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(UnityEngine.AnimationClip), typeof(string))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); UnityEngine.AnimationClip arg0 = (UnityEngine.AnimationClip)ToLua.ToObject(L, 2); string arg1 = ToLua.ToString(L, 3); obj.AddClip(arg0, arg1); return(0); } else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(UnityEngine.AnimationClip), typeof(string), typeof(int), typeof(int))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); UnityEngine.AnimationClip arg0 = (UnityEngine.AnimationClip)ToLua.ToObject(L, 2); string arg1 = ToLua.ToString(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); obj.AddClip(arg0, arg1, arg2, arg3); return(0); } else if (count == 6 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(UnityEngine.AnimationClip), typeof(string), typeof(int), typeof(int), typeof(bool))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); UnityEngine.AnimationClip arg0 = (UnityEngine.AnimationClip)ToLua.ToObject(L, 2); string arg1 = ToLua.ToString(L, 3); int arg2 = (int)LuaDLL.lua_tonumber(L, 4); int arg3 = (int)LuaDLL.lua_tonumber(L, 5); bool arg4 = LuaDLL.lua_toboolean(L, 6); obj.AddClip(arg0, arg1, arg2, arg3, arg4); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.AddClip")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void PlayAnimation(UnityEngine.AnimationClip animationClip) { if (animationClip == null) { throw new ArgumentNullException("animationClip"); } if (mAnimationComponent[animationClip.name] == null) { mAnimationComponent.AddClip(animationClip, animationClip.name); } if (mAnimationComponent.gameObject.active == true) { mAnimationComponent[animationClip.name].enabled = true; mAnimationComponent[animationClip.name].weight = 1.0f; mAnimationComponent.CrossFade(animationClip.name, 0.3f, PlayMode.StopAll); } }
static int QPYX_AddClip_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 3) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); UnityEngine.AnimationClip QPYX_arg0_YXQP = (UnityEngine.AnimationClip)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.AnimationClip)); string QPYX_arg1_YXQP = ToLua.CheckString(L_YXQP, 3); QPYX_obj_YXQP.AddClip(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } else if (QPYX_count_YXQP == 5) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); UnityEngine.AnimationClip QPYX_arg0_YXQP = (UnityEngine.AnimationClip)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.AnimationClip)); string QPYX_arg1_YXQP = ToLua.CheckString(L_YXQP, 3); int QPYX_arg2_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 4); int QPYX_arg3_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 5); QPYX_obj_YXQP.AddClip(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP); return(0); } else if (QPYX_count_YXQP == 6) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); UnityEngine.AnimationClip QPYX_arg0_YXQP = (UnityEngine.AnimationClip)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.AnimationClip)); string QPYX_arg1_YXQP = ToLua.CheckString(L_YXQP, 3); int QPYX_arg2_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 4); int QPYX_arg3_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 5); bool QPYX_arg4_YXQP = LuaDLL.luaL_checkboolean(L_YXQP, 6); QPYX_obj_YXQP.AddClip(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP, QPYX_arg3_YXQP, QPYX_arg4_YXQP); return(0); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Animation.AddClip")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static public int AddClip__AnimationClip__String__Int32__Int32(IntPtr l) { try { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); self.AddClip(a1, a2, a3, a4); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public static int AddClip1_wrap(long L) { try { long VM = FCLibHelper.fc_get_vm_ptr(L); long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.Animation obj = get_obj(nThisPtr); UnityEngine.AnimationClip arg0 = FCGetObj.GetObj <UnityEngine.AnimationClip>(FCLibHelper.fc_get_wrap_objptr(L, 0)); string arg1 = FCLibHelper.fc_get_string_a(L, 1); int arg2 = FCLibHelper.fc_get_int(L, 2); int arg3 = FCLibHelper.fc_get_int(L, 3); bool arg4 = FCLibHelper.fc_get_bool(L, 4); obj.AddClip(arg0, arg1, arg2, arg3, arg4); } catch (Exception e) { Debug.LogException(e); } return(0); }
public IEnumerator TransferAnimation(Animation target, ArmorAnimation anim, Transform avatar) { target.AddClip(anim.clip, anim.clip.name); target[anim.clip.name].layer = anim.animationLayer; //StartCoroutine(MixingTransforms( anim.addMixingTransforms, anim.removeMixingTransforms, anim.clip)); yield return null; if(anim.addMixingTransforms.Count>0) { for (int i = 0; i < anim.addMixingTransforms.Count; i++) { target[anim.clip.name].AddMixingTransform(GetBone(anim.addMixingTransforms[i], avatar), false); } } if(anim.removeMixingTransforms.Count>0) { for (int i = 0; i < anim.removeMixingTransforms.Count; i++) { target[anim.clip.name].RemoveMixingTransform(GetBone(anim.removeMixingTransforms[i], avatar)); } } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ static bool CopyAnimation ( Animation _src, Animation _dest ) { foreach ( AnimationState state in _src ) { _dest.AddClip(_src[state.name].clip, state.name); } _dest.clip=_src.clip; _dest.playAutomatically = _src.playAutomatically; _dest.animatePhysics = _src.animatePhysics; _dest.animateOnlyIfVisible = _src.animateOnlyIfVisible; return true; }
private static void AddAnimClip(Animation _animation, int layer, AnimationClip clip, AnimationBlendMode blendMode, WrapMode wrapMode, Transform mixingBone) { if (clip != null) { // Initialises a clip _animation.AddClip (clip, clip.name); if (mixingBone != null) { _animation [clip.name].AddMixingTransform (mixingBone); } // Set up the state _animation [clip.name].layer = layer; _animation [clip.name].normalizedTime = 0f; _animation [clip.name].blendMode = blendMode; _animation [clip.name].wrapMode = wrapMode; _animation [clip.name].enabled = true; } }
void StarEffectAnim(Animation anim, GameObject tmp) { //Debug.Break(); anim.enabled = true; AnimationClip animclip = new AnimationClip(); #if UNITY_5 animclip.legacy = true; #endif AnimationCurve curveScalex = AnimationCurve.Linear(0, tmp.transform.localScale.x, 1, 3); //AnimationCurve curveScaley = AnimationCurve.Linear(0, tmp.transform.localScale.y, 1, 3); AnimationCurve curvex = AnimationCurve.Linear(0, tmp.transform.position.x, 1, 0); AnimationCurve curvey = AnimationCurve.Linear(0, tmp.transform.position.y, 1, 0); AnimationCurve curvez = AnimationCurve.Linear(0, tmp.transform.position.z, 1, tmp.transform.position.z); AnimationCurve curveColora = AnimationCurve.Linear(0, 1, 1, 0); animclip.SetCurve("", typeof(Transform), "m_LocalScale.x", curveScalex); animclip.SetCurve("", typeof(Transform), "m_LocalScale.y", curveScalex); animclip.SetCurve("", typeof(Transform), "localPosition.x", curvex); animclip.SetCurve("", typeof(Transform), "localPosition.y", curvey); animclip.SetCurve("", typeof(Transform), "localPosition.z", curvez); animclip.SetCurve(tmp.transform.GetChild(0).name, typeof(SpriteRenderer), "m_Color.a", curveColora); // animclip.SetCurve("", typeof(Animation), "m_Enabled", curvenable); anim.wrapMode = WrapMode.Once; anim.AddClip(animclip, "Startwin"); anim.Play("Startwin"); }
public static bool AddClipToAnimationComponent(Animation animation, AnimationClip newClip) { SetClipAsLegacy(newClip); animation.AddClip(newClip, newClip.name); return true; }
public static int metcrossfadetransitionanimation(Transform varpcharacter, string varpdestinationanimname, float varptransitiontime, Transform varpcontroller = null, string varpstateanimationname = "", bool varpgokinematic = true, string varpnewanimname = "transition", Animation varpanimationsystem = null, SkinnedMeshRenderer varprenderer = null, clsurganimationstatesmanager varpstatesmanager = null) { if (varpcharacter == null) { return -1; } if (varptransitiontime == 0f) { return -2; } if (varpanimationsystem == null) { varpanimationsystem = varpcharacter.root.GetComponentInChildren<Animation>(); if (varpanimationsystem == null) { return -3; } varpanimationsystem.Stop(); } if (varprenderer == null) { varprenderer = varpcharacter.root.GetComponentInChildren<SkinnedMeshRenderer>(); if (varprenderer == null) { return -4; } } if (varpgokinematic) { clsurgutils.metgodriven(varpcharacter, true); } Vector3 localPosition = default(Vector3); if (varpcontroller != null) { Vector3 position = varpcharacter.position; varpcontroller.position = position; varpcharacter.localPosition = localPosition; } AnimationClip animationClip = clsurgutils.metcreatetransitionanimation(varpcharacter, varpdestinationanimname, varptransitiontime, varpnewanimname, ref localPosition, varpstatesmanager, false); if (animationClip != null) { varpanimationsystem.Stop(); AnimationState animationState = varpanimationsystem[varpdestinationanimname]; if (animationState != null && animationState.name != varpdestinationanimname) { varpanimationsystem.RemoveClip(varpnewanimname); } varpanimationsystem.AddClip(animationClip, varpnewanimname); if (varpstateanimationname != string.Empty) { varpanimationsystem[varpnewanimname].wrapMode = WrapMode.Once; varpanimationsystem.CrossFade(varpnewanimname); varpanimationsystem.CrossFadeQueued(varpstateanimationname); } else { varpanimationsystem.CrossFade(varpnewanimname); } return 1; } Debug.LogError("Could not create transition"); return -5; }
// Use this for initialization void Start() { anim = (Animation)GetComponent("Animation"); anim.AddClip(clip,"main"); }
static public int AddClip(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (argc == 3) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); self.AddClip(a1, a2); pushValue(l, true); return(1); } else if (argc == 5) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); self.AddClip(a1, a2, a3, a4); pushValue(l, true); return(1); } else if (argc == 6) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); UnityEngine.AnimationClip a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); System.Boolean a5; checkType(l, 6, out a5); self.AddClip(a1, a2, a3, a4, a5); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function AddClip to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
void Start() { m_controller = this.GetComponentInChildren<CharacterController>(); m_curState = AnimStates.Idle; m_animComponent = this.gameObject.GetComponentInChildren<Animation>(); m_isDead = false; m_isSitting = false; for (int i = 0; i < (int)AnimationType.DEFAULT; i++) { m_animComponent.AddClip(characterAnimations[i], ((AnimationType)i).ToString()); } m_animComponent.Play(characterAnimations[(int)AnimationType.Idle].name); m_animComponent.wrapMode = WrapMode.Loop; m_attackType = AnimAttackType.None; m_turnDir = TurningType.None; }
protected void Initialize(Animation animation, Transform transform, string newName = null) { if (clip == null) { Debug.LogError ("clip is null. Cannot initialize animation " + (name == null ? "NULL" : name)); return; } animation.RemoveClip (Name); if (newName != null) name = newName; animation.AddClip (clip, Name); animation [Name].layer = Layer; foreach(var mt in MixingTransforms) { if (AnimationNames.ContainsKey(mt) && transform.Find (AnimationNames [mt]) != null && transform != null) animation [Name].AddMixingTransform (transform.Find (AnimationNames [mt])); else Debug.LogError ("[assembly: " + Assembly.GetExecutingAssembly ().GetName().Name + "]: animation mixing transform " + mt + " from animation " + Name + " does not exist, or could not be found."); } }
void InitTextObject() { _textObject = new GameObject(_textObjectName); _textObject.transform.parent = transform; //Get layers int = 4 bytes = 32 bits _textObject.layer = _guiLayer.value / 32; _textObject.transform.localRotation = RotateText; _textAnimation = _textObject.AddComponent<Animation>(); _textAnimation.playAutomatically = true; _textAnimation.AddClip(_guiAnimation, _guiAnimation.name); _textMesh = _textObject.AddComponent<TextMesh>(); _textMesh.font = _textFont; _textMesh.renderer.material = _textFont.material; _textMesh.characterSize = 0.1f; _textMesh.fontSize = _fontSize; _textMesh.anchor = TextAnchor.MiddleCenter; _textMesh.alignment = TextAlignment.Center; _textMesh.color = TextColor; MaxFontSize = FontSize + MAX_FONT_SIZE_INDEX; DefaultFontSize = FontSize; if (!string.IsNullOrEmpty(ValueText)) _textMesh.text = ValueText; if (Value != -1) _textMesh.text += Value; }
public override void CreateEffect() { if (bTweenPos) { float fromToValX = to.x - from.x; float fromToValY = to.y - from.y; Vector3 fromPos = new Vector3(transform.localPosition.x - fromToValX, transform.localPosition.y - fromToValY, transform.localPosition.z); Vector3 toPos = transform.localPosition; //������Ҫ����Ч if (mTweenPos == null) { mTweenPos = TweenPosition.Begin(transform.gameObject, duration, toPos); } mTweenPos.from = fromPos; mTweenPos.to = toPos; mTweenPos.duration = duration; mTweenList.Add(mTweenPos); } if (bTweenScale) { Vector3 localScale = transform.localScale; //������Ҫ����Ч if (mTweenScale == null) { mTweenScale = TweenScale.Begin(transform.gameObject, duration, endScale); } mTweenScale.value = new Vector3(localScale.x * startScale.x, localScale.y * startScale.y, localScale.z * startScale.z); mTweenScale.from = mTweenScale.value; mTweenScale.to = new Vector3(localScale.x * endScale.x, localScale.y * endScale.y, localScale.z * endScale.z); mTweenScale.duration = duration; mTweenList.Add(mTweenScale); } if (bTweenAlpha) { if (GetComponent<UIPanel>() != null) //��Ϊ UIPanel, ���AlphaTween���Լ� { AddEffectTo(gameObject); } else // ����,���AlphaTween�������Կؼ� { List<UIWidget> list = new List<UIWidget>(); UIToolkits.FindComponents<UIWidget>(transform, list); foreach (UIWidget widget in list) { AddEffectTo(widget.gameObject); } } } if(IdleAnim != null) { m_animation = GetComponent<Animation>(); if( m_animation == null) { m_animation = this.gameObject.AddComponent<Animation>(); if(IdleAnim != null) m_animation.AddClip(IdleAnim, "IdelAnim"); } } }
private void ExportMeshAnimation() { AnimationClip[] animationClips = exportParams.AnimationClips; string[] animationClipNames = exportParams.AnimationNames; GameObject instanceObj = Instantiate(fbx) as GameObject; UnityEngine.Animation animation = instanceObj.GetComponentInChildren <UnityEngine.Animation>(); SkinnedMeshRenderer[] skinnedMeshRenders = instanceObj.GetComponentsInChildren <SkinnedMeshRenderer>(); int subMeshLength = skinnedMeshRenders.Length; Mesh[] subMeshArr = new Mesh[subMeshLength]; for (int i = 0; i < subMeshLength; i++) { subMeshArr[i] = skinnedMeshRenders[i].sharedMesh; } float interval = 1.0f / exportParams.FrameRate; if (File.Exists(exportParams.OutputFilePath)) { File.Delete(exportParams.OutputFilePath); } ExportMeshAnimationData meshAnimationData = ScriptableObject.CreateInstance <ExportMeshAnimationData>(); meshAnimationData.GenerateNormal = exportParams.GenerateNormal; meshAnimationData.SubMeshLength = subMeshLength; meshAnimationData.Fps = exportParams.FrameRate; meshAnimationData.SubMeshData = new ExportMeshAnimationData.AnimationSubMeshData[subMeshLength]; for (int i = 0; i < subMeshLength; i++) { meshAnimationData.SubMeshData[i].ClipDatas = new ExportMeshAnimationData.AnimationClipData[animationClips.Length]; meshAnimationData.SubMeshData[i].FrameRate = exportParams.FrameRate; for (int j = 0; j < animationClips.Length; j++) { AnimationClip clip = animationClips[j]; if (clip == null) { return; } animation.AddClip(clip, animationClipNames[j]); animation.clip = clip; AnimationState state = animation[animationClipNames[j]]; state.enabled = true; state.weight = 1; List <float> frameTimes = GetFrameTimes(clip.length, interval); meshAnimationData.SubMeshData[i].ClipDatas[j].FrameDatas = new ExportMeshAnimationData.AnimationFrameData[frameTimes.Count]; meshAnimationData.SubMeshData[i].ClipDatas[j].ClipName = animationClipNames[j]; for (int k = 0; k < frameTimes.Count; k++) { state.time = frameTimes[k]; animation.Play(); animation.Sample(); Matrix4x4 matrix4X4 = skinnedMeshRenders[i].transform.localToWorldMatrix; Mesh backMesh = BakeFrameAfterMatrixTransform(skinnedMeshRenders[i], matrix4X4); meshAnimationData.SubMeshData[i].ClipDatas[j].FrameDatas[k].Vertexs = backMesh.vertices; backMesh.Clear(); DestroyImmediate(backMesh); animation.Stop(); } } meshAnimationData.SubMeshData[i].UVs = subMeshArr[i].uv; meshAnimationData.SubMeshData[i].Triangles = subMeshArr[i].triangles; } AssetDatabase.CreateAsset(meshAnimationData, GetAssetPath(exportParams.OutputFilePath) + fbx.name + ".asset"); AssetDatabase.Refresh(); }
/// <summary> /// Unity start hook. /// </summary> void Start() { // Get character reference myCharacter = gameObject.GetComponentInParent<Character>(); if (myCharacter == null) Debug.LogError ("Legacy Animation Bridge unable to find Character or Enemy reference"); myCharacter.ChangeAnimationState += AnimationStateChanged; myAnimator = GetComponentInChildren<Animation>(); if (myAnimator == null) Debug.LogError ("Legacy Animation Bridge unable to find Unity Animation reference"); queuedStates = new Queue<AnimationState> (); queuedPriorities = new Queue<int> (); state = AnimationState.NONE; priority = -1; animationLookup = new Dictionary<AnimationState, LegacyAnimation>(); foreach (LegacyAnimation a in animationData) { // Populate dictionary animationLookup.Add (a.state, a); // And add all clips myAnimator.AddClip(a.clip, a.state.AsString()); // Set wrap mode a.clip.wrapMode = a.wrapMode; } }
void Start() { avatarCtrl = GetComponent<AvatarController>(); animCtrl = GetComponent<Animation>(); loadingCtrl = GetComponent<AvatarLoadingController>(); //Setup the basic male and female idle animations if (BasicIdleMale == null) { this.enabled = false; Debug.LogError("BasicIdleMale anim is not set"); return; } if (BasicIdleFemale == null) { this.enabled = false; Debug.LogError("BasicIdleFemale anim is not set"); return; } // Add male animations to the animation component and setup animCtrl.AddClip(BasicIdleMale, BasicIdleMale.name); animCtrl[BasicIdleMale.name].layer = 0; animCtrl[BasicIdleMale.name].speed = 1 + Random.Range(-BasicIdleSpeadSpread, BasicIdleSpeadSpread); animCtrl[BasicIdleMale.name].wrapMode = WrapMode.Loop; //Add female aniations to the animation component and setup. animCtrl.AddClip(BasicIdleFemale, BasicIdleFemale.name); animCtrl[BasicIdleFemale.name].layer = 0; animCtrl[BasicIdleFemale.name].speed = 1 + Random.Range(-BasicIdleSpeadSpread, BasicIdleSpeadSpread); animCtrl[BasicIdleFemale.name].wrapMode = WrapMode.Loop; //Create a list of all animations, add them to the animation component and setup variables List<AnimationMixingSettings> allIdles = new List<AnimationMixingSettings>(GenericIdles.Length + MaleIdles.Length + FemaleIdles.Length); allIdles.AddRange(GenericIdles); allIdles.AddRange(FemaleIdles); allIdles.AddRange(MaleIdles); foreach (AnimationMixingSettings animMix in allIdles) { if (animMix != null && animMix.Clip != null) { animCtrl.AddClip(animMix.Clip, animMix.Clip.name); AnimationState state = animCtrl[animMix.Clip.name]; state.layer = 1; state.wrapMode = WrapMode.Once; if (animMix.MixingTransform) { state.AddMixingTransform(animMix.MixingTransform); } if (animMix.Additive) { state.blendMode = AnimationBlendMode.Additive; } } } // setup animations for the current gender LoadAnims(currentGender); StartCoroutine(IdleAnims()); }
public void TransferAnimations(Animation target, CharacterMotor newcontroller) { rootAnimationTarget = target; controller = newcontroller; if(PreAttackClip != null) { rootAnimationTarget.AddClip(PreAttackClip, PreAttackClip.name); rootAnimationTarget[PreAttackClip.name].layer = attackAnimationLayer; StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, PreAttackClip )); } if(AttackClip != null) { rootAnimationTarget.AddClip(AttackClip, AttackClip.name); rootAnimationTarget[AttackClip.name].layer = attackAnimationLayer; StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, AttackClip )); } if(PostAttackClip != null) { rootAnimationTarget.AddClip(PostAttackClip, PostAttackClip.name); rootAnimationTarget[PostAttackClip.name].layer = attackAnimationLayer; StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, PostAttackClip )); } if(RecoilClip != null) { rootAnimationTarget.AddClip(RecoilClip, RecoilClip.name); rootAnimationTarget[RecoilClip.name].layer = attackAnimationLayer; StartCoroutine(MixingTransforms( AttackAnimationMixingTransforms, AttackAnimationRemoveTransforms, RecoilClip )); } if(hasIdleAnimationOverride) { rootAnimationTarget.AddClip(IdleOverrideAnimationClip, IdleOverrideAnimationClip.name); rootAnimationTarget[IdleOverrideAnimationClip.name].layer = idleAnimationLayer; StartCoroutine(MixingTransforms( IdleAnimationMixingTransformNames, IdleAnimationRemoveTransformNames, IdleOverrideAnimationClip )); } if(hasRunningOverride) { rootAnimationTarget.AddClip(RunningOverrideAnimationClip, RunningOverrideAnimationClip.name); rootAnimationTarget[RunningOverrideAnimationClip.name].layer = idleAnimationLayer; StartCoroutine(MixingTransforms( RunningAnimationMixingTransforms, RunningAnimationRemoveTransforms, RunningOverrideAnimationClip )); } }