Interface to control AnimatorOverrideController.
static public int ApplyOverrides(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 UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <UnityEngine.AnimationClip, UnityEngine.AnimationClip> > a1; checkType(l, 2, out a1); self.ApplyOverrides(a1); pushValue(l, true); return(1); } 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 }
internal static void OnInvalidateOverrideController(AnimatorOverrideController controller) { if (controller.OnOverrideControllerDirty != null) { controller.OnOverrideControllerDirty(); } }
/// <summary> /// Write the specified value using the writer. /// </summary> /// <param name="value">Value.</param> /// <param name="writer">Writer.</param> public override void Write(object value, ISaveGameWriter writer) { UnityEngine.AnimatorOverrideController animatorOverrideController = (UnityEngine.AnimatorOverrideController)value; writer.WriteProperty("runtimeAnimatorController", animatorOverrideController.runtimeAnimatorController); writer.WriteProperty("name", animatorOverrideController.name); writer.WriteProperty("hideFlags", animatorOverrideController.hideFlags); }
static public int constructor(IntPtr l) { UnityEngine.AnimatorOverrideController o; o = new UnityEngine.AnimatorOverrideController(); pushObject(l, o); return(1); }
/// <summary> /// Read the data into the specified value. /// </summary> /// <param name="value">Value.</param> /// <param name="reader">Reader.</param> public override void ReadInto(object value, ISaveGameReader reader) { UnityEngine.AnimatorOverrideController animatorOverrideController = (UnityEngine.AnimatorOverrideController)value; foreach (string property in reader.Properties) { switch (property) { case "runtimeAnimatorController": if (animatorOverrideController.runtimeAnimatorController == null) { animatorOverrideController.runtimeAnimatorController = reader.ReadProperty <UnityEngine.RuntimeAnimatorController> (); } else { reader.ReadIntoProperty <UnityEngine.RuntimeAnimatorController> (animatorOverrideController.runtimeAnimatorController); } break; case "name": animatorOverrideController.name = reader.ReadProperty <System.String> (); break; case "hideFlags": animatorOverrideController.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> (); break; } } }
public static void Play(this Animator animator, AnimationClip clip, float normalizedTime=0f) { AnimatorOverrideController animatorOverrideController; AnimationClip clipOverride = null; if (animator.runtimeAnimatorController is AnimatorOverrideController) { //animator.runtimeAnimatorController is already overrided just take reference animatorOverrideController = animator.runtimeAnimatorController as AnimatorOverrideController; clipOverride = animatorOverrideController.clips [0].originalClip; } else { //AS RuntimeAnimatorController can't be created at runtime RuntimeAnimatorController dummyController = AnimatorUtilityEx.DUMMY_CONTROLLER; clipOverride = dummyController.animationClips [0]; animatorOverrideController = new AnimatorOverrideController (); //bind all clips from animator.runtimeAnimatorController to overrider animatorOverrideController.runtimeAnimatorController = dummyController; } animatorOverrideController [clipOverride] = clip; //to avoid nesting if (animator.runtimeAnimatorController is AnimatorOverrideController) { animator.runtimeAnimatorController = animatorOverrideController.runtimeAnimatorController; } //rebind back animator.runtimeAnimatorController = animatorOverrideController; animator.Play ("Override", 0, normalizedTime); }
void Awake(){ if(type==_AniType.None) return; unitCreep=gameObject.GetComponent<UnitCreep>(); if(type==_AniType.Legacy){ aniInstance=aniRootObj.GetComponent<Animation>(); if(aniInstance!=null){ InitAnimation(); unitCreep.SetAnimationComponent(this); } } if(type==_AniType.Mecanim){ if(anim==null) anim=aniRootObj.GetComponent<Animator>(); if(anim!=null) unitCreep.SetAnimationComponent(this); AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = anim.runtimeAnimatorController; //overrideController["Assigned Animation Clip Name In The Controller"] = New Clip To Be Assigned; //overrideController["DummySpawn"] = clipSpawn!=null ? clipSpawn : null; overrideController["DummyMove"] = clipMove!=null ? clipMove : null; overrideController["DummyDestination"] = clipDestination!=null ? clipDestination : null; overrideController["DummyDestroyed"] = clipDead!=null ? clipDead : null; //if no spawn animation has been assigned, use move animation instead otherwise there will be an delay, bug maybe? AnimationClip spawn = clipSpawn!=null ? clipSpawn : clipMove; overrideController["DummySpawn"] = spawn!=null ? spawn : null; anim.runtimeAnimatorController = overrideController; } }
void Awake() { Unit unit=gameObject.GetComponent<Unit>(); unit.SetUnitAnimation(this); AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = animator.runtimeAnimatorController; overrideController["TDSDummyIdle"] = clipIdle; overrideController["TDSDummyMoveForward"] = clipForward; overrideController["TDSDummyMoveBackward"] = clipBackward; overrideController["TDSDummyMoveStrafeLeft"] = clipStrafeLeft; overrideController["TDSDummyMoveStrafeRight"] = clipStrafeRight; overrideController["TDSDummyAttackRange"] = clipAttackRange; overrideController["TDSDummyAttackMelee"] = clipAttackMelee; overrideController["TDSDummyHit"] = clipHit; overrideController["TDSDummyDestroy"] = clipDestroyed; animator.runtimeAnimatorController = overrideController; //AnimatorStateInfo stateInfo=animator.GetCurrentAnimatorStateInfo(0); //stateInfo.speed=unit.moveSpeed*moveSpeedMultiplier; }
static public int getItem(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); LuaTypes t = LuaDLL.lua_type(l, 2); if (matchType(l, 2, t, typeof(System.String))) { string v; checkType(l, 2, out v); var ret = self[v]; pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, 2, t, typeof(UnityEngine.AnimationClip))) { UnityEngine.AnimationClip v; checkType(l, 2, out v); var ret = self[v]; pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static int get_Item(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes <UnityEngine.AnimationClip>(L, 2)) { UnityEngine.AnimatorOverrideController obj = (UnityEngine.AnimatorOverrideController)ToLua.CheckObject <UnityEngine.AnimatorOverrideController>(L, 1); UnityEngine.AnimationClip arg0 = (UnityEngine.AnimationClip)ToLua.ToObject(L, 2); UnityEngine.AnimationClip o = obj[arg0]; ToLua.PushSealed(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2)) { UnityEngine.AnimatorOverrideController obj = (UnityEngine.AnimatorOverrideController)ToLua.CheckObject <UnityEngine.AnimatorOverrideController>(L, 1); string arg0 = ToLua.ToString(L, 2); UnityEngine.AnimationClip o = obj[arg0]; ToLua.PushSealed(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.AnimatorOverrideController.get_Item")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int _set_this(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes <UnityEngine.AnimationClip, UnityEngine.AnimationClip>(L, 2)) { UnityEngine.AnimatorOverrideController obj = (UnityEngine.AnimatorOverrideController)ToLua.CheckObject <UnityEngine.AnimatorOverrideController>(L, 1); UnityEngine.AnimationClip arg0 = (UnityEngine.AnimationClip)ToLua.ToObject(L, 2); UnityEngine.AnimationClip arg1 = (UnityEngine.AnimationClip)ToLua.ToObject(L, 3); obj[arg0] = arg1; return(0); } else if (count == 3 && TypeChecker.CheckTypes <string, UnityEngine.AnimationClip>(L, 2)) { UnityEngine.AnimatorOverrideController obj = (UnityEngine.AnimatorOverrideController)ToLua.CheckObject <UnityEngine.AnimatorOverrideController>(L, 1); string arg0 = ToLua.ToString(L, 2); UnityEngine.AnimationClip arg1 = (UnityEngine.AnimationClip)ToLua.ToObject(L, 3); obj[arg0] = arg1; return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to operator method: UnityEngine.AnimatorOverrideController.this")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static void AnimatorOverrideController_clips(JSVCall vc) { if (vc.bGet) { UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj; var result = _this.clips; var arrRet = result; for (int i = 0; arrRet != null && i < arrRet.Length; i++) { JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]); JSApi.moveSaveID2Arr(i); } JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true); } else { UnityEngine.AnimationClipPair[] arg0 = JSDataExchangeMgr.GetJSArg <UnityEngine.AnimationClipPair[]>(() => { int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg); int length = JSApi.getArrayLength(jsObjID); var ret = new UnityEngine.AnimationClipPair[length]; for (var i = 0; i < length; i++) { JSApi.getElement(jsObjID, i); ret[i] = (UnityEngine.AnimationClipPair)JSMgr.datax.getObject((int)JSApi.GetType.SaveAndRemove); } return(ret); }); UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj; _this.clips = arg0; } }
static public int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); UnityEngine.AnimatorOverrideController o; if (argc == 2) { UnityEngine.RuntimeAnimatorController a1; checkType(l, 2, out a1); o = new UnityEngine.AnimatorOverrideController(a1); pushValue(l, true); pushValue(l, o); return(2); } else if (argc == 1) { o = new UnityEngine.AnimatorOverrideController(); pushValue(l, true); pushValue(l, o); return(2); } return(error(l, "New object failed.")); } catch (Exception e) { return(error(l, e)); } }
static public int get_overridesCount(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 UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); pushValue(l, true); pushValue(l, self.overridesCount); 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 }
static public int setItem(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); LuaTypes t = LuaDLL.lua_type(l, 2); if (matchType(l, 2, t, typeof(System.String))) { string v; checkType(l, 2, out v); UnityEngine.AnimationClip c; checkType(l, 3, out c); self[v] = c; return(0); } else if (matchType(l, 2, t, typeof(UnityEngine.AnimationClip))) { UnityEngine.AnimationClip v; checkType(l, 2, out v); UnityEngine.AnimationClip c; checkType(l, 3, out c); self[v] = c; 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); } }
static int _CreateUnityEngine_AnimatorOverrideController(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { UnityEngine.AnimatorOverrideController obj = new UnityEngine.AnimatorOverrideController(); ToLua.Push(L, obj); return(1); } else if (count == 1) { UnityEngine.RuntimeAnimatorController arg0 = (UnityEngine.RuntimeAnimatorController)ToLua.CheckObject <UnityEngine.RuntimeAnimatorController>(L, 1); UnityEngine.AnimatorOverrideController obj = new UnityEngine.AnimatorOverrideController(arg0); ToLua.Push(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.AnimatorOverrideController.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int set_clips(IntPtr l) { UnityEngine.AnimatorOverrideController o = (UnityEngine.AnimatorOverrideController)checkSelf(l); UnityEngine.AnimationClipPair[] v; checkType(l, 2, out v); o.clips = v; return(0); }
static public int set_runtimeAnimatorController(IntPtr l) { UnityEngine.AnimatorOverrideController o = (UnityEngine.AnimatorOverrideController)checkSelf(l); UnityEngine.RuntimeAnimatorController v; checkType(l, 2, out v); o.runtimeAnimatorController = v; return(0); }
// Use this for initialization void Start() { Player = GameObject.Find ("Player"); //rigid = gameObject.AddComponent<Rigidbody>(); rigid = GetComponent<Rigidbody> (); anim = GetComponent<Animator> (); AoC = new AnimatorOverrideController (); }
public void changeAnimClip(Animator_Clip_Pair anim, AnimationClip newClip) { AnimatorOverrideController ov_ctrl = new AnimatorOverrideController (); ov_ctrl.runtimeAnimatorController = anim.animator.runtimeAnimatorController; ov_ctrl [anim.getClip()] = newClip; anim.setClip (newClip); anim.animator.runtimeAnimatorController = ov_ctrl; }
public void setNewAnimation(int index, AnimationClip value, AnimatorOverrideController newaoc) { //newaoc = GameObject.Instantiate<AnimatorOverrideController>(newaoc); //Debug.logger.Log(newaoc.clips.Length); newaoc[newaoc.clips[index].originalClip.name] = value == null? newaoc.clips[index].originalClip :value; //GameObject.Destroy(Animator.runtimeAnimatorController); Animator.runtimeAnimatorController = newaoc as RuntimeAnimatorController; //Debug.logger.Log(AOC[AOC.clips[index].originalClip.name]); }
void Start() { AnimatorOverrideController ov_ctrl = new AnimatorOverrideController (); ov_ctrl.runtimeAnimatorController = anim_head.runtimeAnimatorController; ov_ctrl ["clip3"] = anim_clip2; anim_head.runtimeAnimatorController = ov_ctrl; }
static public int get_overridesCount(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); pushValue(l, self.overridesCount); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_clips(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); pushValue(l, true); pushValue(l, self.clips); return(2); } catch (Exception e) { return(error(l, e)); } }
public void Init(Animator animator) { AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = animator.runtimeAnimatorController; foreach(AnimationOverride anim in Overrides) { overrideController[anim.StateName] = anim.OverrideState; } animator.runtimeAnimatorController = overrideController; }
static public int constructor(IntPtr l) { try { UnityEngine.AnimatorOverrideController o; o=new UnityEngine.AnimatorOverrideController(); pushValue(l,true); pushValue(l,o); return 2; } catch(Exception e) { return error(l,e); } }
static public int get_clips(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); pushValue(l, self.clips); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int constructor(IntPtr l) { try { UnityEngine.AnimatorOverrideController o; o = new UnityEngine.AnimatorOverrideController(); pushValue(l, o); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int ApplyOverrides(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <UnityEngine.AnimationClip, UnityEngine.AnimationClip> > a1; checkType(l, 2, out a1); self.ApplyOverrides(a1); return(0); } catch (Exception e) { return(error(l, e)); } }
void Start () { myAudio = GetComponent<AudioSource>(); playerCollider = GetComponent<Collider> (); ragdollBodies = ragdollparent.GetComponentsInChildren<Rigidbody> (); ragdollColliders = ragdollparent.GetComponentsInChildren<Collider> (); overrideController = new AnimatorOverrideController (); overrideController.runtimeAnimatorController = anim.runtimeAnimatorController; DisableRagdoll (); }
static public int set_runtimeAnimatorController(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); UnityEngine.RuntimeAnimatorController v; checkType(l, 2, out v); self.runtimeAnimatorController = v; return(0); } catch (Exception e) { return(error(l, e)); } }
public static int constructor(IntPtr l) { try { UnityEngine.AnimatorOverrideController o; o=new UnityEngine.AnimatorOverrideController(); pushValue(l,o); return 1; } catch(Exception e) { LuaDLL.luaL_error(l, e.ToString()); return 0; } }
static public int constructor(IntPtr l) { try { UnityEngine.AnimatorOverrideController o; o = new UnityEngine.AnimatorOverrideController(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { LuaDLL.lua_remove(l, 1); UnityEngine.AnimatorOverrideController o; if (matchType(l, 1)) { o = new UnityEngine.AnimatorOverrideController(); pushObject(l, o); return(1); } LuaDLL.luaL_error(l, "New object failed."); return(0); }
static public int setItem(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 UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); LuaTypes t = LuaDLL.lua_type(l, 2); if (matchType(l, 2, t, typeof(System.String))) { string v; checkType(l, 2, out v); UnityEngine.AnimationClip c; checkType(l, 3, out c); self[v] = c; pushValue(l, true); return(1); } else if (matchType(l, 2, t, typeof(UnityEngine.AnimationClip))) { UnityEngine.AnimationClip v; checkType(l, 2, out v); UnityEngine.AnimationClip c; checkType(l, 3, out c); self[v] = c; pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function setItem 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 }
static public int set_clips(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); UnityEngine.AnimationClipPair[] v; checkType(l, 2, out v); self.clips = v; return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int set_clips(IntPtr l) { try { UnityEngine.AnimatorOverrideController self = (UnityEngine.AnimatorOverrideController)checkSelf(l); UnityEngine.AnimationClipPair[] v; checkArray(l, 2, out v); self.clips = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static int ApplyOverrides(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.AnimatorOverrideController obj = (UnityEngine.AnimatorOverrideController)ToLua.CheckObject <UnityEngine.AnimatorOverrideController>(L, 1); System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <UnityEngine.AnimationClip, UnityEngine.AnimationClip> > arg0 = (System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <UnityEngine.AnimationClip, UnityEngine.AnimationClip> >)ToLua.CheckObject <System.Collections.Generic.IList <System.Collections.Generic.KeyValuePair <UnityEngine.AnimationClip, UnityEngine.AnimationClip> > >(L, 2); obj.ApplyOverrides(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int ctor__RuntimeAnimatorController_s(IntPtr l) { try { UnityEngine.AnimatorOverrideController o; UnityEngine.RuntimeAnimatorController a1; checkType(l, 1, out a1); o = new UnityEngine.AnimatorOverrideController(a1); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
// fields // properties static void AnimatorOverrideController_runtimeAnimatorController(JSVCall vc) { if (vc.bGet) { UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj; var result = _this.runtimeAnimatorController; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.RuntimeAnimatorController arg0 = (UnityEngine.RuntimeAnimatorController)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj; _this.runtimeAnimatorController = arg0; } }
static void AnimatorOverrideController_Item_AnimationClip(JSVCall vc) { UnityEngine.AnimationClip arg0 = (UnityEngine.AnimationClip)JSMgr.datax.getObject((int)JSApi.GetType.Arg); if (vc.bGet) { UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj; var result = _this[arg0]; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); } else { UnityEngine.AnimationClip arg1 = (UnityEngine.AnimationClip)JSMgr.datax.getObject((int)JSApi.GetType.Arg); UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj; _this[arg0] = arg1; } }
void Start() { anim=gameObject.GetComponent<Animator>(); if(anim!=null){ if(enableConstruct) tower.playConstructAnimation=this.PlayConstruct; if(enableDeconstruct) tower.playDeconstructAnimation=this.PlayDeconstruct; AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = anim.runtimeAnimatorController; overrideController["DefaultTowerConstruct"] = clipConstruct!=null ? clipConstruct : null; overrideController["DefaultTowerDeconstruct"] = clipDeconstruct!=null ? clipDeconstruct : null; overrideController["DefaultTowerShoot"] = clipShoot!=null ? clipShoot : null; anim.runtimeAnimatorController = overrideController; } }
static int set_runtimeAnimatorController(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.AnimatorOverrideController obj = (UnityEngine.AnimatorOverrideController)o; UnityEngine.RuntimeAnimatorController arg0 = (UnityEngine.RuntimeAnimatorController)ToLua.CheckObject <UnityEngine.RuntimeAnimatorController>(L, 2); obj.runtimeAnimatorController = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index runtimeAnimatorController on a nil value")); } }
AnimatorOverrideController createAnimatorController(params AnimationClip[] clips) { AnimationClipPair[] pairs = new AnimationClipPair[orgcontroller.animationClips.Length]; for (int i = 0; i < pairs.Length; i++) { pairs[i] = new AnimationClipPair { originalClip = orgcontroller.animationClips[i], overrideClip = clips[i] }; } AnimatorOverrideController ret = new AnimatorOverrideController(); ret.name = "TheTestController"; ret.runtimeAnimatorController = orgcontroller; ret.clips = pairs; return ret; }
void Awake() { UIAnimator = gameObject.GetComponent<Animator>(); if (UIAnimator == null) { UIAnimator = gameObject.AddComponent<Animator>(); UIAnimator.runtimeAnimatorController = Resources.Load<RuntimeAnimatorController>("Common/UI Animation/Base UI Animator"); AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = Animator.Instantiate(UIAnimator.runtimeAnimatorController); overrideController.name = @"OverrideController"; overrideController["Appearing"] = AppearEffect; overrideController["Disappearing"] = DisappearEffect; UIAnimator.runtimeAnimatorController = overrideController; if (DisappearEffect == null) MirrorAppear = true; } }
private void Start () { whiteCam = GameObject.Find ("White Camera").GetComponent<Camera>(); blackCam = GameObject.Find ("Black Camera").GetComponent<Camera>(); framesToCapture +=1; if (recordAnimation) { Animation anim = FindObjectOfType<Animation> (); if (anim != null) { anim.Play (animationClip.name); }else{ Animator animator=FindObjectOfType<Animator>(); if(animator != null){ RuntimeAnimatorController tempController = animator.runtimeAnimatorController; AnimatorOverrideController overrideController= new AnimatorOverrideController(); overrideController.runtimeAnimatorController=tempController; overrideController["Temp"]=animationClip; animator.runtimeAnimatorController = overrideController; } } if(autoFrameRate){ frameRate = (int)(framesToCapture / animationClip.length); } } Time.captureFramerate = frameRate; realFolder = folder; int count = 1; while (System.IO.Directory.Exists(Application.dataPath+"/"+realFolder)) { realFolder = folder +" "+ count; count++; } System.IO.Directory.CreateDirectory(Application.dataPath+"/"+realFolder); originaltimescaleTime=Time.timeScale; }
// change spell cast animation void SpellANIMOFF(string spell) { RuntimeAnimatorController cn = anm.runtimeAnimatorController; AnimatorOverrideController ov = new AnimatorOverrideController(); ov.runtimeAnimatorController = cn; AnimationClip animation = Resources.Load<AnimationClip>("Animations/Spells/" + spell); if(animation == null) { animation = defaultOffSpell; } animation.name = "CastSpell"; ov["CastSpell"] = animation; anm.runtimeAnimatorController = ov; }
//============================================================== void ProcessNextCycle() { Debug.Log ("next cycle process, time:"+Time.time); AnimationBaker.cycleProcessed = false; if(curCharacter!=null){ Destroy(curCharacter.gameObject); } if((curAnimationClipId== animationsList.Length-1) && (curCharacterId==charactersList.Length-1)){ Debug.Log ("All stuff processed!"); startRecord = false; EditorApplication.isPlaying = false; AssetDatabase.Refresh(); return; } if(executionModeA){ curAnimationClipId++; if(curCharacterId<0) curCharacterId = 0; if(curAnimationClipId>animationsList.Length-1){ curAnimationClipId = 0; curCharacterId++; } }else{ curCharacterId++; if(curAnimationClipId<0) curAnimationClipId = 0; if(curCharacterId>charactersList.Length-1){ curCharacterId = 0; curAnimationClipId++; } } Debug.Log ("cur anim id:"+curAnimationClipId+" cur char id:"+curCharacterId); if(animationsList[curAnimationClipId].bakeForID[curCharacterId] == false){ Debug.Log ("baking of '"+animationsList[curAnimationClipId].clip.name+"' skipped for "+charactersList[curCharacterId].transform.name); AnimationBaker.cycleProcessed = true; return; } Debug.Log ("create new character"); lastStateName = "dummy"; curCharacter = Instantiate(charactersList[curCharacterId],Vector3.zero,Quaternion.identity) as Transform; curCharacter.name = charactersList[curCharacterId].name; curCharacterName = curCharacter.name; _animator = curCharacter.GetComponent<Animator>(); _animator.cullingMode = AnimatorCullingMode.AlwaysAnimate; if(baseController == null){ baseController = AssetDatabase.LoadAssetAtPath("Assets/AnimationBaker/Core/aB_Animator.controller",typeof(RuntimeAnimatorController)) as RuntimeAnimatorController; Debug.Log ("baseController is empty, trying to load again..."); } _animator.runtimeAnimatorController = baseController; AnimatorOverrideController oC = new AnimatorOverrideController(); oC.runtimeAnimatorController = _animator.runtimeAnimatorController; oC[lastStateName] = animationsList[curAnimationClipId].clip; _animator.runtimeAnimatorController = oC; lastStateName = animationsList[curAnimationClipId].clip.name; curCharacter.gameObject.AddComponent<AnimationBaker>(); baker = curCharacter.GetComponent<AnimationBaker>(); baker.sourceAnimator = _animator; baker.samples = sampleRate; baker.isLegacyType = isLegacyType; if(modelNamePrefix) baker.clipNamePrefix +=curCharacter.name+"_"; if(frameRatePrefix) baker.clipNamePrefix += sampleRate.ToString()+"_"; if(!createDumpForAll) baker.createDumpFile = animationsList[curAnimationClipId].createDump; else baker.createDumpFile = createDumpForAll; if(!autoBakeDumpForAll) baker.dumpAutoBake = animationsList[curAnimationClipId].autoBakeDump; else baker.dumpAutoBake = autoBakeDumpForAll; if(animationsList[curAnimationClipId].recordTime<0) baker.recordTime = animationsList[curAnimationClipId].clip.length; else baker.recordTime = animationsList[curAnimationClipId].recordTime; baker.curAnimationName = lastStateName; baker.delayTime = delay; baker.delayPassedTime = 0f; baker.sourceAnimator.speed = 0f; //applying constraints================================ if(useCommonBakingProperties) baker.bakingProperties = bakingProperties; else baker.bakingProperties = animationsList[curAnimationClipId].bakingProperties; if(useCommonRootConstraints){ if(useRootConstraints){ baker.rootPositionConstraint = rootPositionConstraints; baker.rootRotationConstraint = rootRotationConstraints; baker.rootScaleConstraint = rootScaleConstraints; baker.useRootConstraints = true; }else baker.useRootConstraints = false; }else if(animationsList[curAnimationClipId].useRootConstraints){ baker.rootPositionConstraint = animationsList[curAnimationClipId].rootPositionConstraints; baker.rootRotationConstraint = animationsList[curAnimationClipId].rootRotationConstraints; baker.rootScaleConstraint = animationsList[curAnimationClipId].rootScaleConstraints; baker.useRootConstraints = true; }else baker.useRootConstraints = false; //==================================================== baker.startRecord = true; if(mainCamera == null){ mainCamera = Camera.main; if(mainCamera == null){ GameObject dummy = new GameObject(); dummy.AddComponent<Camera>(); mainCamera = dummy.GetComponent<Camera>(); } } mainCamera.transform.position = new Vector3(curCharacter.position.x,curCharacter.position.y+2f,curCharacter.position.z)+curCharacter.forward*100; mainCamera.transform.LookAt(curCharacter.position); mainCamera.orthographic = true; mainCamera.orthographicSize = 2f; }
void Start() { AnimatorOverrideController controller = new AnimatorOverrideController(); animator.runtimeAnimatorController = controller; }
// Use this for initialization void Start() { animator = GetComponent<Animator>(); overrideController = animator.runtimeAnimatorController as AnimatorOverrideController; }
//The overrite machine. Creates an overrideController, replace its core animations and restate it back in private void _playAnimation(AnimationData targetAnimationData, float blendingTime, float normalizedTime, bool mirror) { if (targetAnimationData == null || targetAnimationData.clip == null) return; AnimatorOverrideController overrideController = new AnimatorOverrideController(); float newAnimatorSpeed = Mathf.Abs(targetAnimationData.originalSpeed); float currentNormalizedTime = GetCurrentClipPosition(); currentMirror = mirror; if (mirror){ if (targetAnimationData.originalSpeed >= 0) { overrideController.runtimeAnimatorController = controller2; }else{ overrideController.runtimeAnimatorController = controller4; } }else{ if (targetAnimationData.originalSpeed >= 0) { overrideController.runtimeAnimatorController = controller1; }else{ overrideController.runtimeAnimatorController = controller3; } } if (currentAnimationData != null) overrideController["State1"] = currentAnimationData.clip; overrideController["State2"] = targetAnimationData.clip; if (blendingTime == -1) blendingTime = currentAnimationData.transitionDuration; if (blendingTime == -1) blendingTime = defaultTransitionDuration; if (blendingTime <= 0 || currentAnimationData == null){ animator.runtimeAnimatorController = overrideController; animator.Play("State2", 0, normalizedTime); }else { animator.runtimeAnimatorController = overrideController; currentAnimationData.stateName = "State1"; SetCurrentClipPosition(currentNormalizedTime); animator.Update(0); animator.CrossFade("State2", blendingTime/newAnimatorSpeed, 0, normalizedTime); } targetAnimationData.secondsPlayed = (normalizedTime * targetAnimationData.clip.length) / newAnimatorSpeed; targetAnimationData.length = targetAnimationData.clip.length; targetAnimationData.normalizedTime = normalizedTime; if (overrideRootMotion) animator.applyRootMotion = targetAnimationData.applyRootMotion; SetSpeed(targetAnimationData.originalSpeed); if (currentAnimationData != null) { currentAnimationData.speed = currentAnimationData.originalSpeed; currentAnimationData.normalizedSpeed = 1; currentAnimationData.timesPlayed = 0; } currentAnimationData = targetAnimationData; currentAnimationData.stateName = "State2"; if (MecanimControl.OnAnimationBegin != null) MecanimControl.OnAnimationBegin(currentAnimationData); }
public void ReplaceClip() { Animator m_animator = GetComponentInChildren<Animator>(); m_animator.applyRootMotion = false; m_animator.runtimeAnimatorController = animController; m_overrideController = new AnimatorOverrideController (); m_overrideController.runtimeAnimatorController = m_animator.runtimeAnimatorController; AnimationClip[] cs = m_animator.runtimeAnimatorController.animationClips; foreach (AnimationClip ac in cs) { print (ac); } if (m_overrideController) { foreach (TargetPart tp in targetParts) { m_overrideController [tp.targetClipName] = tp.clips[tp.currentClipIndex].clip; } if (!ReferenceEquals (m_animator.runtimeAnimatorController, m_overrideController)) { m_animator.runtimeAnimatorController = m_overrideController; } } gameObject.GetComponent<PlaceItem> ().EndEditing (); }
void Start() { if (defaultAnimation.clip == null && animations.Length > 0){ SetDefaultClip(animations[0].clip, "Default", animations[0].speed, animations[0].wrapMode, false); } if (defaultAnimation.clip != null){ foreach(AnimationData animData in animations) { if (animData.clip == defaultAnimation.clip) defaultAnimation.clip = (AnimationClip) Instantiate(defaultAnimation.clip); } AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = controller1; currentAnimationData = defaultAnimation; currentAnimationData.stateName = "State2"; currentAnimationData.length = currentAnimationData.clip.length; overrideController["State1"] = currentAnimationData.clip; overrideController["State2"] = currentAnimationData.clip; animator.runtimeAnimatorController = overrideController; animator.Play("State2", 0, 0); if (overrideRootMotion) animator.applyRootMotion = currentAnimationData.applyRootMotion; SetSpeed(currentAnimationData.speed); } }
private void RandomizeBasicClips() { var holder = AudienceAnimWarehouse.curr; if (holder == null) return; AnimatorOverrideController overCtrl = new AnimatorOverrideController(); overCtrl.name = "Basic Audience Override Anim Ctrl"; overCtrl.runtimeAnimatorController = controller.runtimeAnimatorController; var clipPairs = overCtrl.clips; AnimationClipPair leftChatPair = null; AnimationClipPair rightChatPair = null; foreach (var pair in clipPairs) { if (holder.basicFocusedClips != null && holder.basicFocusedClips.Length > 0) { bool found = false; foreach (var clip in holder.basicFocusedClips) { if (pair.originalClip == clip.clip) { float sample = Random.value; for (int i = 0; i < holder.basicFocusedClips.Length; ++i) if (sample < holder.basicFocusedClips[i].probability) { pair.overrideClip = holder.basicFocusedClips[i].clip; break; } found = true; break; } } if (found) continue; } if (holder.basicBoredClips != null && holder.basicBoredClips.Length > 0) { bool found = false; foreach (var clip in holder.basicBoredClips) { if (pair.originalClip == clip.clip) { float sample = Random.value; for (int i = 0; i < holder.basicBoredClips.Length; ++i) if (sample < holder.basicBoredClips[i].probability) { pair.overrideClip = holder.basicBoredClips[i].clip; break; } found = true; break; } } if (found) continue; } if (holder.basicChattingClips != null && holder.basicChattingClips.Length > 0) { bool found = false; foreach (var clip in holder.basicChattingClips) { if (pair.originalClip == clip.clip1) { leftChatPair = pair; break; } else if (pair.originalClip == clip.clip2) { rightChatPair = pair; break; } } if (found) continue; } } float s = Random.value; for (int i = 0; i < holder.basicChattingClips.Length; ++i) if (s < holder.basicChattingClips[i].probability) { leftChatPair.overrideClip = holder.basicChattingClips[i].clip1; rightChatPair.overrideClip = holder.basicChattingClips[i].clip2; break; } overCtrl.clips = clipPairs; controller.runtimeAnimatorController = overCtrl; }
// Use this for initialization void Start() { // create mock scene with two player objects mPlayer1 = GameObject.CreatePrimitive(PrimitiveType.Cube); mPlayer2 = GameObject.Find("CubeHand"); Vector3 scale = new Vector3(0.1f, 0.1f, 0.1f); mPlayer1.transform.localScale = scale; mPlayer2.transform.localScale = scale; // find the camera and man mCamera = GameObject.Find("Main Camera"); mMan = GameObject.Find("Man"); //RuntimeAnimatorController animCtrl = mMan.AddComponent("RuntimeAnimatorController") as RuntimeAnimatorController; // //RuntimeAnimatorController anim = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("myAnimation", typeof(RuntimeAnimatorController))); AnimatorOverrideController overrideController = new AnimatorOverrideController(); //Animator manimator = mMan.GetComponent<Animator>(); //manimator.runtimeAnimatorController = overrideController; // mLeftHand = GameObject.FindWithTag("LeftHand"); mRightHand = GameObject.FindWithTag("RightHand"); mRightShoulder = GameObject.FindWithTag("RightShoulder"); // hook up the IK if (mRightShoulder != null) { //IKControl ik = mRightShoulder.GetComponent<IKControl>(); //ik.target = mPlayer2.transform; //ik.ikActive = true; //IKCtrl ik = mRightShoulder.GetComponent<IKCtrl>(); //ik.rightHandObj = mPlayer2.transform; //ik.ikActive = true; //ikLimb2 ik = mRightShoulder.GetComponent<ikLimb2>(); //IKLimb ik = mRightShoulder.GetComponent<IKLimb>(); IKScriptNew ik = mRightShoulder.GetComponent<IKScriptNew>(); //ik.target = mPlayer2.transform; ik.IsEnabled = true; } // restart the scene Restart(); // create the behaviors in this scene float speed = 0.025f; Behavior p1Up = new TranslateBehavior("player1 move up", mPlayer1, new Vector3( 0, 1, 0) * speed); Behavior p1Down = new TranslateBehavior("player1 move down", mPlayer1, new Vector3( 0, -1, 0) * speed); Behavior p1Left = new TranslateBehavior("player1 move left", mPlayer1, new Vector3(-1, 0, 0) * speed); Behavior p1Right = new TranslateBehavior("player1 move right", mPlayer1, new Vector3( 1, 0, 0) * speed); Behavior p2Up = new TranslateBehavior("player2 move up", mPlayer2, new Vector3( 0, 1, 0) * speed); Behavior p2Down = new TranslateBehavior("player2 move down", mPlayer2, new Vector3( 0, -1, 0) * speed); Behavior p2Left = new TranslateBehavior("player2 move left", mPlayer2, new Vector3(-1, 0, 0) * speed); Behavior p2Right = new TranslateBehavior("player2 move right", mPlayer2, new Vector3( 1, 0, 0) * speed); // create the control scheme that maps inputs to these behaviors mControls = new ControlScheme(); mControls.AddControl(new KeyCodeControlSignal(KeyCode.W), p1Up ); mControls.AddControl(new KeyCodeControlSignal(KeyCode.S), p1Down ); mControls.AddControl(new KeyCodeControlSignal(KeyCode.A), p1Left ); mControls.AddControl(new KeyCodeControlSignal(KeyCode.D), p1Right); mControls.AddControl(new KeyCodeControlSignal(KeyCode.UpArrow), p2Up ); mControls.AddControl(new KeyCodeControlSignal(KeyCode.DownArrow), p2Down ); mControls.AddControl(new KeyCodeControlSignal(KeyCode.LeftArrow), p2Left ); mControls.AddControl(new KeyCodeControlSignal(KeyCode.RightArrow), p2Right); // mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, 1.0f), p1Up ); mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, -1.0f), p1Down ); mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, -1.0f), p1Left ); mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.One, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, 1.0f), p1Right ); mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, 1.0f), p2Up ); mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.Y, -1.0f), p2Down ); mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, -1.0f), p2Left ); mControls.AddControl(new GamepadAxisControlSignal(GamepadInput.GamePad.Index.Two, GamepadInput.GamePad.Axis.LeftStick, GamepadAxisControlSignal.Dimension.X, 1.0f), p2Right ); }
// function called when the equipped weapon of the player changes public void WeaponChanged() { isWeaponSheathed = true; instantiateSheathedSword(); // change all animations bumbo // vivi is a bum RuntimeAnimatorController cn = anm.runtimeAnimatorController; AnimatorOverrideController ov = new AnimatorOverrideController(); ov.runtimeAnimatorController = cn; WeaponScript ws = sword.GetComponent<WeaponScript>(); ov["ReadySword"] = ws.WeaponHoldTarget; ov["HoldSword"] = ws.WeaponHold; ov["Swing1"] = ws.LightATK; ov["Swing2"] = ws.LightATK2; ov["Swing3"] = ws.LightATK3; ov["Attack1"] = ws.HeavyATK; ov["Attack2"] = ws.HeavyATK2; ov["ChargeAttack"] = ws.ChargeAttack; ov["RollAttack"] = ws.RollAttack; //ov["SpecialAttack"] = ws.SpecialAttack; ov["Sheathe"] = ws.Sheathe; ov["Unsheathe"] = ws.Unsheathe; anm.runtimeAnimatorController = ov; }
public void WeaponEquipt(string name) { PlayerInventory.GetPlayerInventory().EquiptWeapon(name); WeaponBase myWeapon = PlayerInventory.GetPlayerInventory().GetCurrentWeapon().GetComponent<WeaponBase>(); myWeapon.transform.SetParent(weapon.transform); myWeapon.transform.localPosition = new Vector3(0, 0, 0); myWeapon.transform.Rotate(myWeapon.weaponRotation); weapon.transform.localPosition = myWeapon.weaponPosition; AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = myAnimator.runtimeAnimatorController; overrideController["Attack"] = myWeapon.weaponAnim; myAnimator.runtimeAnimatorController = overrideController; }
// Use this for initialization void Start() { Ammo = new int[10]; controller = GetComponent<CharacterController>(); anim = GetComponent<Animator>(); AoC = new AnimatorOverrideController(); rigid = controller.attachedRigidbody; StartCoroutine ("HurtWait"); WeaponHas [0] = false; WeaponHas [1] = true; Ammo [0] = 100; //Knife Ammo [1] = 100; //Shotgun }