using System; using System.Collections; using UnityEngine; [ExecuteInEditMode] public class CharaDumper : MonoBehaviour { private void Awake() { if (!Application.isPlaying) { return; } GameObject gameObject = GameObject.Find("_DanceMain_"); NDebug.Assert(gameObject != null, "_DanceMain_ が見つかりませんでした。"); this.m_DanceMain = gameObject.GetComponent(); NDebug.Assert(this.m_DanceMain != null, "DanceMain コンポーネントが見つかりませんでした。"); this.m_nMaidNo = this.m_CharaNo - 1; int count = this.m_DanceMain.m_listDummyAnimChara.Count; NDebug.Assert(this.m_nMaidNo >= 0 && this.m_nMaidNo < count, string.Concat(new object[] { "キャラクター番号:", this.m_CharaNo, "は不正です。キャラクター番号は1~", count, "の間でなければいけません" })); this.m_goDummyBody = this.m_DanceMain.m_listDummyAnimChara[this.m_nMaidNo]; } private void Start() { if (!Application.isPlaying) { return; } this.m_bDebug = this.m_DanceMain.m_boDebugDummyBody; if (!this.m_bDebug) { base.StartCoroutine(this.CoCharaLoadWait()); } } private void OnDestroy() { if (this.m_trMaid) { this.m_trMaid.position = Vector3.zero; } } private IEnumerator CoCharaLoadWait() { Maid maid = null; while (maid == null) { maid = GameMain.Instance.CharacterMgr.GetMaid(this.m_nMaidNo); yield return null; } this.m_trMaid = maid.transform; yield break; } private void Update() { if (this.m_bDebug || !Application.isPlaying) { if (this.m_goDummyBody != null) { this.m_goDummyBody.transform.position = base.transform.position; } } else if (this.m_trMaid != null) { this.m_trMaid.position = base.transform.position; } } [SerializeField] [Header("移動させるキャラクターの番号")] private int m_CharaNo; private GameObject m_goDummyBody; private DanceMain m_DanceMain; private bool m_bDebug = true; private int m_nMaidNo; private Transform m_trMaid; }