Ejemplo n.º 1
0
        /// <summary>
        /// Constructs a new editor application. Called at editor start-up by the runtime, and any time assembly refresh
        /// occurrs.
        /// </summary>
        internal EditorApplication()
        {
            instance    = this;
            codeManager = new ScriptCodeManager();

            const string soName = "EditorPersistentData";
            SceneObject  so     = Scene.Root.FindChild(soName);

            if (so == null)
            {
                so = new SceneObject(soName, true);
            }

            persistentData = so.GetComponent <EditorPersistentData>();
            if (persistentData == null)
            {
                persistentData = so.AddComponent <EditorPersistentData>();
            }

            // Register controls
            InputConfiguration inputConfig = VirtualInput.KeyConfig;

            inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.W);
            inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.S);
            inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.A);
            inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.D);
            inputConfig.RegisterButton(SceneCamera.MoveUpBinding, ButtonCode.E);
            inputConfig.RegisterButton(SceneCamera.MoveDownBinding, ButtonCode.Q);
            inputConfig.RegisterButton(SceneCamera.MoveForwardBinding, ButtonCode.Up);
            inputConfig.RegisterButton(SceneCamera.MoveBackBinding, ButtonCode.Down);
            inputConfig.RegisterButton(SceneCamera.MoveLeftBinding, ButtonCode.Left);
            inputConfig.RegisterButton(SceneCamera.MoveRightBinding, ButtonCode.Right);
            inputConfig.RegisterButton(SceneCamera.FastMoveBinding, ButtonCode.LeftShift);
            inputConfig.RegisterButton(SceneCamera.RotateBinding, ButtonCode.MouseRight);
            inputConfig.RegisterButton(SceneCamera.PanBinding, ButtonCode.MouseMiddle);
            inputConfig.RegisterAxis(SceneCamera.HorizontalAxisBinding, InputAxis.MouseX);
            inputConfig.RegisterAxis(SceneCamera.VerticalAxisBinding, InputAxis.MouseY);
            inputConfig.RegisterAxis(SceneCamera.ScrollAxisBinding, InputAxis.MouseZ);

            inputConfig.RegisterButton(SceneWindow.ToggleProfilerOverlayBinding, ButtonCode.P, ButtonModifier.CtrlAlt);
            inputConfig.RegisterButton(SceneWindow.ViewToolBinding, ButtonCode.Q);
            inputConfig.RegisterButton(SceneWindow.FrameBinding, ButtonCode.F);
            inputConfig.RegisterButton(SceneWindow.MoveToolBinding, ButtonCode.W);
            inputConfig.RegisterButton(SceneWindow.RotateToolBinding, ButtonCode.E);
            inputConfig.RegisterButton(SceneWindow.ScaleToolBinding, ButtonCode.R);
            inputConfig.RegisterButton(SceneWindow.DuplicateBinding, ButtonCode.D, ButtonModifier.Ctrl);

            if (IsProjectLoaded)
            {
                monitor             = new FolderMonitor(ProjectLibrary.ResourceFolder);
                monitor.OnAdded    += OnAssetModified;
                monitor.OnRemoved  += OnAssetModified;
                monitor.OnModified += OnAssetModified;
            }
        }