void Update() { if (morph == null) { morph = (MegaMorphBase)GetComponent <MegaMorphBase>(); } if (LinkedUpdate) { DoLinkedUpdate(); } else { if (morph && clips.Count > 0 && current < clips.Count) { if (t >= 0.0f) { t += Time.deltaTime; float dt = clips[current].end - clips[current].start; switch (clips[current].loop) { case MegaRepeatMode.Loop: at = Mathf.Repeat(t, dt); break; case MegaRepeatMode.PingPong: at = Mathf.PingPong(t, dt); break; case MegaRepeatMode.Clamp: at = Mathf.Clamp(t, 0.0f, dt); break; } at += clips[current].start; morph.SetAnim(at); } } } }
public override void PostCopy(MegaModifier src) { MegaMorphBase mor = (MegaMorphBase)src; chanBank = new List <MegaMorphChan>(); for (int c = 0; c < mor.chanBank.Count; c++) { MegaMorphChan chan = new MegaMorphChan(); MegaMorphChan.Copy(mor.chanBank[c], chan); chanBank.Add(chan); } }
static public GameObject DoCopyObjects(GameObject from) { MegaModifyObject fromMod = from.GetComponent <MegaModifyObject>(); GameObject to; if (fromMod) { to = CopyMesh(from, fromMod); } else { to = CopyMesh(from); } //CopyObject.CopyFromTo(from, to); //return to; //MegaModifier[] desmods = to.GetComponents<MegaModifier>(); //for ( int i = 0; i < desmods.Length; i++ ) //{ // GameObject.DestroyImmediate(desmods[i]); //} //MegaModifyObject mo = to.GetComponent<MegaModifyObject>(); //if ( mo ) //{ //GameObject.DestroyImmediate(mo); MegaModifyObject mo = to.AddComponent <MegaModifyObject>(); CopyModObj(fromMod, mo); //} MegaModifier[] mods = from.GetComponents <MegaModifier>(); for (int i = 0; i < mods.Length; i++) { Component com = CopyComponent(mods[i], to); //Type tp = com.GetType(); #if false if (tp.IsSubclassOf(typeof(MegaMorphBase))) { MegaMorphBase mor = (MegaMorphBase)com; // Need to rebuild the morphchan List <MegaMorphChan> chans = new List <MegaMorphChan>(); for (int c = 0; c < mor.chanBank.Count; c++) { MegaMorphChan chan = new MegaMorphChan(); MegaMorphChan.Copy(mor.chanBank[c], chan); chans.Add(chan); } mor.chanBank = chans; } #endif #if false if (tp.IsSubclassOf(typeof(MegaFFD))) { MegaFFD ffd = (MegaFFD)com; MegaFFD srcffd = (MegaFFD)mods[i]; ffd.pt = new Vector3[64]; for (int c = 0; c < 64; c++) { ffd.pt[c] = srcffd.pt[c]; } } #endif // TODO: Add method to modifiers so can deal with any special cases if (com) { MegaModifier mod = (MegaModifier)com; mod.PostCopy(mods[i]); } } if (mo) { //mod.ReStart1(false); //for ( int i = 0; i < mods.Length; i++ ) // mods[i].SetModMesh(mod.cachedMesh); mo.MeshUpdated(); } to.name = from.name + " - Copy"; return(to); }
static public GameObject DoCopyObjects(GameObject from) { MegaModifyObject fromMod = from.GetComponent <MegaModifyObject>(); GameObject to; if (fromMod) { to = CopyMesh(from, fromMod); } else { to = CopyMesh(from); } //CopyObject.CopyFromTo(from, to); //return to; MegaModifier[] desmods = to.GetComponents <MegaModifier>(); for (int i = 0; i < desmods.Length; i++) { GameObject.DestroyImmediate(desmods[i]); } MegaModifyObject mo = to.GetComponent <MegaModifyObject>(); if (mo) { GameObject.DestroyImmediate(mo); mo = to.AddComponent <MegaModifyObject>(); CopyModObj(fromMod, mo); } MegaModifier[] mods = from.GetComponents <MegaModifier>(); //for ( int i = 0; i < mods.Length; i++ ) //{ // CopyComponent(mods[i], to); //} for (int i = 0; i < mods.Length; i++) { Component com = CopyComponent(mods[i], to); Type tp = com.GetType(); if (tp.IsSubclassOf(typeof(MegaMorphBase))) { MegaMorphBase mor = (MegaMorphBase)com; // Need to rebuild the morphchan List <MegaMorphChan> chans = new List <MegaMorphChan>(); for (int c = 0; c < mor.chanBank.Count; c++) { MegaMorphChan chan = new MegaMorphChan(); MegaMorphChan.Copy(mor.chanBank[c], chan); chans.Add(chan); } mor.chanBank = chans; } } if (mo) { //mod.ReStart1(false); //for ( int i = 0; i < mods.Length; i++ ) // mods[i].SetModMesh(mod.cachedMesh); mo.MeshUpdated(); } to.name = from.name + " - Copy"; return(to); }
void DoUpdate() { if ( MultipleMorphs ) { if ( morphs == null ) morphs = GetComponentsInChildren<MegaMorphBase>(); } else { if ( morph == null ) morph = (MegaMorphBase)GetComponent<MegaMorphBase>(); } if ( LinkedUpdate ) { DoLinkedUpdate(); } else { //if ( morph && clips.Count > 0 && current < clips.Count ) if ( clips.Count > 0 && current < clips.Count ) { UpdatePlayingClips(); if ( t >= 0.0f ) { t += Time.deltaTime * clips[current].speed; float dt = clips[current].end - clips[current].start; switch ( clips[current].loop ) { case MegaRepeatMode.Loop: at = Mathf.Repeat(t, dt); break; case MegaRepeatMode.PingPong: at = Mathf.PingPong(t, dt); break; case MegaRepeatMode.Clamp: at = Mathf.Clamp(t, 0.0f, dt); break; } at += clips[current].start; if ( MultipleMorphs ) { if ( morphs != null ) { for ( int i = 0; i < morphs.Length; i++ ) { morphs[i].SetAnim(at); } } } else { if ( morph ) morph.SetAnim(at); } } } } }
void Update() { if ( morph == null ) morph = (MegaMorphBase)GetComponent<MegaMorphBase>(); if ( morph && clips.Count > 0 && current < clips.Count ) { if ( t >= 0.0f ) { t += Time.deltaTime; float dt = clips[current].end - clips[current].start; switch ( clips[current].loop ) { case MegaRepeatMode.Loop: at = Mathf.Repeat(t, dt); break; case MegaRepeatMode.PingPong: at = Mathf.PingPong(t, dt); break; case MegaRepeatMode.Clamp: at = Mathf.Clamp(t, 0.0f, dt); break; } at += clips[current].start; morph.SetAnim(at); } } }
void Update() { if (MultipleMorphs) { if (morphs == null) { morphs = GetComponentsInChildren <MegaMorphBase>(); } } else { if (morph == null) { morph = (MegaMorphBase)GetComponent <MegaMorphBase>(); } } if (LinkedUpdate) { DoLinkedUpdate(); } else { //if ( morph && clips.Count > 0 && current < clips.Count ) if (clips.Count > 0 && current < clips.Count) { UpdatePlayingClips(); if (t >= 0.0f) { t += Time.deltaTime * clips[current].speed; float dt = clips[current].end - clips[current].start; switch (clips[current].loop) { case MegaRepeatMode.Loop: at = Mathf.Repeat(t, dt); break; case MegaRepeatMode.PingPong: at = Mathf.PingPong(t, dt); break; case MegaRepeatMode.Clamp: at = Mathf.Clamp(t, 0.0f, dt); break; } at += clips[current].start; if (MultipleMorphs) { if (morphs != null) { for (int i = 0; i < morphs.Length; i++) { morphs[i].SetAnim(at); } } } else { if (morph) { morph.SetAnim(at); } } } } } }