示例#1
0
        private void LoadAnimClip(AnimationClip clip)
        {
            EditorPersistentData persistentData = EditorApplication.PersistentData;

            if (persistentData.dirtyAnimClips.TryGetValue(clip.UUID, out clipInfo))
            {
                // If an animation clip is imported, we don't care about it's cached curve values as they could have changed
                // since last modification, so we re-load the clip. But we persist the events as those can only be set
                // within the editor.
                if (clipInfo.isImported)
                {
                    EditorAnimClipInfo newClipInfo = EditorAnimClipInfo.Create(clip);
                    newClipInfo.events = clipInfo.events;
                }
            }
            else
            {
                clipInfo = EditorAnimClipInfo.Create(clip);
            }

            persistentData.dirtyAnimClips[clip.UUID] = clipInfo;

            foreach (var curve in clipInfo.curves)
            {
                guiFieldDisplay.AddField(new AnimFieldInfo(curve.Key, curve.Value, !clipInfo.isImported));
            }

            guiCurveEditor.Events           = clipInfo.events;
            guiCurveEditor.DisableCurveEdit = clipInfo.isImported;

            SetCurrentFrame(0);
            FPS = clipInfo.sampleRate;
        }
        /// <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;
            }
        }
示例#3
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(CutBinding, ButtonCode.X, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(CopyBinding, ButtonCode.C, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(PasteBinding, ButtonCode.V, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(DuplicateBinding, ButtonCode.D, ButtonModifier.Ctrl);
            inputConfig.RegisterButton(DeleteBinding, ButtonCode.Delete);
            inputConfig.RegisterButton(RenameBinding, ButtonCode.F2);

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