using System; using System.Collections.Generic; using UnityEngine; public class BoneHair2 { public BoneHair2(TBodySkin bodyskin) { this.m_BodySkin = bodyskin; } public void Init() { } public void Uninit() { if (this.m_listCollders != null) { for (int i = 0; i < this.m_listCollders.Count; i++) { if (this.m_listCollders[i] != null) { UnityEngine.Object.DestroyImmediate(this.m_listCollders[i].gameObject); } } this.m_listCollders.Clear(); } } public bool InitGameObject(GameObject f_goRoot, MPN f_mpn) { BoneHair2.YureType yureType = BoneHair2.YureType.Non; Transform transform = this.SearchYureBone(f_goRoot.transform, out yureType); if (transform == null || yureType == BoneHair2.YureType.Non || yureType == BoneHair2.YureType.Skirt) { return false; } Transform parent = transform.parent; if (parent == null) { NDebug.Assert(transform.name + " の親が不正です。", false); } if (yureType == BoneHair2.YureType.Hair && parent.name.ToLower().IndexOf("hair") != 0) { NDebug.Assert("髪ボーン" + transform.name + " の親が不正です。", false); } string text = f_goRoot.name.Replace("_SM_", string.Empty); float[] f_aryDefStiffness = null; if (f_mpn == MPN.hairf) { f_aryDefStiffness = new float[] { 0.95f, 0.9f, 0.7f }; } DynamicBone dynamicBone = ImportCM.TryLoadDynamicBone(f_goRoot, parent, text, this.m_BodySkin.body, f_aryDefStiffness); if (dynamicBone == null) { string f_strFileName = string.Empty; if (yureType == BoneHair2.YureType.Hair) { f_strFileName = "default_hair"; if (f_mpn == MPN.hairf) { if (GameUty.IsExistFile("default_hairf.phy", null)) { f_strFileName = "default_hairf"; } } else if (f_mpn == MPN.hairr) { if (GameUty.IsExistFile("default_hairr.phy", null)) { f_strFileName = "default_hairr"; } } else if (f_mpn == MPN.hairs) { if (GameUty.IsExistFile("default_hairs.phy", null)) { f_strFileName = "default_hairs"; } } else if (f_mpn == MPN.hairt && GameUty.IsExistFile("default_hairt.phy", null)) { f_strFileName = "default_hairt"; } } else if (yureType == BoneHair2.YureType.Yure) { if (f_mpn != MPN.hairaho) { return false; } f_strFileName = "default_haira"; } else if (yureType == BoneHair2.YureType.Skirt) { f_strFileName = "default_yure"; } dynamicBone = ImportCM.TryLoadDynamicBone(f_goRoot, parent, f_strFileName, this.m_BodySkin.body, f_aryDefStiffness); if (dynamicBone == null) { return false; } } if (!string.IsNullOrEmpty(dynamicBone.m_ColliderFileName)) { ImportCM.LoadDynamicCollilder(dynamicBone, dynamicBone.m_ColliderFileName, this.m_BodySkin.body.m_trBones, this.m_BodySkin.body.maid); } else if (GameUty.IsExistFile(text + ".col", null)) { ImportCM.LoadDynamicCollilder(dynamicBone, text, this.m_BodySkin.body.m_trBones, this.m_BodySkin.body.maid); } else { string text2 = string.Empty; if (f_mpn == MPN.hairf) { text2 = "default_hairf"; } else if (f_mpn == MPN.hairr) { text2 = "default_hairr"; } else if (f_mpn == MPN.hairt) { text2 = "default_hairt"; } else if (f_mpn == MPN.hairs) { text2 = "default_hairs"; } else if (f_mpn == MPN.hairaho) { text2 = "default_haira"; } if (!string.IsNullOrEmpty(text2)) { ImportCM.LoadDynamicCollilder(dynamicBone, text2, this.m_BodySkin.body.m_trBones, this.m_BodySkin.body.maid); } } this.m_listCollders = dynamicBone.m_Colliders; return true; } private Transform SearchYureBone(Transform f_goParent, out BoneHair2.YureType f_eYureType) { if (f_goParent.name.Contains("_yure_hair_")) { f_eYureType = BoneHair2.YureType.Hair; return f_goParent; } if (f_goParent.name.Contains("_yure_skirt_")) { f_eYureType = BoneHair2.YureType.Skirt; return f_goParent; } if (f_goParent.name.Contains("_yure_")) { f_eYureType = BoneHair2.YureType.Yure; return f_goParent; } for (int i = 0; i < f_goParent.childCount; i++) { Transform transform = this.SearchYureBone(f_goParent.GetChild(i), out f_eYureType); if (transform != null) { return transform; } } f_eYureType = BoneHair2.YureType.Non; return null; } private TBodySkin m_BodySkin; private List m_listCollders; private enum YureType { Non, Hair, Skirt, Yure } }