Exemple #1
0
        static void OnFocusOut(this IRenamable renamable, FocusOutEvent evt)
        {
            VseWindow window = renamable.TitleElement.GetFirstAncestorOfType <VseGraphView>()?.window;

            if (window != null)
            {
                window.RefreshUIDisabled = false;
            }

            renamable.TitleEditor.UnregisterCallback <FocusEvent>(renamable.OnFocus);
            renamable.TitleEditor.UnregisterCallback <FocusOutEvent>(renamable.OnFocusOut);
            renamable.TitleEditor.Q(TextInputBaseField <string> .textInputUssName).UnregisterCallback <KeyDownEvent>(OnKeyPressed);

            // ReSharper disable once DelegateSubtraction
            Undo.undoRedoPerformed -= renamable.UndoRedoPerformed;

            renamable.TitleEditor.RemoveFromHierarchy();

            if (!renamable.EditTitleCancelled)
            {
                if (renamable.TitleEditor is TextField textField && renamable.TitleValue != textField.text)
                {
                    renamable.Store.Dispatch(new RenameElementAction((IRenamableModel)renamable.GraphElementModel, textField.text));
                }
            }
            else
            {
                renamable.EditTitleCancelled = false;
            }
        }
        public void SetUp()
        {
            m_Window  = EditorWindow.GetWindowWithRect <VseWindow>(new Rect(Vector2.zero, new Vector2(800, 600)));
            m_Stencil = new ClassStencil();

            var AssetModel = ScriptableObject.CreateInstance <VSGraphAssetModel>();
            var graphModel = AssetModel.CreateGraph <VSGraphModel>("test", typeof(ClassStencil), false);

            var portModelMock = new Mock <IPortModel>();

            portModelMock.Setup(x => x.GraphModel).Returns(graphModel);
            portModelMock.Setup(x => x.PortType).Returns(PortType.Event);
            portModelMock.Setup(x => x.Direction).Returns(Direction.Input);
            portModelMock.Setup(x => x.Name).Returns("port");
            portModelMock.Setup(x => x.DataType).Returns(typeof(float).GenerateTypeHandle(m_Stencil));
            m_Port = Port.Create(portModelMock.Object, m_Window.Store, Orientation.Horizontal);

            VariableDeclarationModel intVariableModel = graphModel.CreateGraphVariableDeclaration(
                "int", typeof(int).GenerateTypeHandle(m_Stencil), false
                );
            VariableDeclarationModel stringVariableModel = graphModel.CreateGraphVariableDeclaration(
                "string", typeof(string).GenerateTypeHandle(m_Stencil), false
                );

            m_IntField    = new BlackboardVariableField(m_Window.Store, intVariableModel, m_Window.GraphView);
            m_StringField = new BlackboardVariableField(m_Window.Store, stringVariableModel, m_Window.GraphView);

            m_IntTokenModel = Activator.CreateInstance <VariableNodeModel>();
            m_IntTokenModel.DeclarationModel = intVariableModel;
            m_IntTokenModel.GraphModel       = graphModel;

            m_StringTokenModel = Activator.CreateInstance <VariableNodeModel>();
            m_StringTokenModel.DeclarationModel = stringVariableModel;
            m_StringTokenModel.GraphModel       = graphModel;
        }
Exemple #3
0
 public void Unregister()
 {
     EditorApplication.update -= Update;
     HideWarningLabel();
     m_Store  = null;
     m_Window = null;
 }
Exemple #4
0
        public void Register(Store store, VseWindow window)
        {
            m_Store     = store;
            m_GraphView = window.GraphView;
            EditorApplication.update               += OnUpdate;
            EditorApplication.pauseStateChanged    += OnEditorPauseStateChanged;
            EditorApplication.playModeStateChanged += OnEditorPlayModeStateChanged;
            m_Store.StateChanged += OnStateChangeUpdate;
            m_Store.GetState().CurrentGraphModel?.Stencil?.Debugger?.Start(m_Store.GetState().CurrentGraphModel, m_Store.GetState().EditorDataModel.TracingEnabled);

            var root = window.rootVisualElement;

            if (m_TimelineToolbar == null)
            {
                m_TimelineToolbar = root.Q <TracingToolbar>();
                if (m_TimelineToolbar == null)
                {
                    m_TimelineToolbar = new TracingToolbar(m_GraphView, store);
                }
            }

            if (m_TimelineToolbar.parent != root)
            {
                root.Insert(1, m_TimelineToolbar);
            }
        }
Exemple #5
0
 public void Register(Store store, VseWindow window)
 {
     m_Store  = store;
     m_Window = window;
     EditorApplication.update += Update;
     CreateWarningLabel();
     Update();
 }
        static Texture2D GetIcon(string assetPath)
        {
            var obj = AssetDatabase.LoadAssetAtPath <VSGraphAssetModel>(assetPath);

            if (obj != null)
            {
                if (s_GraphAssetModelIcon == null)
                {
                    s_GraphAssetModelIcon = VseWindow.GetIcon();
                }
                return(s_GraphAssetModelIcon);
            }

            return(null);
        }
Exemple #7
0
        static void OnFocus(this IRenamable renamable, FocusEvent evt)
        {
            var textField = renamable.TitleEditor as TextField;

            textField?.SelectAll();

            VseWindow window = renamable.TitleElement.GetFirstAncestorOfType <VseGraphView>()?.window;

            // OnBlur is not called after a function is created in a new window and the window is closed, e.g. in tests
            ((VisualElement)renamable).RegisterCallback <DetachFromPanelEvent>(Callback);
            if (window != null)
            {
                window.RefreshUIDisabled = true;
            }

            renamable.TitleEditor.UnregisterCallback <FocusEvent>(renamable.OnFocus);

            Undo.undoRedoPerformed += renamable.UndoRedoPerformed;
        }
        public bool GetGraphAndObjectFromSelection(VseWindow vseWindow, Object selectedObject,
                                                   out string assetPath, out GameObject boundObject)
        {
            assetPath   = null;
            boundObject = null;

            if (selectedObject is IGraphAssetModel graphAssetModel)
            {
                // don't change the current object if it's the same graph
                if (graphAssetModel == vseWindow.CurrentGraphModel?.AssetModel)
                {
                    assetPath   = vseWindow.LastGraphFilePath;
                    boundObject = vseWindow.BoundObject;
                    return(true);
                }
            }

            ScriptingGraphAuthoring authoring;

            if (!(selectedObject is GameObject gameObject) ||
                (!(authoring = gameObject.GetComponent <ScriptingGraphAuthoring>())))
            {
                return(false);
            }

            var path = AssetDatabase.GetAssetPath(authoring.ScriptingGraph);

            if (path == null)
            {
                return(false);
            }

            assetPath   = path;
            boundObject = selectedObject as GameObject;

            return(true);
        }
 internal PluginRepository(Store store, VseWindow graphView)
 {
     m_Store          = store;
     m_GraphView      = graphView;
     m_PluginHandlers = new List <IPluginHandler>();
 }
Exemple #10
0
 public void Register(Store store, VseWindow window)
 {
 }