Beispiel #1
0
        private static void HandleKnobMouseUp(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            state.IsLinkSetting = false;
            if (state.SelectedKnob == null || inputInfo.InputPos.x < 0 || inputInfo.InputPos.y < 0 || state.SelectedKnob == state.FocusKnob)
            {
                return;
            }
            if (state.FocusKnob != null)
            {
                if (state.SelectedKnob.GetType().Name.Contains("Output"))
                {
                    NodeOutput output = state.SelectedKnob as NodeOutput;
                    NodeInput  input  = state.FocusKnob as NodeInput;
                    NodeKnob.Linking(output, input);
                }
                else
                {
                    NodeOutput output = state.FocusKnob as NodeOutput;
                    NodeInput  input  = state.SelectedKnob as NodeInput;
                    NodeKnob.Linking(output, input);
                }
            }
            else
            {
                state.SelectedKnob = null;
            }
        }
Beispiel #2
0
        public static void NewCanvas()
        {
            Path = @"Assets/Ou/Property/Node/Default.asset";
            if (curNodeEditorState != null)
            {
                if (AssetDatabase.GetAssetPath(curNodeEditorState).Contains("Default"))
                {
                    curNodeEditorState.CurGraph.Clear();
                    return;
                }
            }
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(Path);
            NodeGraph       graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
                graph.Clear();
            }
            else
            {
                TriggerEditorUtility.Init();
                state          = ScriptableObject.CreateInstance <NodeEditorState>();
                graph          = ScriptableObject.CreateInstance <NodeGraph>();
                state.CurGraph = graph;
                AssetDatabase.CreateAsset(state, Path);
                AssetDatabase.AddObjectToAsset(graph, state);
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(Path);
        }
Beispiel #3
0
        private static void HandleKnobMouseDrag(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputPos.x < 0 || inputInfo.InputPos.y < 0 || state.SelectedKnob == null)
            {
                return;
            }
        }
Beispiel #4
0
        private static void SelectedPanelMouseDragCheck(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputEvent.modifiers != EventModifiers.Alt)
            {
                state.IsSelectedPanelNodes = false;
            }
        }
Beispiel #5
0
        private static void SelectedPanelMouseDrag(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputEvent.modifiers == EventModifiers.Alt)
            {
                state.selectedPanelNodesEndPos = inputInfo.InputPos;
            }
        }
Beispiel #6
0
        private static void HandleWindowPineUp(NodeInputInfo inputInfo)
        {
            if (inputInfo.InputPos.x < 0 || inputInfo.InputPos.y < 0)
            {
                return;
            }
            NodeEditorState state = inputInfo.EdState;

            state.IsPineSetting = false;
        }
Beispiel #7
0
        private static void HandleKnobMouseDown(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputEvent.button == 0 && state.FocusKnob != null)
            {
                state.SelectedKnob  = state.FocusKnob;
                state.IsLinkSetting = true;
            }
        }
Beispiel #8
0
        private static void SelectedPanelMouseDown(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputEvent.modifiers == EventModifiers.Alt)
            {
                state.IsSelectedPanelNodes = true;
                state.SelectedNodes.Clear();
                state.selectedPanelNodesStartPos = inputInfo.InputPos;
            }
        }
Beispiel #9
0
        private static void HandleSettingMouseDown(NodeInputInfo inputInfo)
        {
            var state = inputInfo.EdState;

            if (inputInfo.InputEvent.button != 1)
            {
                return;
            }
            if (state.SelectedNode != null && state.FocusNode == state.SelectedNode)
            {
                NodeEditor.DrawSelectedNodeMenu();
            }
        }
