コード例 #1
0
        private static IEnumerator ExtractResourceFile()
        {
            TtuiUtils.GetPage <StartPage>().SetStartButtonEnable(false);
            TTUIPage.ShowPage <LoadingTip>();
            TtuiUtils.GetPage <LoadingTip>().SetText("第一次运行解压中...");
            var textAsset = Resources.Load("LocalFiles/DefaultResource") as TextAsset;

            if (textAsset != null)
            {
                var bytes             = textAsset.bytes;
                var tempFilePath      = Application.temporaryCachePath + "/MikuMikuARTemp.zip";
                var appDataPath       = Paths.Getter().Home();
                var extractDataThread = new Thread(() =>
                {
                    Directory.CreateDirectory(appDataPath);
                    FileUtils.ExtractZipBytesToFolder(appDataPath, bytes, tempFilePath);
                });
                extractDataThread.Start();
                while (extractDataThread.IsAlive)
                {
                    yield return(null);
                }
            }
            else
            {
                Directory.CreateDirectory(Paths.Getter().Home());
                Debug.Log("No resource file under LocalFiles/DefaultResource. Skip extracting.");
            }

            TTUIPage.ClosePage <LoadingTip>();
            TtuiUtils.GetPage <StartPage>().SetStartButtonEnable(true);
        }
コード例 #2
0
ファイル: MmdStagePanel.cs プロジェクト: ttoyou/MikuMikuXR
 private static void ShowAddModelFailTip()
 {
     TtuiUtils.ShowPageAfterLoadingUI <OkDialog>(MainSceneController.Instance,
                                                 new OkDialog.Context
     {
         Title = "提示",
         Tip   = "载入模型失败。请确认模型存在且为正确的MikuMikuDance模型。"
     });
 }
