GameObject BuildModelSync() { if (string.IsNullOrEmpty(prefabPath) /*|| null != mViewPrefab || null != mPrefabReq*/) { return(null); } GameObject tmpGo = AssetsLoader.Instance.InstantiateAssetImm(m_PrefabPath, Entity.peTrans.position, Entity.peTrans.rotation, Vector3.one); if (tmpGo == null) { return(null); } BiologyViewRoot oldBiologyViewRoot = biologyViewRoot; PEModelController oldMonoModelCtrlr = monoModelCtrlr; WhiteCat.BoneCollector oldMonoBoneCollector = monoBoneCollector; biologyViewRoot = tmpGo.GetComponent <BiologyViewRoot>(); monoModelCtrlr = biologyViewRoot.modelController; monoBoneCollector = tmpGo.GetComponent <WhiteCat.BoneCollector>(); GameObject tmpModel = monoModelCtrlr.gameObject; OnBoneLoadSync(tmpModel); // Recover biologyViewRoot = oldBiologyViewRoot; monoModelCtrlr = oldMonoModelCtrlr; monoBoneCollector = oldMonoBoneCollector; tmpModel.transform.SetParent(null, true); Destroy(tmpGo); return(tmpModel); }
public virtual void Destroy() { if (mViewPrefab != null) { Entity.SendMsg(EMsg.View_Prefab_Destroy, mViewPrefab.gameObject); monoBoneCollector = null; if (monoModelCtrlr != null) { Entity.SendMsg(EMsg.View_Model_Destroy, monoModelCtrlr.gameObject); } if (monoRagdollCtrlr != null) { Entity.SendMsg(EMsg.View_Ragdoll_Destroy, monoRagdollCtrlr.gameObject); } if (mPrefabReq != null) { mPrefabReq.Deactivate(); } GameObject.Destroy(mViewPrefab.gameObject); } }
protected virtual void OnBoneLoad(GameObject obj) { mPrefabReq = null; mViewPrefab = obj.transform; mViewPrefab.parent = Entity.GetGameObject().transform; mViewPrefab.position = Entity.peTrans.position; mViewPrefab.rotation = Entity.peTrans.rotation; mViewPrefab.localScale = Entity.peTrans.scale; biologyViewRoot = mViewPrefab.GetComponent <BiologyViewRoot>(); monoBoneCollector = mViewPrefab.GetComponent <WhiteCat.BoneCollector>(); if (null == biologyViewRoot) { // Some doodads haven't root, we add it to start coroutine and make coroutine stopable while destroying mViewPrefab //Debug.LogError("BiologyViewRoot not found in " + mViewPrefab.name); biologyViewRoot = mViewPrefab.gameObject.AddComponent <BiologyViewRoot>(); } biologyViewRoot.StartCoroutine(ProcPostBoneLoad()); }