Inheritance: UnityEditor.Graphs.GraphGUI
コード例 #1
0
        protected virtual void DrawOutputSlots(GraphGUI host, IEnumerable <Graphs.Slot> slots, bool prefixNodeName = false)
        {
            var src_slot = (host.edgeGUI as EdgeGUI).DragSourceSlot;

            foreach (var slot in slots)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (slot == src_slot)
                {
                    Styles.pinOut.fontStyle          = FontStyle.Bold;
                    Styles.pinOut.normal.textColor   = Color.blue;
                    Styles.pinOut.onNormal.textColor = Color.blue;
                }
                else
                {
                    Styles.pinOut.fontStyle          = FontStyle.Normal;
                    Styles.pinOut.normal.textColor   = Color.black;
                    Styles.pinOut.onNormal.textColor = Color.black;
                }
                var n = (slot.node as Block).runtimeInstance;
                host.LayoutSlot(slot, (prefixNodeName ? n.name + "." :"") + slot.title, true, false, true, Styles.pinOut);
                EditorGUILayout.EndHorizontal();
            }
        }
コード例 #2
0
        public virtual void OnNodeUI(GraphGUI host)
        {
            var src_slot = (host.edgeGUI as EdgeGUI).DragSourceSlot;

            foreach (var slot in this.inputSlots)
            {
                if (src_slot != null && src_slot.isOutputSlot && host.graph.CanConnect(src_slot, slot))
                {
                    Styles.pinIn.fontStyle        = FontStyle.Bold;
                    Styles.pinIn.normal.textColor = Color.green;
                }
                else
                {
                    Styles.pinIn.fontStyle        = FontStyle.Normal;
                    Styles.pinIn.fontSize         = 10;
                    Styles.pinIn.normal.textColor = Color.black;
                }
                host.LayoutSlot(slot, slot.title, false, true, true, Styles.pinIn);
            }

            base.NodeUI(host);

            foreach (var slot in this.outputSlots)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                host.LayoutSlot(slot, slot.title, true, false, true, Styles.pinOut);
                EditorGUILayout.EndHorizontal();
            }
        }