コード例 #3
0
ファイル: LoadSceneDialog.cs プロジェクト: x3bits/MikuMikuXR
        private List <object> ConvertDataForUi()
        {
            var sceneNames = MainSceneController.Instance.ListScenes();

            return(sceneNames.Select((sceneName, i) => new SceneListItemData
            {
                Name = sceneName.Replace(' ', '\u00A0'),
                OnClick = () =>
                {
                    ClosePage();
                    try
                    {
                        TtuiUtils.RunWithLoadingUI <LoadingDialog>(MainSceneController.Instance, () =>
                        {
                            try
                            {
                                MainSceneController.Instance.LoadScene(sceneName);
                            }
                            catch (Exception e)
                            {
                                Debug.LogException(e);
                            }
                        });
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                },
                OnDelete = () =>
                {
                    ShowPage <OkCancelDialog>(new OkCancelDialog.Context
                    {
                        Title = "确认删除",
                        Tip = "确认要删除吗?",
                        OnOk = () =>
                        {
                            try
                            {
                                MainSceneController.Instance.DeleteScene(sceneName);
                                _modelListView.SetData(ConvertDataForUi());
                            } catch (Exception e)
                            {
                                Debug.LogException(e);
                            }
                        },
                        OnCancel = () => { }
                    });
                }
            })
                   .Cast <object>()
                   .ToList());
        }
コード例 #4
0
ファイル: MmdStagePanel.cs プロジェクト: ttoyou/MikuMikuXR
        public override void Awake(GameObject go)
        {
            _cameraFilePanel         = transform.Find("MmdCamera").gameObject;
            _arUserDefinedPanel      = transform.Find("ArUserDefined").gameObject;
            _arUserDefinedInitPanel  = transform.Find("ArUserDefined/Init").gameObject;
            _arUserDefinedResetPanel = transform.Find("ArUserDefined/Reset").gameObject;
            MainSceneController.Instance.OnXrTypeChanged.AddListener(xrType =>
            {
                _cameraFilePanel.SetActive(xrType == XrType.CameraFile);
                _arUserDefinedPanel.SetActive(xrType == XrType.ArUserDefined);
                if (xrType == XrType.ArUserDefined)
                {
                    _arUserDefinedInitPanel.SetActive(true);
                    _arUserDefinedResetPanel.SetActive(false);
                }
            });

            SetButtonListener("Functions/BtnAddModel", () =>
            {
                ShowPage <MmdFileSelector>(new MmdFileSelector.Context
                {
                    Type         = MmdFileSelector.FileType.Model,
                    Title        = "添加模型",
                    OnFileSelect = filePath =>
                    {
                        TtuiUtils.RunWithLoadingUI <LoadingDialog>(MainSceneController.Instance, () =>
                        {
                            try
                            {
                                if (!MainSceneController.Instance.AddModel(filePath))
                                {
                                    ShowAddModelFailTip();
                                    return;
                                }
                            }
                            catch (Exception e)
                            {
                                Debug.LogException(e);
                                ShowAddModelFailTip();
                                return;
                            }
                            ShowPage <MmdModelPanel>();
                        });
                    }
                });
                OnceTipPage.ShowOnceTip(TipNames.ExportCustomMmdFiles);
            });
            SetButtonListener("Functions/BtnSelectModel", () =>
            {
                if (MainSceneController.Instance.GetModelCount() > 0)
                {
                    ShowPage <MmdModelSelectPanel>();
                }
            });
            SetButtonListener("Functions/BtnSelectMusic", () =>
            {
                ShowPage <MmdFileSelector>(new MmdFileSelector.Context
                {
                    Type         = MmdFileSelector.FileType.Music,
                    Title        = "选择音乐",
                    OnFileSelect = filePath =>
                    {
                        TtuiUtils.RunWithLoadingUI <LoadingDialog>(MainSceneController.Instance,
                                                                   () =>
                        {
                            try
                            {
                                MainSceneController.Instance.ChangeMusic(filePath);
                            }
                            catch (Exception e)
                            {
                                Debug.LogException(e);
                            }
                        });
                    }
                });
                OnceTipPage.ShowOnceTip(TipNames.ExportCustomMmdFiles);
            });
            SetButtonListener("Functions/BtnPlay", () =>
            {
                if (MainSceneController.Instance.GetXrType().Equals(XrType.VrGlass))
                {
                    ShowPage <VrCountdownPage>();
                }
                else
                {
                    MainSceneController.Instance.SwitchPlayPause(true);
                }
            });
            SetButtonListener("Functions/BtnXR", ShowPage <XrSelecror>);
            SetButtonListener("Bottom/BtnQuit", ShowPage <ConfirmReturnTitlePage>);
            SetButtonListener("Bottom/BtnSave", ShowPage <SaveSceneDialog>);
            SetButtonListener("Bottom/BtnLoad", ShowPage <LoadSceneDilog>);
            SetButtonListener("MmdCamera/BtnSelectCamera", () =>
            {
                ShowPage <MmdFileSelector>(new MmdFileSelector.Context
                {
                    Type         = MmdFileSelector.FileType.Motion,
                    Title        = "相机数据",
                    OnFileSelect = filePath =>
                    {
                        TtuiUtils.RunWithLoadingUI <LoadingDialog>(MainSceneController.Instance, () =>
                        {
                            try
                            {
                                var xrController         = MainSceneController.Instance.GetXrController();
                                var cameraFileController = xrController as CameraFileController;
                                if (cameraFileController == null)
                                {
                                    return;
                                }
                                MainSceneController.Instance.SwitchPlayPause(false);
                                MainSceneController.Instance.ResetAll();
                                MainSceneController.Instance.CameraFilePath = filePath;
                                if (!cameraFileController.CameraObject.LoadCameraMotion(filePath))
                                {
                                    TtuiUtils.ShowPageAfterLoadingUI <OkDialog>(MainSceneController.Instance,
                                                                                new OkDialog.Context
                                    {
                                        Tip   = "载入的文件中不含镜头数据。",
                                        Title = "提示"
                                    });
                                }
                            }
                            catch (Exception e)
                            {
                                Debug.LogException(e);
                                TtuiUtils.ShowPageAfterLoadingUI <OkDialog>(MainSceneController.Instance,
                                                                            new OkDialog.Context
                                {
                                    Tip   = "载入镜头数据失败。",
                                    Title = "提示"
                                });
                            }
                        });
                    }
                });
                OnceTipPage.ShowOnceTip(TipNames.ExportCustomMmdFiles);
            });
            SetButtonListener("ArUserDefined/Init/BtnStartAR", () =>
            {
                var arController = MainSceneController.Instance.GetXrController() as ArUserDefinedController;
                if (arController == null)
                {
                    return;
                }
                _arUserDefinedInitPanel.SetActive(false);
                _arUserDefinedResetPanel.SetActive(true);
            });
            SetButtonListener("ArUserDefined/Reset/BtnResetAR", () =>
            {
                var arController = MainSceneController.Instance.GetXrController() as ArUserDefinedController;
                if (arController == null)
                {
                    return;
                }
                _arUserDefinedInitPanel.SetActive(true);
                _arUserDefinedResetPanel.SetActive(false);
            });
        }
コード例 #5
0
 public override void Awake(GameObject go)
 {
     _inputField = transform.Find("Content/InputField").gameObject.GetComponent <InputField>();
     SetButtonListener("Bottom/BtnClose", ClosePage);
     SetButtonListener("Bottom/BtnOK", () =>
     {
         var fileName = _inputField.text;
         Directory.CreateDirectory(Paths.Getter().BonePoseFolder());
         var context  = (Context)data;
         var savePath = Paths.Getter().BonePoseFolder() + "/" + fileName + Constants.BonePoseFileExt;
         ClosePage();
         if (File.Exists(savePath))
         {
             ShowPage <OkCancelDialog>(new OkCancelDialog.Context
             {
                 Title = "确认保存",
                 Tip   = "文件已存在,要覆盖吗?",
                 OnOk  = () =>
                 {
                     OpenCalculatingDialog(context, savePath);
                 },
                 OnCancel = () => { }
             });
         }
         else
         {
             OpenCalculatingDialog(context, savePath);
         }
     });
     SetButtonListener("Bottom/BtnLoad", () =>
     {
         ClosePage();
         ShowPage <MmdFileSelector>(new MmdFileSelector.Context
         {
             Type         = MmdFileSelector.FileType.BonePose,
             Title        = "物理计算",
             OnFileSelect = filePath =>
             {
                 TtuiUtils.RunWithLoadingUI <LoadingDialog>(MainSceneController.Instance, () =>
                 {
                     try
                     {
                         MainSceneController.Instance.ChangeCurrentBonePoseFile(filePath);
                     }
                     catch (BonePoseNotSuitableException e)
                     {
                         TtuiUtils.ShowPageAfterLoadingUI <OkDialog>(MainSceneController.Instance,
                                                                     new OkDialog.Context
                         {
                             Title = "提示",
                             Tip   = "载入的物理计算结果不适用于当前模型"
                         });
                     }
                     catch (Exception e)
                     {
                         Debug.LogException(e);
                     }
                 });
             }
         });
     });
 }
コード例 #6
0
ファイル: MmdModelPanel.cs プロジェクト: x3bits/MikuMikuXR
 public override void Awake(GameObject go)
 {
     SetButtonListener("BtnSelectMotion", () =>
     {
         ShowPage <MmdFileSelector>(new MmdFileSelector.Context
         {
             Type         = MmdFileSelector.FileType.Motion,
             Title        = "选择动作",
             OnFileSelect = filePath =>
             {
                 TtuiUtils.RunWithLoadingUI <LoadingDialog>(MainSceneController.Instance, () =>
                 {
                     try
                     {
                         MainSceneController.Instance.ChangeCurrentMotion(filePath);
                     }
                     catch (Exception e)
                     {
                         Debug.LogException(e);
                     }
                 });
             }
         });
         OnceTipPage.ShowOnceTip(TipNames.ExportCustomMmdFiles);
     });
     SetButtonListener("BtnSelectModel", () =>
     {
         ShowPage <MmdFileSelector>(new MmdFileSelector.Context
         {
             Type         = MmdFileSelector.FileType.Model,
             Title        = "替换模型",
             OnFileSelect = filePath =>
             {
                 TtuiUtils.RunWithLoadingUI <LoadingDialog>(MainSceneController.Instance, () =>
                 {
                     try
                     {
                         MainSceneController.Instance.ChangeCurrentModel(filePath);
                     }
                     catch (Exception e)
                     {
                         Debug.LogException(e);
                     }
                 });
             }
         });
         OnceTipPage.ShowOnceTip(TipNames.ExportCustomMmdFiles);
     });
     SetButtonListener("BtnPosition", ShowPage <MmdModelTransform>);
     SetButtonListener("BtnDelete", () => { MainSceneController.Instance.DeleteCurrentModel(); });
     SetButtonListener("BtnBack", ClosePage);
     SetButtonListener("BtnBonePoseCalculate", () =>
     {
         var modelPath  = MainSceneController.Instance.GetCurrentModelPath();
         var motionPath = MainSceneController.Instance.GetCurrentMotionPath();
         if (string.IsNullOrEmpty(modelPath))
         {
             return;
         }
         if (string.IsNullOrEmpty(motionPath))
         {
             ShowPage <OkDialog>(new OkDialog.Context
             {
                 Title = "提示",
                 Tip   = "还没有选择动作。"
             });
             return;
         }
         ShowPage <PhysicsCalculateSave>(new PhysicsCalculateSave.Context
         {
             ModelPath       = modelPath,
             MotionPath      = motionPath,
             DefaultFileName = GenerateDefaultBonePoseFileName(modelPath, motionPath)
         });
     });
 }