Beispiel #10
0
        public static void DrawCanvas(Rect viewRect)
        {
            DrawBackground();
            if (curNodeGraph == null || curNodeEditorState == null)
            {
                return;
            }
            curNodeEditorState.CurGraphRect = viewRect;
            if (!curNodeGraph.nodes.Exists(res => res.GetId.Equals("初始化")))
            {
                InitGraphNode();
            }
            for (int nodeCnt = 0; nodeCnt < curNodeGraph.nodes.Count; nodeCnt++)
            {
                if (curNodeGraph.nodes[nodeCnt] == null)
                {
                    curNodeGraph.nodes.RemoveAt(nodeCnt);
                    nodeCnt--;
                }
                else
                {
                    try
                    {
                        curNodeGraph.nodes[nodeCnt].Draw();
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        curNodeGraph.Remove(curNodeGraph.nodes[nodeCnt]);
                        nodeCnt--;
                    }
                }
                //try
                //{
                //    curNodeGraph.nodes[nodeCnt].Draw();
                //}
                //catch (NullReferenceException e)
                //{
                //    curNodeEditorState = null;
                //    curNodeGraph = null;
                //    return;
                //}
            }

            if (CurNodeInputInfo == null || CurNodeInputInfo.EdState == null)
            {
                CurNodeInputInfo = new NodeInputInfo("test", curNodeEditorState);
            }
            DrawLink();
            DrawMessage();
            NodeInputSystem.DynamicInvoke(CurNodeInputInfo);
        }
 internal static void DynamicInvoke(NodeInputInfo inputInfo)
 {
     if (_eventHandles == null)
     {
         return;
     }
     foreach (var keyValuePair in _eventHandles)
     {
         if (keyValuePair.Key.eventType == inputInfo.InputEvent.type)
         {
             keyValuePair.Value.DynamicInvoke(inputInfo);
         }
     }
 }
Beispiel #12
0
        public static void LoadCanvas(string path)
        {
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(path);

            TriggerEditorUtility.Init();
            NodeGraph graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(path);
        }
Beispiel #13
0
        private static void HandleNodePanelDrag(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputPos.x < 0 || inputInfo.InputPos.y < 0 || state.SelectedNode == null)
            {
                return;
            }
            if (state.IsPineSetting)
            {
                Vector2 panChangeDragOffset = state.DragOffset;
                state.DragOffset    = inputInfo.InputPos - state.DragStart;
                panChangeDragOffset = (state.DragOffset - panChangeDragOffset);
                state.SelectedNode.rect.position += panChangeDragOffset / state.GraphZoom;
            }
        }
Beispiel #14
0
        private static void HandleCheckFocus(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            state.FocusNode = state.CurGraph.CheckFocus(inputInfo.InputPos);
            state.FocusKnob = state.CurGraph.CheckFocusKnob(inputInfo.InputPos);
            if (state.FocusKnob != null)
            {
                NodeEditor.Messagerect = new Rect(state.FocusKnob.rect.position, new Vector2(150, 150));
                NodeEditor.Message     = state.FocusKnob.Name;
            }
            else
            {
                NodeEditor.Message = string.Empty;
            }
        }
Beispiel #15
0
        private static void SelectedPanelMouseUp(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputEvent.modifiers == EventModifiers.Alt)
            {
                state.selectedPanelNodesEndPos = inputInfo.InputPos;
                state.IsSelectedPanelNodes     = false;
                // Rect rect=new Rect(state.selectedPanelNodesStartPos);
                for (int i = 0; i < state.CurGraph.nodes.Count; i++)
                {
                    //if( state.CurGraph.nodes[i].rect)
                    state.SelectedNodes.Add(state.CurGraph.nodes[i]);
                }
            }
        }
Beispiel #16
0
        private static void HandleWindowPineDrag(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputPos.x < 0 || inputInfo.InputPos.y < 0 || state.SelectedNode != null || state.SelectedKnob != null)
            {
                return;
            }
            if (state.IsPineSetting)
            {
                Vector2 panChangeDragOffset = state.DragOffset;
                state.DragOffset    = inputInfo.InputPos - state.DragStart;
                panChangeDragOffset = (state.DragOffset - panChangeDragOffset);
                state.PanOffset    += panChangeDragOffset / state.GraphZoom;
            }
        }
