예제 #1
0
        private void OnDiffRevert(CustomEditor editor)
        {
            // Special case for removed Script from actor
            if (editor is RemovedScriptDummy removed)
            {
                Editor.Log("Reverting removed script changes to prefab (adding it)");

                var actor          = (Actor)Values[0];
                var restored       = actor.AddScript(removed.PrefabObject.GetType());
                var prefabId       = actor.PrefabID;
                var prefabObjectId = restored.PrefabObjectID;
                Script.Internal_LinkPrefab(restored.unmanagedPtr, ref prefabId, ref prefabObjectId);
                string data = JsonSerializer.Serialize(removed.PrefabObject);
                JsonSerializer.Deserialize(restored, data);

                var action = AddRemoveScript.Added(restored);
                Presenter.Undo?.AddAction(action);

                return;
            }

            // Special case for new Script added to actor
            if (editor.Values[0] is Script script && !script.HasPrefabLink)
            {
                Editor.Log("Reverting added script changes to prefab (removing it)");

                var action = AddRemoveScript.Remove(script);
                action.Do();
                Presenter.Undo?.AddAction(action);

                return;
            }

            editor.RevertToReferenceValue();
        }
예제 #2
0
        private void OnClickRemove(ContextMenuButton button)
        {
            var script = (Script)button.ParentContextMenu.Tag;
            var action = AddRemoveScript.Remove(script);

            action.Do();
            Presenter.Undo?.AddAction(action);
        }
예제 #3
0
        private void OnClickRemove(ContextMenuButton button)
        {
            var script = (Script)button.ParentContextMenu.Tag;
            var action = AddRemoveScript.Remove(script);

            action.Do();
            Editor.Instance.Undo.AddAction(action);
        }
예제 #4
0
            private void SettingsMenuOnButtonClicked(int id, ContextMenu contextMenu)
            {
                var script = (Script)contextMenu.Tag;

                switch (id)
                {
                // Reset
                case 0:
                {
                    throw new NotImplementedException("Reset script");
                    break;
                }

                // Remove
                case 1:
                {
                    var action = AddRemoveScript.Remove(script);
                    action.Do();
                    Editor.Instance.Undo.AddAction(action);
                    break;
                }

                // Move up
                case 2:
                {
                    var action = ChangeScriptAction.ChangeOrder(script, script.OrderInParent - 1);
                    action.Do();
                    Editor.Instance.Undo.AddAction(action);
                    break;
                }

                // Move down
                case 3:
                {
                    var action = ChangeScriptAction.ChangeOrder(script, script.OrderInParent + 1);
                    action.Do();
                    Editor.Instance.Undo.AddAction(action);
                    break;
                }

                // Edit script
                case 4:
                {
                    var item = Editor.Instance.ContentDatabase.FindScriptWitScriptName(script);
                    if (item != null)
                    {
                        Editor.Instance.ContentEditing.Open(item);
                    }
                    break;
                }

                // Show in content window
                case 5:
                {
                    var item = Editor.Instance.ContentDatabase.FindScriptWitScriptName(script);
                    if (item != null)
                    {
                        Editor.Instance.Windows.ContentWin.Select(item);
                    }
                    break;
                }
                }
            }