using System; using System.Collections; using UnityEngine; using UnityEngine.UI; public class Day_UI : MonoBehaviour { public static void Day_UI_Start(Action action = null) { if (action != null) { Day_UI.m_End_Action = action; } if (Day_UI.UI_Obj) { UnityEngine.Object.Destroy(Day_UI.UI_Obj); } Day_UI.UI_Obj = Resources.Load(Day_UI.UI_Obj_Path); Day_UI.UI_Obj = UnityEngine.Object.Instantiate(Day_UI.UI_Obj); Day_UI.UI_Obj.GetComponent().Start_Set(); } private void Start_Set() { this.m_My_Rect = base.GetComponent(); this.m_My_Child = this.m_My_Rect.GetChild(0); Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); this.m_My_Child.GetComponent().text = maid.status.GetFlag("VRイベント日数").ToString() + "日目"; if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.NON) { base.GetComponent().renderMode = RenderMode.ScreenSpaceOverlay; this.m_My_Rect = this.m_My_Child.gameObject.GetComponent(); this.m_My_Child.GetComponent().fontSize = this.m_2D_Text; this.m_My_Rect.localPosition = Vector3.up * (float)(Screen.height + this.m_2D_Text / 2); this.m_Start_Pos = (this.m_Goal_Pos = this.m_My_Rect.localPosition); this.m_Goal_Pos.y = 0f; this.m_Down_Speed = (float)(Screen.height + this.m_2D_Text / 2); } else { Vector3 eulerAngles = GameMain.Instance.MainCamera.GetRealHeadTransform().eulerAngles; Vector3 a = GameMain.Instance.MainCamera.GetRealHeadTransform().TransformDirection(Vector3.forward); a.y = 0f; a.Normalize(); Vector3 position = GameMain.Instance.MainCamera.GetRealHeadTransform().position; this.m_My_Rect.eulerAngles = Vector3.up * eulerAngles.y; this.m_My_Child.GetComponent().fontSize = this.m_Text_Size; this.m_My_Rect.position = position + a * this.m_Forwordlength + Vector3.up * this.m_First_High; this.m_My_Child.GetComponent().localPosition = Vector3.down * this.m_Down_Length; this.m_Start_Pos = (this.m_Goal_Pos = this.m_My_Rect.position); this.m_Goal_Pos.y = position.y; this.m_Down_Speed = this.m_First_High; } base.StartCoroutine("UI_Animation"); } private IEnumerator UI_Animation() { float timer = 0f; for (;;) { timer += Time.deltaTime; float angle = 90f * (timer / this.m_Anime_Time); float rate = Mathf.Sin(0.017453292f * angle); this.m_My_Rect.localPosition = this.m_Start_Pos * (1f - rate) + this.m_Goal_Pos * rate; if (timer >= this.m_Anime_Time) { break; } yield return null; } GameMain.Instance.SoundMgr.PlaySe(this.m_Sound_Name, false); yield return new WaitForSeconds(this.m_Wait_Time); base.StartCoroutine("UI_Fade"); yield break; yield break; } private IEnumerator UI_Fade() { Text child_text = this.m_My_Child.GetComponent(); Color text_color = child_text.color; float timer = 0f; for (;;) { timer += Time.deltaTime; text_color.a = 1f - timer / this.m_Fade_Time; child_text.color = text_color; if (timer >= this.m_Fade_Time) { break; } yield return null; } if (Day_UI.m_End_Action != null) { Day_UI.m_End_Action(); } UnityEngine.Object.Destroy(base.gameObject); yield break; yield break; } private static string UI_Obj_Path = "Prefab/Day_Display_UI"; private static GameObject UI_Obj; [SerializeField] [Header("アニメーション時間")] private float m_Anime_Time = 1f; [SerializeField] [Header("アニメーションとフェードの間時間")] private float m_Wait_Time = 2f; [SerializeField] [Header("フェード時間")] private float m_Fade_Time = 0.5f; [SerializeField] [Header("UIとカメラの距離(前方向)")] private float m_Forwordlength = 1.7f; [SerializeField] [Header("UIの最初の高さ")] private float m_First_High = 3f; [SerializeField] private int m_Text_Size = 100; [SerializeField] private float m_Down_Length = 40f; [SerializeField] [Header("2Dモード時の文字サイズ")] private int m_2D_Text = 75; [SerializeField] [Header("SEファイル")] private string m_Sound_Name = "SE021.ogg"; private RectTransform m_My_Rect; private Transform m_My_Child; private float m_Down_Speed; private static Action m_End_Action; private Vector3 m_Start_Pos; private Vector3 m_Goal_Pos; }