Beispiel #17
0
        public static void LoadCanvas()
        {
            string path = EditorUtility.OpenFilePanel("Load Canvas", Application.dataPath + "/Ou/Property/Node", "asset");

            path = Regex.Replace(path, @"^.+/Assets", "Assets");
            TriggerEditorUtility.Init();
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(path);
            NodeGraph       graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(path);
        }
Beispiel #18
0
        private static void HandleNodePanelDown(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (inputInfo.InputEvent.button == 0 && state.FocusNode != null)
            {
                state.SelectedNode     = state.FocusNode;
                Selection.activeObject = state.FocusNode;
                if (!state.IsPineSetting)
                {
                    state.IsPineSetting = true;
                    state.DragStart     = inputInfo.InputPos;
                    state.DragOffset    = Vector2.zero;
                }
                else
                {
                    state.DragStart  = inputInfo.InputPos;
                    state.DragOffset = Vector2.zero;
                }
            }
        }
Beispiel #19
0
        public static void InitAssetData()
        {
            TriggerEditorUtility.Init();
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(Path);
            NodeGraph       graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            else
            {
                state          = ScriptableObject.CreateInstance <NodeEditorState>();
                graph          = ScriptableObject.CreateInstance <NodeGraph>();
                state.CurGraph = graph;
                AssetDatabase.CreateAsset(state, Path);
                AssetDatabase.AddObjectToAsset(graph, state);
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
        }
Beispiel #20
0
        private static void HandleWindowScroll(NodeInputInfo inputInfo)
        {
            if (inputInfo.InputPos.x < 0 || inputInfo.InputPos.y < 0)
            {
                return;
            }
            NodeEditorState state = inputInfo.EdState;

            state.ZoomPos = (inputInfo.InputPos - NodeEditor.curNodeEditorState.PanOffset) /
                            NodeEditor.curNodeEditorState.GraphZoom;
            Vector2 scalePos = state.ZoomPos;
            float   Scale    = 0.01f * inputInfo.InputEvent.delta.y;

            state.GraphZoom += Scale;
            if (state.GraphZoom <= 0.5f)
            {
                state.GraphZoom = 0.5f;
                return;
            }
            Vector2 scalePosCurrent = scalePos * state.GraphZoom;

            state.PanAdjust = (scalePos - scalePosCurrent);
        }
Beispiel #21
0
        public static void SaveAs()
        {
            string path = EditorUtility.SaveFilePanel("Save unit", Application.dataPath + "/Ou/Property/Node",
                                                      "Duplicate", "asset");

            path = Regex.Replace(path, @"^.+/Assets", "Assets");
            AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(curNodeEditorState), path);
            AssetDatabase.Refresh();
            NodeEditorState state = AssetDatabase.LoadAssetAtPath <NodeEditorState>(path);

            state.Name = Regex.Match(path, @"/.+?\.", RegexOptions.RightToLeft).Value.TrimStart('/').TrimEnd('.');
            TriggerEditorUtility.Init();
            NodeGraph graph = null;

            if (state != null)
            {
                graph = state.CurGraph;
            }
            CurNodeInputInfo   = null;
            curNodeGraph       = graph;
            curNodeEditorState = state;
            CreateCache(path);
        }
Beispiel #22
0
        private static void HandleWindowPineDown(NodeInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.EdState;

            if (state.FocusNode != null && state.FocusKnob != null || inputInfo.InputEvent.button != 0)
            {
                return;
            }
            else
            {
                state.SelectedNode = null;
            }
            if (!state.IsPineSetting)
            {
                state.IsPineSetting = true;
                state.DragStart     = inputInfo.InputPos;
                state.DragOffset    = Vector2.zero;
            }
            else
            {
                state.DragStart  = inputInfo.InputPos;
                state.DragOffset = Vector2.zero;
            }
        }