예제 #1
0
        public void Migrate()
        {
            bool selected = SelectionManager.IsSelected(this);

            SetAttributeNode newNode = NodeUtils.CreateNode(DashEditorCore.EditorConfig.editingGraph, typeof(SetAttributeNode), rect.position) as SetAttributeNode;

            newNode.Model.attributeName.SetValue(Model.attributeName);
            newNode.Model.expression    = Model.expression;
            newNode.Model.specifyType   = true;
            newNode.Model.attributeType = Model.attributeType;

            Graph.Connections.FindAll(c => c.inputNode == this).ToArray().ForEach(c =>
            {
                NodeConnection nc = new NodeConnection(c.inputIndex, newNode, c.outputIndex, c.outputNode);
                Graph.Connections.Add(nc);
                Graph.Connections.Remove(c);
            });

            Graph.Connections.FindAll(c => c.outputNode == this).ToArray().ForEach(c =>
            {
                NodeConnection nc = new NodeConnection(c.inputIndex, c.inputNode, c.outputIndex, newNode);
                Graph.Connections.Add(nc);
                Graph.Connections.Remove(c);
            });

            Graph.DeleteNode(this);

            if (selected)
            {
                SelectionManager.SelectNode(newNode, Graph);
            }
        }
예제 #2
0
        void DrawOutline(Rect p_rect)
        {
            if (SelectionManager.IsSelected(Graph.Nodes.IndexOf(this)))
            {
                GUI.color = Color.green;
                GUI.Box(new Rect(p_rect.x - 2, p_rect.y - 2, p_rect.width + 4, p_rect.height + 4),
                    "",  DashEditorCore.Skin.GetStyle("NodeSelected"));
            }
                
            if (IsExecuting || executeTime > 0)
            {
                if (!IsExecuting)
                {
                    executeTime -= .2f;
                }
                GUI.color = Color.cyan;
                GUI.Box(new Rect(p_rect.x - 2, p_rect.y - 2, p_rect.width + 4, p_rect.height + 4),
                    "",  DashEditorCore.Skin.GetStyle("NodeSelected"));
            }
            
            if (SelectionManager.IsSelecting(Graph.Nodes.IndexOf(this)))
            {
                GUI.color = Color.yellow;
                GUI.Box(new Rect(p_rect.x - 2, p_rect.y - 2, p_rect.width + 4, p_rect.height + 4),
                    "",  DashEditorCore.Skin.GetStyle("NodeSelected"));
            }
                
            if (hasErrorsInExecution)
            {
                GUI.color = Color.red;
                GUI.Box(new Rect(p_rect.x - 2, p_rect.y - 2, p_rect.width + 4, p_rect.height + 4),
                    "",  DashEditorCore.Skin.GetStyle("NodeSelected"));
                GUI.DrawTexture(new Rect(p_rect.x + 2, p_rect.y - 22, 16, 16),
                    IconManager.GetIcon("error_icon"));
            }

            int labelOffset = 0;
            if (this is InputNode)
            {
                InputNode node = this as InputNode;
                if (DashEditorCore.EditorConfig.editingController != null &&
                    DashEditorCore.EditorConfig.editingController.autoStart &&
                    DashEditorCore.EditorConfig.editingController.autoStartInput == node.Model.inputName) 
                {
                    GUI.color = Color.white;
                    GUIStyle style = new GUIStyle();
                    style.normal.textColor = Color.green;
                    style.fontStyle = FontStyle.Bold;
                    style.fontSize = 20;
                    style.alignment = TextAnchor.UpperCenter;
                    GUI.Label(new Rect(p_rect.x, p_rect.y + rect.height, rect.width, 20), "[START]", style);
                    labelOffset++;
                }
            }
            
            if (this is InputNode)
            {
                InputNode node = this as InputNode;
                if (DashEditorCore.EditorConfig.editingController != null &&
                    DashEditorCore.EditorConfig.editingController.autoOnEnable &&
                    DashEditorCore.EditorConfig.editingController.autoOnEnableInput == node.Model.inputName) 
                {
                    GUI.color = Color.white;
                    GUIStyle style = new GUIStyle();
                    style.normal.textColor = Color.green;
                    style.fontStyle = FontStyle.Bold;
                    style.fontSize = 20;
                    style.alignment = TextAnchor.UpperCenter;
                    GUI.Label(new Rect(p_rect.x, p_rect.y + rect.height + labelOffset * 25, rect.width, 20), "[ONENABLE]", style);
                    labelOffset++;
                }
            }

            if (Graph.previewNode == this)
            {
                GUI.color = Color.white;
                GUIStyle style = new GUIStyle();
                style.normal.textColor = Color.magenta;
                style.fontStyle = FontStyle.Bold;
                style.fontSize = 20;
                style.alignment = TextAnchor.UpperCenter;
                GUI.Label(new Rect(p_rect.x, p_rect.y + rect.height + labelOffset * 25, rect.width, 20), "[PREVIEW]", style);
            }

            GUI.color = Color.white;
        }