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); }
void OnValidate() { if (null == transform.parent) { return; } if (Application.isPlaying) { return; } PEModelController mc = transform.parent.GetComponentInChildren <PEModelController>(); if (null == mc) { return; } if (m_HitReaction == null) { return; } if (m_HitReaction.m_HitParts == null) { return; } UnityEditor.Undo.RecordObject(this, "xxx"); Pathea.PEDefenceTrigger defenceTrigger = transform.parent.GetComponentInChildren <Pathea.PEDefenceTrigger>(); foreach (var hitpart in m_HitReaction.m_HitParts) { if (null != defenceTrigger && "" != hitpart.m_Name) { if (null == hitpart.m_PartTrans) { hitpart.m_PartTrans = new System.Collections.Generic.List <Transform>(); } hitpart.m_PartTrans.Clear(); for (int i = 0; i < defenceTrigger.defenceParts.Length; i++) { int count1 = hitpart.m_Name.Split('_').Length; int count2 = defenceTrigger.defenceParts[i].name.Split('_').Length; if (count1 == count2 && defenceTrigger.defenceParts[i].name.Contains(hitpart.m_Name) && null != defenceTrigger.defenceParts[i].capsule.trans) { if (!hitpart.m_PartTrans.Contains(defenceTrigger.defenceParts[i].capsule.trans)) { hitpart.m_PartTrans.Add(defenceTrigger.defenceParts[i].capsule.trans); } } } } } UnityEditor.EditorUtility.SetDirty(this); }
public void ModeTrans() { PEModelController mc = PETools.PEUtil.GetCmpt <PEModelController>(transform.parent); if (null != mc) { m_ModeTrans = mc.transform; } }
void Start() { if (null == m_Root) { PEModelController mc = transform.parent.GetComponentInChildren <PEModelController>(); if (null != mc) { m_Root = mc.transform; } } }
void Reset() { Transform checkTrans = (transform.parent != null) ? transform.parent : transform; PEModelController mc = checkTrans.GetComponentInChildren <PEModelController>(); PEInjuredController ic = checkTrans.GetComponentInChildren <PEInjuredController>(); modelRoot = centerBone = (null != mc) ? mc.transform : transform; if (null != ic && null != mc) { CheckOldCols(ic.transform, mc.transform); } }
void Start() { for (int i = 0; i < defenceParts.Length; i++) { defenceParts[i].Init(); } if (null == centerBone || null == modelRoot) { PEModelController mc = transform.GetComponentInChildren <PEModelController>(); if (null != mc) { centerBone = modelRoot = mc.transform; } } // if(null == modelRoot) // Debug.LogError("modelRoot is null." + ((null != transform.parent) ? transform.parent.name : "")); // if(null == centerBone) // Debug.LogError("centerBone is null" + ((null != transform.parent) ? transform.parent.name : "")); }
public void Reset() { modelController = PEUtil.GetCmpt <PEModelController>(transform); ragdollController = PEUtil.GetCmpt <PERagdollController>(transform); ikArray = PEUtil.GetCmpts <IK>(transform); ikFlashLight = PEUtil.GetCmpt <IKFlashLight>(transform); fbbik = PEUtil.GetCmpt <FullBodyBipedIK>(transform); grounderFBBIK = PEUtil.GetCmpt <GrounderFBBIK>(transform); humanPhyCtrl = PEUtil.GetCmpt <HumanPhyCtrl>(transform); ikAimCtrl = PEUtil.GetCmpt <IKAimCtrl>(transform); ikAnimEffectCtrl = PEUtil.GetCmpt <IKAnimEffectCtrl>(transform); ikDrive = PEUtil.GetCmpt <IKDrive>(transform); defenceTrigger = PEUtil.GetCmpt <PEDefenceTrigger>(transform); pathFinder = PEUtil.GetCmpt <PEPathfinder>(transform); motor = PEUtil.GetCmpt <PEMotor>(transform); steerAgent = PEUtil.GetCmpt <Steer3D.SteerAgent>(transform); animFollow_AF = PEUtil.GetCmpt <AnimFollow_AF>(transform); beatParam = PEUtil.GetCmpt <BeatParam>(transform); moveParam = PEUtil.GetCmpt <MoveParam>(transform); barrelController = PEUtil.GetCmpt <PEBarrelController>(transform); billBoard = PEUtil.GetCmpt <BillBoard>(transform); armorBones = PEUtil.GetCmpt <ArmorBones>(transform); visions = PEUtil.GetCmpts <PEVision>(transform); hears = PEUtil.GetCmpts <PEHearing>(transform); native = PEUtil.GetCmpt <PENative>(transform); monster = PEUtil.GetCmpt <PEMonster>(transform); if (null != modelController) { modelController.ResetModelInfo(); } if (null != animFollow_AF) { animFollow_AF.ResetModelInfo(); } if (null != ragdollController) { ragdollController.ResetRagdoll(); } }
static GameObject CreateTmplGo(AvatarData avdata) { string baseModel = avdata._baseModel; GameObject go = GameObject.Instantiate(Resources.Load(baseModel)) as GameObject; PEModelController mCtrl = go.GetComponentInChildren <PEModelController>(); if (mCtrl == null) { Debug.LogError("[CreateTmplGo]Cannot find PEModelController in baseModel:" + baseModel); return(null); } PERagdollController rCtrl = go.GetComponentInChildren <PERagdollController>(); if (rCtrl == null) { Debug.LogError("[CreateTmplGo]Cannot find PERagdollController in baseModel:" + baseModel); return(null); } Debug.LogError("[CreateTmplGo]create baseModel:" + baseModel); // Model SkinnedMeshRenderer mSmr = mCtrl.GetComponent <SkinnedMeshRenderer> (); if (null == mSmr) { mSmr = mCtrl.gameObject.AddComponent <SkinnedMeshRenderer> (); } if (mSmr.sharedMesh == null) { mSmr.sharedMesh = new Mesh(); mSmr.sharedMesh.name = "PlayerAppearance1"; } else { mSmr.sharedMesh.Clear(); } List <Material> materials = new List <Material> (); List <Transform> bones = new List <Transform> (); List <Transform> mAllBoneList = new List <Transform> (mCtrl.GetComponentsInChildren <Transform> (true)); foreach (string partPathName in avdata) { if (string.IsNullOrEmpty(partPathName)) { continue; } SkinnedMeshRenderer tmpSmr = new CustomPartInfo(partPathName).Smr; if (null == tmpSmr) { continue; } List <Transform> tmpBones = CustomUtils.FindSmrBonesByName(mAllBoneList, tmpSmr); int nSub = tmpSmr.sharedMesh.subMeshCount; for (int iSub = 0; iSub < nSub; iSub++) { //all sub mesh must find bones bones.AddRange(tmpBones); } materials.AddRange(tmpSmr.sharedMaterials); // smr.materials } mSmr.bones = bones.ToArray(); mSmr.materials = materials.ToArray(); //Ragdoll SkinnedMeshRenderer rSmr = rCtrl.GetComponent <SkinnedMeshRenderer> (); if (null == rSmr) { rSmr = rCtrl.gameObject.AddComponent <SkinnedMeshRenderer> (); } rSmr.sharedMesh = mSmr.sharedMesh; List <Transform> rAllBoneList = new List <Transform> (rCtrl.GetComponentsInChildren <Transform> (true)); bones = CustomUtils.FindSmrBonesByName(rAllBoneList, mSmr); rSmr.bones = bones.ToArray(); rSmr.sharedMaterials = mSmr.sharedMaterials; go.SetActive(false); return(go); }
protected IEnumerator ProcPostBoneLoad() { //biologyViewRoot.gameObject.SetActive (false); if (monoPhyCtrl == null) { monoPhyCtrl = biologyViewRoot.humanPhyCtrl; } if (monoIKAimCtrl == null) { monoIKAimCtrl = biologyViewRoot.ikAimCtrl; } if (monoIKAnimCtrl == null) { monoIKAnimCtrl = biologyViewRoot.ikAnimEffectCtrl; } if (monoModelCtrlr == null) { monoModelCtrlr = biologyViewRoot.modelController; } if (monoRagdollCtrlr == null) { monoRagdollCtrlr = biologyViewRoot.ragdollController; } if (monoDefenceTrigger == null) { monoDefenceTrigger = biologyViewRoot.defenceTrigger; } m_MeshBuildEnd = false; if (monoRagdollCtrlr != null) { monoRagdollCtrlr.SetHandler(this); //EMsg.View_Ragdoll_Build } // Collider ignore and other if (monoModelCtrlr != null) { SetupMaterials(mColorID, GetModelName()); if (Entity.proto == EEntityProto.Monster && Entity.Race == ERace.Mankind) { monoModelCtrlr.gameObject.layer = Layer.AIPlayer; } PEUtil.IgnoreCollision(monoModelCtrlr.colliders, monoModelCtrlr.colliders); if (monoRagdollCtrlr != null) { PEUtil.IgnoreCollision(monoModelCtrlr.colliders, monoRagdollCtrlr.colliders); } } BuildOutCollider(biologyViewRoot.gameObject); if (Entity.IsDeath()) { OnDeath(null, null); } else if (monoModelCtrlr != null) { monoModelCtrlr.ActivateDeathMode(false); } HideView(0.01f); if (Entity.Id == 9008) { ActivatePhysics(m_PhyActive); } DoActivateInjured(); yield return(0); if (null == biologyViewRoot) { yield break; } // Proc Mesh if (_coroutineMeshProc != null) { yield return(biologyViewRoot.StartCoroutine(_coroutineMeshProc())); } m_MeshBuildEnd = true; if (null == biologyViewRoot) { yield break; } if (null == Entity) { yield break; } // Send Msg if (monoModelCtrlr != null) { Profiler.BeginSample("EMsg.View_Model_Build"); Entity.SendMsg(EMsg.View_Model_Build, monoModelCtrlr.gameObject, biologyViewRoot); Profiler.EndSample(); yield return(0); } if (null == biologyViewRoot) { yield break; } if (null == Entity) { yield break; } Profiler.BeginSample("EMsg.View_Prefab_Build"); Entity.SendMsg(EMsg.View_Prefab_Build, this, biologyViewRoot); Profiler.EndSample(); yield return(0); if (null == biologyViewRoot) { yield break; } //biologyViewRoot.gameObject.SetActive (true); biologyViewRoot.StartCoroutine(FadeInDelay(0.01f, 3.0f)); // Note: prev version use this Monobehavior(NOT ROOT) to start Coroutine }