CharaDumper.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. [ExecuteInEditMode]
  5. public class CharaDumper : MonoBehaviour
  6. {
  7. private void Awake()
  8. {
  9. if (!Application.isPlaying)
  10. {
  11. return;
  12. }
  13. GameObject gameObject = GameObject.Find("_DanceMain_");
  14. NDebug.Assert(gameObject != null, "_DanceMain_ が見つかりませんでした。");
  15. this.m_DanceMain = gameObject.GetComponent<DanceMain>();
  16. NDebug.Assert(this.m_DanceMain != null, "DanceMain コンポーネントが見つかりませんでした。");
  17. this.m_nMaidNo = this.m_CharaNo - 1;
  18. int count = this.m_DanceMain.m_listDummyAnimChara.Count;
  19. NDebug.Assert(this.m_nMaidNo >= 0 && this.m_nMaidNo < count, string.Concat(new object[]
  20. {
  21. "キャラクター番号:",
  22. this.m_CharaNo,
  23. "は不正です。キャラクター番号は1~",
  24. count,
  25. "の間でなければいけません"
  26. }));
  27. this.m_goDummyBody = this.m_DanceMain.m_listDummyAnimChara[this.m_nMaidNo];
  28. }
  29. private void Start()
  30. {
  31. if (!Application.isPlaying)
  32. {
  33. return;
  34. }
  35. this.m_bDebug = this.m_DanceMain.m_boDebugDummyBody;
  36. if (!this.m_bDebug)
  37. {
  38. base.StartCoroutine(this.CoCharaLoadWait());
  39. }
  40. }
  41. private void OnDestroy()
  42. {
  43. if (this.m_trMaid)
  44. {
  45. this.m_trMaid.position = Vector3.zero;
  46. }
  47. }
  48. private IEnumerator CoCharaLoadWait()
  49. {
  50. Maid maid = null;
  51. while (maid == null)
  52. {
  53. maid = GameMain.Instance.CharacterMgr.GetMaid(this.m_nMaidNo);
  54. yield return null;
  55. }
  56. this.m_trMaid = maid.transform;
  57. yield break;
  58. }
  59. private void Update()
  60. {
  61. if (this.m_bDebug || !Application.isPlaying)
  62. {
  63. if (this.m_goDummyBody != null)
  64. {
  65. this.m_goDummyBody.transform.position = base.transform.position;
  66. }
  67. }
  68. else if (this.m_trMaid != null)
  69. {
  70. this.m_trMaid.position = base.transform.position;
  71. }
  72. }
  73. [SerializeField]
  74. [Header("移動させるキャラクターの番号")]
  75. private int m_CharaNo;
  76. private GameObject m_goDummyBody;
  77. private DanceMain m_DanceMain;
  78. private bool m_bDebug = true;
  79. private int m_nMaidNo;
  80. private Transform m_trMaid;
  81. }