using System; using System.Collections; using I2.Loc; using Kasizuki; using UnityEngine; using UnityEngine.SceneManagement; using wf; public class ControllerShortcutWindow : MonoBehaviour { public float fadeSpeed { get { return this.m_FadeSpeed; } set { this.m_FadeSpeed = Mathf.Clamp(value, 0.001f, 1f); } } private bool IsEnableTypeVR() { GameMain instance = GameMain.Instance; if (!instance.VRMode) { return false; } GameMain.VRFamilyType vrfamily = instance.VRFamily; return vrfamily != GameMain.VRFamilyType.FOVE; } private void Awake() { if (!this.IsEnableTypeVR()) { Debug.Log("[ControllerShortcutWindow] ハンドコントローラが存在しない操作系だったので、UIを無効化します。"); base.gameObject.SetActive(false); } this.m_ButtonDic = new ObjectCacheDic(); } public void Init(PhotoFaceDataShortcutParent rightHandUI, PhotoFaceDataShortcutParent leftHandUI) { PhotoFaceDataShortcutSetter component = this.m_FadeWindowFaceShortcut.GetComponent(); component.Init(rightHandUI.handUI, leftHandUI.handUI); } private void Start() { UIWFTabButton uiwftabButton = this.m_ButtonDic.CacheChildObject(this.m_ParentButtonMainMenu.gameObject, "button config", "コンフィグ"); UIWFTabButton uiwftabButton2 = this.m_ButtonDic.CacheChildObject(this.m_ParentButtonMainMenu.gameObject, "button calibration", "キャリブレーション"); UIWFTabButton uiwftabButton3 = this.m_ButtonDic.CacheChildObject(this.m_ParentButtonMainMenu.gameObject, "button face", "表情"); UIWFTabButton uiwftabButton4 = this.m_ButtonDic.CacheChildObject(this.m_ParentButtonMainMenu.gameObject, "button hand", "ハンドサイン"); UIWFTabButton uiwftabButton5 = this.m_ButtonDic.CacheChildObject(this.m_ParentButtonMainMenu.gameObject, "button motion", "モーション"); UIWFTabButton uiwftabButton6 = this.m_ButtonDic.CacheChildObject(this.m_ParentButtonMainMenu.gameObject, "button general object", "一般オブジェクト"); uiwftabButton5.gameObject.SetActive(false); uiwftabButton4.gameObject.SetActive(false); Debug.Log("メインメニューのうち、モーション登録ボタンを隠します。"); this.m_ParentButtonMainMenu.GetComponent().Reposition(); EventDelegate.Add(uiwftabButton.onClick, new EventDelegate.Callback(this.OpenWindowConfig)); EventDelegate.Add(uiwftabButton2.onClick, new EventDelegate.Callback(this.OpenWindowCalibration)); EventDelegate.Add(uiwftabButton3.onClick, new EventDelegate.Callback(this.OpenWindowFaceShortcut)); EventDelegate.Add(uiwftabButton4.onClick, new EventDelegate.Callback(this.OpenWindowHandShortcut)); EventDelegate.Add(uiwftabButton5.onClick, new EventDelegate.Callback(this.OpenWindowMotionShortcut)); EventDelegate.Add(uiwftabButton6.onClick, new EventDelegate.Callback(this.OpenWindowGeneralObject)); this.m_FadeWindowHideButton = UTY.GetChildObject(this.m_FadeWindowParent.gameObject, "parent button/Button Hide", false).GetComponent(); EventDelegate.Add(this.m_FadeWindowHideButton.onClick, delegate() { this.m_FadeWindowParent.Close(0.25f, null); }); this.SetupCaribWindow(); this.m_ParentButtonMainMenu.Select(uiwftabButton2); uiwftabButton2.SetSelect(true); NGUIWindow fadeWindowParent = this.m_FadeWindowParent; fadeWindowParent.OnOpen = (Action)Delegate.Combine(fadeWindowParent.OnOpen, new Action(this.OnOpenFadeWindowParent)); this.ChangeLayout(); SceneManager.activeSceneChanged += this.OnActiveSceneChanged; } private void SetupCaribWindow() { this.m_FadeWindowCalibration.CacheChildObject("Window Start", "FadeWindow Start"); this.m_FadeWindowCalibration.CacheChildObject("Window Countdown", "FadeWindow Countdown"); this.m_FadeWindowCalibration.CacheChildObject("Window Countdown/label countdown", "countdown"); if (Product.supportMultiLanguage) { this.m_FadeWindowCalibration.CacheChildObject("Window Countdown/label description", "label count desc"); this.m_FadeWindowCalibration.CacheChildObject("Window Start/label", "label start desc"); } else { this.m_FadeWindowCalibration.CacheChildObject("Window Countdown/label description", "label count desc"); this.m_FadeWindowCalibration.CacheChildObject("Window Start/label", "label start desc"); } UIButton uibutton = this.m_FadeWindowCalibration.CacheChildObject("Window Start/button start", "startButton"); UIButton uibutton2 = this.m_FadeWindowCalibration.CacheChildObject("Window Start/button end", "endButton"); NGUIWindow fadeWindowCalibration = this.m_FadeWindowCalibration; fadeWindowCalibration.OnOpen = (Action)Delegate.Combine(fadeWindowCalibration.OnOpen, new Action(delegate() { NGUIWindow cache = this.m_FadeWindowCalibration.GetCache("FadeWindow Start"); NGUIWindow cache2 = this.m_FadeWindowCalibration.GetCache("FadeWindow Countdown"); cache.Open(0.001f, null); cache2.Close(0.001f, null); cache.gameObject.SetActive(true); cache2.gameObject.SetActive(false); this.ChangeLayout(); })); EventDelegate.Add(uibutton.onClick, new EventDelegate.Callback(this.OnClickCalibrationStart)); EventDelegate.Add(uibutton2.onClick, new EventDelegate.Callback(this.OnClickCalibrationEnd)); if (Product.supportMultiLanguage) { this.m_FadeWindowCalibration.GetCache("label count desc").SetTerm(ControllerShortcutWindow.STR_LABEL_DESC_COUNT_DOWN_TERMS); this.m_FadeWindowCalibration.GetCache("label start desc").GetComponent().supportEncoding = true; } else { this.m_FadeWindowCalibration.GetCache("label count desc").text = ControllerShortcutWindow.STR_LABEL_DESC_COUNT_DOWN; this.m_FadeWindowCalibration.GetCache("label start desc").supportEncoding = true; } } private void OnOpenFadeWindowParent() { this.ChangeLayout(); } private void ChangeLayout() { UILabel uilabel = null; Localize localize = null; if (Product.supportMultiLanguage) { localize = this.m_FadeWindowCalibration.GetCache("label start desc"); uilabel = localize.GetComponent(); } else { uilabel = this.m_FadeWindowCalibration.GetCache("label start desc"); } UIButton cache = this.m_FadeWindowCalibration.GetCache("startButton"); UIButton cache2 = this.m_FadeWindowCalibration.GetCache("endButton"); UIWFTabButton cache3 = this.m_ButtonDic.GetCache("表情"); UIWFTabButton cache4 = this.m_ButtonDic.GetCache("モーション"); UIWFTabButton cache5 = this.m_ButtonDic.GetCache("ハンドサイン"); UIWFTabButton cache6 = this.m_ButtonDic.GetCache("一般オブジェクト"); if (!OvrIK.IsVRIKMode) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0); if (maid == null || !maid.Visible || maid.IsBusy || !maid.body0.isLoadedBody) { uilabel.text = ControllerShortcutWindow.STR_LABEL_DESC_MISSING_MAID; Utility.SetLocalizeTerm(localize, ControllerShortcutWindow.STR_LABEL_DESC_MISSING_MAID_TERMS, false); cache.gameObject.SetActive(false); cache2.gameObject.SetActive(false); Debug.Log("OvrIK\u3000メイドの準備がまだ行われていません。"); } else { bool flag = false; try { string nowSceneName = GameMain.Instance.GetNowSceneName(); if (!string.IsNullOrEmpty(nowSceneName) && nowSceneName.IndexOf("SceneDance_") == 0) { DanceMain danceMain = UnityEngine.Object.FindObjectOfType(); if (danceMain != null && danceMain.OvrCamTrans != null) { flag = true; } } } catch { Debug.Log("シーン名の取得に失敗しました"); } if (!GameMain.Instance.CMSystem.SConfig.OvrIkAllSceneEnable && flag) { uilabel.text = ControllerShortcutWindow.STR_LABEL_DESC_NOT_SUPPORT_MOVE_CAMERA; Utility.SetLocalizeTerm(localize, ControllerShortcutWindow.STR_LABEL_DESC_NOT_SUPPORT_MOVE_CAMERA_TERMS, false); cache.gameObject.SetActive(false); cache2.gameObject.SetActive(false); } else { uilabel.text = ControllerShortcutWindow.STR_LABEL_DESC_START; Utility.SetLocalizeTerm(localize, ControllerShortcutWindow.STR_LABEL_DESC_START_TERMS, false); cache.gameObject.SetActive(true); cache2.gameObject.SetActive(false); if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.VIVE && ControllerShortcutSettingData.config.use1TrackerForHead) { UILabel uilabel2 = uilabel; uilabel2.text = uilabel2.text + "\n" + ControllerShortcutWindow.STR_LABEL_DESC_START_NOTES_TRACKER; Utility.SetLocalizeTerm(localize, ControllerShortcutWindow.STR_LABEL_DESC_START_NOTES_TRACKER_TERMS, false); } } } cache3.isEnabled = false; cache4.isEnabled = false; cache5.isEnabled = false; cache6.isEnabled = false; } else { uilabel.text = ControllerShortcutWindow.STR_LABEL_DESC_END; Utility.SetLocalizeTerm(localize, ControllerShortcutWindow.STR_LABEL_DESC_END_TERMS, false); cache.gameObject.SetActive(false); cache2.gameObject.SetActive(true); cache3.isEnabled = true; cache4.isEnabled = true; cache5.isEnabled = true; cache6.isEnabled = true; } } private void OpenWindowConfig() { this.m_FadeWindowCalibration.Close(this.fadeSpeed, null); this.m_FadeWindowFaceShortcut.Close(this.fadeSpeed, null); this.m_FadeWindowMotionShortcut.Close(this.fadeSpeed, null); this.m_FadeWindowGeneralObject.Close(this.fadeSpeed, null); this.WaitTime(this.fadeSpeed, delegate { this.m_FadeWindowConfig.Open(this.fadeSpeed, null); }); } private void OpenWindowCalibration() { this.m_FadeWindowFaceShortcut.Close(this.fadeSpeed, null); this.m_FadeWindowMotionShortcut.Close(this.fadeSpeed, null); this.m_FadeWindowConfig.Close(this.fadeSpeed, null); this.m_FadeWindowGeneralObject.Close(this.fadeSpeed, null); this.WaitTime(this.fadeSpeed, delegate { this.m_FadeWindowCalibration.Open(this.fadeSpeed, null); }); } private void OpenWindowFaceShortcut() { this.m_FadeWindowCalibration.Close(this.fadeSpeed, null); this.m_FadeWindowMotionShortcut.Close(this.fadeSpeed, null); this.m_FadeWindowConfig.Close(this.fadeSpeed, null); this.m_FadeWindowGeneralObject.Close(this.fadeSpeed, null); this.WaitTime(this.fadeSpeed, delegate { this.m_FadeWindowFaceShortcut.Open(this.fadeSpeed, null); }); } private void OpenWindowHandShortcut() { } private void OpenWindowMotionShortcut() { this.m_FadeWindowCalibration.Close(this.fadeSpeed, null); this.m_FadeWindowFaceShortcut.Close(this.fadeSpeed, null); this.m_FadeWindowConfig.Close(this.fadeSpeed, null); this.m_FadeWindowGeneralObject.Close(this.fadeSpeed, null); this.WaitTime(this.fadeSpeed, delegate { this.m_FadeWindowMotionShortcut.Open(this.fadeSpeed, null); }); } private void OpenWindowGeneralObject() { this.m_FadeWindowCalibration.Close(this.fadeSpeed, null); this.m_FadeWindowFaceShortcut.Close(this.fadeSpeed, null); this.m_FadeWindowConfig.Close(this.fadeSpeed, null); this.m_FadeWindowMotionShortcut.Close(this.fadeSpeed, null); this.WaitTime(this.fadeSpeed, delegate { this.m_FadeWindowGeneralObject.Open(this.fadeSpeed, null); }); } private void OnClickCalibrationStart() { NGUIWindow cache = this.m_FadeWindowCalibration.GetCache("FadeWindow Start"); NGUIWindow windowCount = this.m_FadeWindowCalibration.GetCache("FadeWindow Countdown"); this.m_FadeWindowCalibration.GetCache("countdown").text = 5.ToString("f2"); cache.Close(this.fadeSpeed, null); this.m_FadeWindowMainMenu.Close(this.fadeSpeed, null); this.WaitTime(this.fadeSpeed, delegate { windowCount.Open(this.fadeSpeed, null); }); this.WaitTime(this.fadeSpeed + 1f, delegate { if (!OvrIK.IsVRIKMode) { OvrIK.InitStart(); } this.StartCoroutine(this.CoCalibrationCountdown(delegate { this.m_FadeWindowCalibration.GetCache("FadeWindow Countdown").Close(this.fadeSpeed, null); this.WaitTime(this.fadeSpeed, delegate { this.m_FadeWindowCalibration.GetCache("FadeWindow Start").Open(this.fadeSpeed, null); this.m_FadeWindowMainMenu.Open(this.fadeSpeed, null); this.ChangeLayout(); }); })); }); } private void OnClickCalibrationEnd() { this.m_FadeWindowParent.Close(this.fadeSpeed, delegate { if (OvrIK.IsVRIKMode) { OvrIK.UninitEnd(); } }); } private IEnumerator CoCalibrationCountdown(Action onEnd) { Debug.Log("キャリブレーション開始"); float nowTime = 0f; float maxTime = 5f; UILabel textCountdown = this.m_FadeWindowCalibration.GetCache("countdown"); while (nowTime <= maxTime) { textCountdown.text = (maxTime - nowTime).ToString("f2"); nowTime += Time.deltaTime; yield return null; } textCountdown.text = 0.ToString("f2"); if (onEnd != null) { onEnd(); } Debug.Log("キャリブレーション完了"); yield break; } private void WaitTime(float time, Action onFinish) { base.StartCoroutine(this.CoWaitTime(time, onFinish)); } private IEnumerator CoWaitTime(float time, Action onFinish) { yield return new WaitForSeconds(time); if (onFinish != null) { onFinish(); } yield break; } public void Open() { this.m_FadeWindowParent.Open(this.fadeSpeed, null); } public void Close() { this.m_FadeWindowParent.Close(this.fadeSpeed, null); } public bool isOpen { get { return this.m_FadeWindowParent.gameObject.activeSelf; } } private void OnActiveSceneChanged(Scene beforeScene, Scene activeScene) { if (this.m_IsDestroyed) { return; } UnityEngine.Object.Destroy(base.gameObject); Debug.Log("VRIK用UIを削除しました : シーン切り替え"); } private void OnDestroy() { this.m_IsDestroyed = true; } [SerializeField] [Range(0.001f, 1f)] private float m_FadeSpeed = 0.25f; [SerializeField] private NGUIWindow m_FadeWindowFaceShortcut; [SerializeField] private NGUIWindow m_FadeWindowMotionShortcut; [SerializeField] private NGUIWindow m_FadeWindowCalibration; [SerializeField] private NGUIWindow m_FadeWindowConfig; [SerializeField] private NGUIWindow m_FadeWindowGeneralObject; [SerializeField] private NGUIWindow m_FadeWindowMainMenu; [SerializeField] private NGUIWindow m_FadeWindowParent; private UIButton m_FadeWindowHideButton; [SerializeField] private UIWFTabPanel m_ParentButtonMainMenu; private ObjectCacheDic m_ButtonDic; private static readonly string STR_LABEL_DESC_MISSING_MAID_TERMS = "VAS/センターテキスト/キャリブレーション開始"; private static readonly string STR_LABEL_DESC_NOT_SUPPORT_MOVE_CAMERA_TERMS = "VAS/センターテキスト/センターテキスト/移動カメラエラー"; private static readonly string STR_LABEL_DESC_START_TERMS = "VAS/センターテキスト/キャリブレーション開始"; private static readonly string STR_LABEL_DESC_START_NOTES_TRACKER_TERMS = "VAS/センターテキスト/キャリブレーション開始+注意"; private static readonly string STR_LABEL_DESC_COUNT_DOWN_TERMS = "VAS/センターテキスト/カウントダウン注意"; private static readonly string STR_LABEL_DESC_END_TERMS = "VAS/センターテキスト/終了文"; private static readonly string STR_LABEL_DESC_MISSING_MAID = "メイドの準備ができていません。"; private static readonly string STR_LABEL_DESC_NOT_SUPPORT_MOVE_CAMERA = "移動カメラモードでは実行できません。"; private static readonly string STR_LABEL_DESC_START = "「スタート」ボタンを押して、キャリブレーションを開始します。\r\n\r\nキャリブレーション中は、\r\nHDMを装着して、正面を向いて足を肩幅に開いて直立し、\r\nコントローラを持った手を肩幅で胸の前に出してお待ち下さい。"; private static readonly string STR_LABEL_DESC_START_NOTES_TRACKER = "[FF8000]HMDを顔に装着した状態で、\r\n頭のトラッカーを装着予定位置に固定して下さい。[-]"; private static readonly string STR_LABEL_DESC_COUNT_DOWN = "手を前に出し、\r\n足を肩幅に広げ、\r\n正面を向いて、\r\n背筋を伸ばして下さい。\r\n"; private static readonly string STR_LABEL_DESC_END = "バーチャルアバタースタジオ機能を終了します。\r\n\r\n(終了後にキャラクターに不具合がある場合は\r\n\u3000シーンに入り直して下さい。)"; private bool m_IsDestroyed; }