void CheckBone(GameObject obj, mainPlayerCfg playerCfg) { if (null == playerCfg) { Debug.Log("prefab = " + obj.name + " playerCfg " + " = Null"); } else { if (null == playerCfg.m_headTransform) { Debug.Log("prefab = " + obj.name + " playerCfg.m_headTransform " + " = Null"); } else { if ("Bip01 Head" != playerCfg.m_headTransform.name) { Debug.Log("prefab = " + obj.name + " playerCfg.m_headTransform.name " + " wrong"); } } if (null == playerCfg.m_upperBodyTransform) { Debug.Log("prefab = " + obj.name + " playerCfg.m_upperBodyTransform " + " = Null"); } else { if ("Bip01 Spine1" != playerCfg.m_upperBodyTransform.name) { Debug.Log("prefab = " + obj.name + " playerCfg.m_upperBodyTransform.name " + " wrong"); } } if (null == playerCfg.m_rootTransform) { Debug.Log("prefab = " + obj.name + " playerCfg.m_rootTransform " + " = Null"); } else { if ("Bip01" != playerCfg.m_rootTransform.name) { Debug.Log("prefab = " + obj.name + " playerCfg.m_rootTransform.name " + " wrong"); } } if (null == playerCfg.m_ghostResource) { Debug.Log("prefab = " + obj.name + " playerCfg.m_ghostResource " + " = Null"); } } //检查骨 Transform rootBone = LookupBone(obj.transform, "Bip01"); if (null == rootBone) { Debug.Log("prefab = " + obj.name + " Bip01 Bone " + " = Null"); } Transform footsteps = LookupBone(obj.transform, "Bip01 Footsteps"); if (null == footsteps) { Debug.Log("prefab = " + obj.name + " Bip01 Footsteps Bone " + " = Null"); } Transform spine = LookupBone(obj.transform, "Bip01 Spine"); if (null == spine) { Debug.Log("prefab = " + obj.name + " Bip01 Spine Bone " + " = Null"); } Transform spine1 = LookupBone(obj.transform, "Bip01 Spine1"); if (null == spine1) { Debug.Log("prefab = " + obj.name + " Bip01 Spine Bone1 " + " = Null"); } Transform head = LookupBone(obj.transform, "Bip01 Head"); if (null == head) { Debug.Log("prefab = " + obj.name + " Bip01 Head " + " = Null"); } }
void OnGUI() { this.Repaint(); if (!mIsFirst) { mList.Add("Actor/Hero"); mList.Add("Actor/NPC"); mIsFirst = true; } mIsCheckSingleFile = EditorGUILayout.Toggle("Check Single File", mIsCheckSingleFile); mIndex = EditorGUILayout.Popup("Check Type:", mIndex, mList.ToArray()); Rect rct = new Rect(30, 50, 100, 30); Rect rct1 = new Rect(30, 85, 100, 30); if (GUI.Button(rct, @"Check")) { if (mIsCheckSingleFile) { GameObject[] selection = Selection.gameObjects; if (selection.Length <= 0) { return; } if (null == selection[0]) { return; } // 选择的物件 GameObject obj = selection[0]; // 获得动画列表 CheckActorAnimation(obj); } else { string sPth = Application.streamingAssetsPath; sPth = sPth.Remove(sPth.LastIndexOf("/") + 1); string path = sPth + PrefabPath + mList[mIndex]; if (!Directory.Exists(path)) { Debug.Log("not exist " + path); return; } string[] fls = Directory.GetFiles(path, "*.prefab"); foreach (string str in fls) { string strkey = "/" + mList[mIndex]; int nIdx = str.LastIndexOf(strkey); string prefabFile = str.Substring(nIdx + 1); nIdx = prefabFile.LastIndexOf("."); prefabFile = prefabFile.Remove(nIdx); GameObject obj = GameData.LoadPrefab <GameObject>(prefabFile); // 获得动画列表 CheckActorAnimation(obj); } } Debug.Log("!!!!!!!!check success!!!!!!!!"); } //检查玩家骨骼资源 if (GUI.Button(rct1, @"CheckBone")) { if (mIsCheckSingleFile) { GameObject[] selection = Selection.gameObjects; if (selection.Length <= 0) { return; } if (null == selection[0]) { return; } // 选择的物件 GameObject obj = selection[0]; mainPlayerCfg playerCfg = null; // 获得骨骼列表 playerCfg = obj.GetComponent <mainPlayerCfg>(); CheckBone(obj, playerCfg); Debug.Log("prefab = " + obj.name + " Check Complete"); } else { string sPth = Application.streamingAssetsPath; sPth = sPth.Remove(sPth.LastIndexOf("/") + 1); string path = sPth + PrefabPath + mList[mIndex]; if (!Directory.Exists(path)) { Debug.Log("not exist " + path); return; } string[] fls = Directory.GetFiles(path, "*.prefab"); foreach (string str in fls) { string strkey = "/" + mList[mIndex]; int nIdx = str.LastIndexOf(strkey); string prefabFile = str.Substring(nIdx + 1); nIdx = prefabFile.LastIndexOf("."); prefabFile = prefabFile.Remove(nIdx); GameObject obj = GameData.LoadPrefab <GameObject>(prefabFile); mainPlayerCfg playerCfg = null; // 获得骨骼列表 playerCfg = obj.GetComponent <mainPlayerCfg>(); CheckBone(obj, playerCfg); Debug.Log("prefab = " + obj.name + " Check Complete"); } } } }