BoneHair3.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using UnityEngine;
  3. public class BoneHair3
  4. {
  5. public BoneHair3(TBodySkin bodyskin)
  6. {
  7. this.m_BodySkin = bodyskin;
  8. this.m_Body = bodyskin.body;
  9. }
  10. public void WarpInit()
  11. {
  12. if (this.m_SkirtBone != null)
  13. {
  14. this.m_SkirtBone.m_bResetPos = true;
  15. }
  16. }
  17. public void Init()
  18. {
  19. }
  20. public void Uninit()
  21. {
  22. if (this.m_SkirtBone != null)
  23. {
  24. this.m_SkirtBone.Uninit();
  25. UnityEngine.Object.DestroyImmediate(this.m_SkirtBone);
  26. this.m_SkirtBone = null;
  27. }
  28. }
  29. public bool InitGameObject(GameObject f_goRoot, MPN f_mpn)
  30. {
  31. if (!this.m_Body.m_bNewSkirtPhyscs)
  32. {
  33. return false;
  34. }
  35. Transform transform = this.SearchSkirtBone(f_goRoot.transform);
  36. if (transform == null)
  37. {
  38. return false;
  39. }
  40. Transform parent = transform.parent;
  41. NDebug.Assert(this.m_SkirtBone == null, () => "DynamicSkirtBoneコンポーネントが二重に付けられました。");
  42. string f_strFileName = f_goRoot.name.Replace("_SM_", string.Empty);
  43. DynamicSkirtBone dynamicSkirtBone = ImportCM.TryLoadDynamicSkirtBone(f_goRoot, parent, f_strFileName, this.m_BodySkin.body);
  44. if (dynamicSkirtBone == null)
  45. {
  46. string f_strFileName2 = "default_skirt";
  47. dynamicSkirtBone = ImportCM.TryLoadDynamicSkirtBone(f_goRoot, parent, f_strFileName2, this.m_BodySkin.body);
  48. if (dynamicSkirtBone == null)
  49. {
  50. return false;
  51. }
  52. }
  53. this.m_SkirtBone = dynamicSkirtBone;
  54. this.m_SkirtBone.InitGameObject(f_goRoot, this.m_BodySkin, parent);
  55. this.WarpInit();
  56. return true;
  57. }
  58. private Transform SearchSkirtBone(Transform f_goParent)
  59. {
  60. if (f_goParent.name.Contains("_yure_skirt_"))
  61. {
  62. return f_goParent;
  63. }
  64. for (int i = 0; i < f_goParent.childCount; i++)
  65. {
  66. Transform transform = this.SearchSkirtBone(f_goParent.GetChild(i));
  67. if (transform != null)
  68. {
  69. return transform;
  70. }
  71. }
  72. return null;
  73. }
  74. public void UpdateSelf()
  75. {
  76. if (this.m_SkirtBone != null)
  77. {
  78. this.m_SkirtBone.UpdateSelf();
  79. }
  80. }
  81. private TBody m_Body;
  82. private TBodySkin m_BodySkin;
  83. private DynamicSkirtBone m_SkirtBone;
  84. }