123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- 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<PhotoFaceDataShortcutSetter>();
- component.Init(rightHandUI.handUI, leftHandUI.handUI);
- }
- private void Start()
- {
- UIWFTabButton uiwftabButton = this.m_ButtonDic.CacheChildObject<UIWFTabButton>(this.m_ParentButtonMainMenu.gameObject, "button config", "コンフィグ");
- UIWFTabButton uiwftabButton2 = this.m_ButtonDic.CacheChildObject<UIWFTabButton>(this.m_ParentButtonMainMenu.gameObject, "button calibration", "キャリブレーション");
- UIWFTabButton uiwftabButton3 = this.m_ButtonDic.CacheChildObject<UIWFTabButton>(this.m_ParentButtonMainMenu.gameObject, "button face", "表情");
- UIWFTabButton uiwftabButton4 = this.m_ButtonDic.CacheChildObject<UIWFTabButton>(this.m_ParentButtonMainMenu.gameObject, "button hand", "ハンドサイン");
- UIWFTabButton uiwftabButton5 = this.m_ButtonDic.CacheChildObject<UIWFTabButton>(this.m_ParentButtonMainMenu.gameObject, "button motion", "モーション");
- UIWFTabButton uiwftabButton6 = this.m_ButtonDic.CacheChildObject<UIWFTabButton>(this.m_ParentButtonMainMenu.gameObject, "button general object", "一般オブジェクト");
- uiwftabButton5.gameObject.SetActive(false);
- uiwftabButton4.gameObject.SetActive(false);
- Debug.Log("メインメニューのうち、モーション登録ボタンを隠します。");
- this.m_ParentButtonMainMenu.GetComponent<UIGrid>().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<UIButton>();
- 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<NGUIWindow>("Window Start", "FadeWindow Start");
- this.m_FadeWindowCalibration.CacheChildObject<NGUIWindow>("Window Countdown", "FadeWindow Countdown");
- this.m_FadeWindowCalibration.CacheChildObject<UILabel>("Window Countdown/label countdown", "countdown");
- if (Product.SPP)
- {
- this.m_FadeWindowCalibration.CacheChildObject<Localize>("Window Countdown/label description", "label count desc");
- this.m_FadeWindowCalibration.CacheChildObject<Localize>("Window Start/label", "label start desc");
- }
- else
- {
- this.m_FadeWindowCalibration.CacheChildObject<UILabel>("Window Countdown/label description", "label count desc");
- this.m_FadeWindowCalibration.CacheChildObject<UILabel>("Window Start/label", "label start desc");
- }
- UIButton uibutton = this.m_FadeWindowCalibration.CacheChildObject<UIButton>("Window Start/button start", "startButton");
- UIButton uibutton2 = this.m_FadeWindowCalibration.CacheChildObject<UIButton>("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<NGUIWindow>("FadeWindow Start");
- NGUIWindow cache2 = this.m_FadeWindowCalibration.GetCache<NGUIWindow>("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.SPP)
- {
- this.m_FadeWindowCalibration.GetCache<Localize>("label count desc").SetTerm(ControllerShortcutWindow.STR_LABEL_DESC_COUNT_DOWN_TERMS);
- this.m_FadeWindowCalibration.GetCache<Localize>("label start desc").GetComponent<UILabel>().supportEncoding = true;
- }
- else
- {
- this.m_FadeWindowCalibration.GetCache<UILabel>("label count desc").text = ControllerShortcutWindow.STR_LABEL_DESC_COUNT_DOWN;
- this.m_FadeWindowCalibration.GetCache<UILabel>("label start desc").supportEncoding = true;
- }
- }
- private void OnOpenFadeWindowParent()
- {
- this.ChangeLayout();
- }
- private void ChangeLayout()
- {
- UILabel uilabel = null;
- Localize localize = null;
- if (Product.SPP)
- {
- localize = this.m_FadeWindowCalibration.GetCache<Localize>("label start desc");
- uilabel = localize.GetComponent<UILabel>();
- }
- else
- {
- uilabel = this.m_FadeWindowCalibration.GetCache<UILabel>("label start desc");
- }
- UIButton cache = this.m_FadeWindowCalibration.GetCache<UIButton>("startButton");
- UIButton cache2 = this.m_FadeWindowCalibration.GetCache<UIButton>("endButton");
- UIWFTabButton cache3 = this.m_ButtonDic.GetCache<UIWFTabButton>("表情");
- UIWFTabButton cache4 = this.m_ButtonDic.GetCache<UIWFTabButton>("モーション");
- UIWFTabButton cache5 = this.m_ButtonDic.GetCache<UIWFTabButton>("ハンドサイン");
- UIWFTabButton cache6 = this.m_ButtonDic.GetCache<UIWFTabButton>("一般オブジェクト");
- 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);
- 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<DanceMain>();
- 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);
- 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);
- 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);
- }
- }
- }
- 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);
- 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<NGUIWindow>("FadeWindow Start");
- NGUIWindow windowCount = this.m_FadeWindowCalibration.GetCache<NGUIWindow>("FadeWindow Countdown");
- this.m_FadeWindowCalibration.GetCache<UILabel>("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<NGUIWindow>("FadeWindow Countdown").Close(this.fadeSpeed, null);
- this.WaitTime(this.fadeSpeed, delegate
- {
- this.m_FadeWindowCalibration.GetCache<NGUIWindow>("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<UILabel>("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;
- }
|