コード例 #1
0
        public override void LoadFile(string sNewPath)
        {
            // save this path because it is super-annoying otherwise...
            SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;
            if (IsMeshFile(sNewPath))
            {
                FContext controller = ActiveCockpit.Context;

                // read mesh file
                SceneMeshImporter import = new SceneMeshImporter();
                bool bOK = import.ReadFile(sNewPath);
                if (bOK == false && import.LastReadResult.code != IOCode.Ok)
                {
                    Debug.Log("[Import] import failed: " + import.LastReadResult.message);
                    HUDUtil.ShowCenteredPopupMessage("Import Failed!", "Sorry, could not import " + sNewPath, ActiveCockpit);
                    return;
                }
                import.AppendReadMeshesToScene(controller.Scene, true);
                // save undo/redo checkpoint
                controller.Scene.History.PushInteractionCheckpoint();

                // once we have opened file, done with cockpit
                controller.PopCockpit(true);

                // emit this message after we pop cockpit
                if (import.SomeMeshesTooLargeForUnityWarning)
                {
                    Debug.Log("[Import] some meshes too large! ignored!");
                    MessageStream.Get.AddMessage(new Message()
                    {
                        Type = Message.Types.Warning, Code = FileBrowserMessageCodes.MESHES_TOO_LARGE
                    });
                }
            }
        }
コード例 #2
0
        public override void LoadFile(string sNewPath)
        {
            // save this path because it is super-annoying otherwise...
            SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;
            FContext controller = ActiveCockpit.Context;

            // read xml
            try {
                DebugUtil.Log(1, "Loading scene from path " + sNewPath);

                XmlDocument doc = new XmlDocument();
                doc.Load(sNewPath);
                XMLInputStream stream = new XMLInputStream()
                {
                    xml = doc
                };
                SceneSerializer serializer = new SceneSerializer();
                serializer.TargetFilePath = sNewPath;
                serializer.SOFactory      = new SOFactory();
                serializer.Restore(stream, ActiveCockpit.Scene);

                // once we have opened file, done with cockpit
                controller.PopCockpit(true);
            } catch (Exception e) {
                Debug.Log("[LoadScene] read failed: " + e.Message);
                HUDUtil.ShowCenteredPopupMessage("Load Failed!", "Sorry could not load scene " + sNewPath, ActiveCockpit);
            }
        }
コード例 #3
0
        public bool HandleShortcuts()
        {
            if (Input.GetKeyUp(KeyCode.Escape))
            {
                controller.PopCockpit(true);
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Return))
            {
                if (OnReturn != null)
                {
                    OnReturn();
                }
                return(true);
            }
            else if (Input.GetKeyDown(KeyCode.Backspace))
            {
                deleteTime = FPlatform.RealTime() + 0.5f;
                if (entryField.Text.Length > 0)
                {
                    entryField.Text = entryField.Text.Substring(0, entryField.Text.Length - 1);
                }
                return(true);
            }
            else if (Input.GetKey(KeyCode.Backspace))
            {
                if (entryField.Text.Length > 0 && FPlatform.RealTime() - deleteTime > 0.05f)
                {
                    entryField.Text = entryField.Text.Substring(0, entryField.Text.Length - 1);
                    deleteTime      = FPlatform.RealTime();
                }
                return(true);
            }
            else if (Input.GetKeyDown(KeyCode.V) && Input.GetKey(KeyCode.LeftControl))
            {
                //entryField.Text = "https://www.dropbox.com/s/momif47x1erb2fp/test_bunny.obj?raw=1";
                return(true);
            }
            else if (Input.anyKeyDown)
            {
                if (Input.inputString.Length > 0 && FileSystemUtils.IsValidFilenameString(Input.inputString))
                {
                    entryField.Text += Input.inputString;
                    return(true);
                }
            }

            return(false);
        }