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); }