コード例 #3
0
ファイル: Node.cs プロジェクト: red-pencil/ISWC18
        public virtual void OnNodeUI(GraphGUI host)
        {
            var src_slot = (host.edgeGUI as EdgeGUI).DragSourceSlot;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            foreach (var slot in this.inputSlots)
            {
                bool canConvert = false;
                if (src_slot != null && src_slot.isOutputSlot)
                {
                    canConvert = host.graph.CanConnect(src_slot, slot);

                    /*
                     * var convertor = TypeDescriptor.GetConverter (src_slot.dataType);//host.graph.CanConnect(src_slot,slot)) {
                     * try{
                     * if (convertor!=null)
                     *      canConvert = convertor.CanConvertTo (slot.dataType);
                     * }catch(Exception e) {
                     * }
                     * canConvert |= slot.dataType.IsAssignableFrom (src_slot.dataType);*/
                }
                if (canConvert)
                {
                    Styles.pinIn.fontStyle          = FontStyle.Bold;
                    Styles.pinIn.onNormal.textColor = Color.green;
                }
                else
                {
                    Styles.pinIn.fontStyle          = FontStyle.Normal;
                    Styles.pinIn.fontSize           = 10;
                    Styles.pinIn.onNormal.textColor = Color.black;
                }
                host.LayoutSlot(slot, slot.title, false, true, true, Styles.pinIn);
            }
            EditorGUILayout.EndVertical();

            base.NodeUI(host);
            EditorGUILayout.BeginVertical();
            foreach (var slot in this.outputSlots)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                host.LayoutSlot(slot, slot.title, true, false, true, Styles.pinOut);
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
コード例 #4
0
ファイル: Node.cs プロジェクト: red-pencil/ISWC18
        public virtual void OnNodeDraw(GraphGUI host)
        {
            // Recapture the variable for the delegate.
            var node2 = this;

            // Subwindow style (active/nonactive)
            var      isActive = host.selection.Contains(this);
            GUIStyle style    = nodeStyle;

            if (nodeStyle == null)
            {
                style = Graphs.Styles.GetNodeStyle(this.style, this.color, isActive);
            }

            // Show the subwindow of this node.
            this.position = GUILayout.Window(
                this.GetInstanceID(), this.position,
                delegate { host.NodeGUI(node2); },
                this.title, style, GUILayout.Width(150), GUILayout.Height(50)
                );
        }
コード例 #5
0
        public virtual void OnNodeUI(GraphGUI host)
        {
            GUI.backgroundColor = Color.white;
            var src_slot = (host.edgeGUI as EdgeGUI).DragSourceSlot;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            DrawInputSlots(host, inputSlots);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();

            base.NodeUI(host);

            (this.runtimeInstance as BlockBase).OnNodeGUI();
            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            DrawOutputSlots(host, outputSlots);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
コード例 #6
0
        public virtual void OnNodeDraw(GraphGUI host)
        {
#if UNITY_EDITOR
            // Recapture the variable for the delegate.
            var node2 = this;
            if ((runtimeInstance as BlockBase)._group != null)
            {
                return;
            }

            // Subwindow style (active/nonactive)
            var      isActive = host.selection.Contains(this);
            GUIStyle style    = BlockStyle;
            //  if (nodeStyle == null)
            {
                BlockStyle = new GUIStyle(Graphs.Styles.GetNodeStyle(this.style, this.color, isActive));
                if (_attrs != null)
                {
                    //   BlockStyle.normal.background =  _visuals.iconTex;
                }
            }

            float w = 150, h = 50;

            if (_attrs != null)
            {
                w = _attrs.width;
                h = _attrs.height;
            }

            // Show the subwindow of this Block.
            this.position = GUILayout.Window(
                this.GetInstanceID(), this.position,
                delegate { host.NodeGUI(node2); },
                this.title, GUILayout.Width(w), GUILayout.Height(h));
#endif
        }
コード例 #7
0
        protected virtual void DrawInputSlots(GraphGUI host, IEnumerable <Graphs.Slot> slots, bool prefixNodeName = false)
        {
            var src_slot = (host.edgeGUI as EdgeGUI).DragSourceSlot;

            foreach (var slot in slots)
            {
                bool canConvert = false;
                if (src_slot != null && src_slot.isOutputSlot)
                {
                    canConvert = host.graph.CanConnect(src_slot, slot);

                    /*
                     *                  var convertor = TypeDescriptor.GetConverter (src_slot.dataType);//host.graph.CanConnect(src_slot,slot)) {
                     *                  try{
                     *                  if (convertor!=null)
                     *                          canConvert = convertor.CanConvertTo (slot.dataType);
                     *                  }catch(Exception e) {
                     *                  }
                     *                  canConvert |= slot.dataType.IsAssignableFrom (src_slot.dataType);*/
                }
                if (canConvert)
                {
                    Styles.pinIn.fontStyle          = FontStyle.Bold;
                    Styles.pinIn.normal.textColor   = Color.blue;
                    Styles.pinIn.onNormal.textColor = Color.blue;
                }
                else
                {
                    Styles.pinIn.fontStyle          = FontStyle.Normal;
                    Styles.pinIn.fontSize           = 10;
                    Styles.pinIn.normal.textColor   = Color.black;
                    Styles.pinIn.onNormal.textColor = Color.black;
                }
                var n = (slot.node as Block).runtimeInstance;
                host.LayoutSlot(slot, (prefixNodeName ? n.name + "." : "") + slot.title, false, true, true, Styles.pinIn);
            }
        }
コード例 #8
0
ファイル: PatcherWindow.cs プロジェクト: red-pencil/ISWC18
 // Initializer (called from OpenPatch)
 void Initialize(Wiring.Patch patch)
 {
     hideFlags = HideFlags.HideAndDontSave;
     _graph    = Graph.Create(patch);
     _graphGUI = _graph.GetEditor();
 }
コード例 #9
0
ファイル: PatcherWindow.cs プロジェクト: keijiro/Klak
 // Initializer (called from OpenPatch)
 void Initialize(Wiring.Patch patch)
 {
     hideFlags = HideFlags.HideAndDontSave;
     _graph = Graph.Create(patch);
     _graphGUI = _graph.GetEditor();
 }