Esempio n. 1
0
 protected internal override void DrawConnection()
 {
     if (connection != null)
     {
         EffectUtility.DrawLine(this.rect.center, connection.rect.center);
     }
 }
Esempio n. 2
0
 protected internal override void DrawConnection()
 {
     if (connection != null && connection.Body != null)
     {
         EffectUtility.DrawLine(connection.rect.center, this.rect.center, Color.blue);
     }
 }
Esempio n. 3
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            (obj as EffectLTransformObject).value =
                (Transform)EffectUtility.FormatObject((obj as EffectLTransformObject).value, typeof(Transform));
#endif
        }
Esempio n. 4
0
        protected internal virtual void Draw()
        {
#if UNITY_EDITOR
            if (NodeSkin == null)
            {
                return;
            }
            CheckKnobMigration();
            nodeRect = rect;
            EffectUtility.RectConverting(ref nodeRect, curGraph.curNodeState);
            Vector2 contentOffset = new Vector2(0, 15 * curGraph.curNodeState.GraphZoom);
            Rect    nodeHead      = new Rect(0, 0, nodeRect.width, contentOffset.y);
            Rect    nodeBody      = new Rect(nodeRect.x, nodeRect.y, nodeRect.width,
                                             nodeRect.height);
            using (var group = new ClipGroup(nodeBody))
            {
                nodeBody.position = Vector2.zero;
                using (var area = new ClipArea(nodeBody, NodeSkin.GetStyle("nodeBody")))
                {
                    var style = NodeSkin.GetStyle("nodeHead");
                    style.fontSize = (int)(10 * curGraph.curNodeState.GraphZoom);
                    GUI.Label(nodeHead, Title, style);
                    GUILayout.Space(contentOffset.y);
                    NodeGUI();
                }
            }
            //GUILayout.BeginArea(nodeBody, curGraph.curNodeState.SelectedNode == this
            //    ? NodeSkin.GetStyle("nodeBodySelected")
            //    : NodeSkin.GetStyle("nodeBody"));

            // GUILayout.EndArea();
            DrawKnob();
            DrawConnections();
#endif
        }
Esempio n. 5
0
        protected internal virtual void DrawCotName()
        {
            if (Body.curGraph.curNodeState.GraphZoom < 0.9f)
            {
                return;
            }
            Vector2 offset   = Vector2.zero;
            var     gUIStyle = Body.NodeSkin.GetStyle("nodeKnobName");

            switch (side)
            {
            case Side.Left:
                offset   = new Vector2(15, 0);
                gUIStyle = Body.NodeSkin.GetStyle("nodeKnobNameL");
                break;

            case Side.Top:
                offset = new Vector2(0, -10);
                break;

            case Side.Right:
                offset   = new Vector2(-55, 0);
                gUIStyle = Body.NodeSkin.GetStyle("nodeKnobNameR");
                break;

            case Side.Bottom:
                offset = new Vector2(0, 5);
                break;
            }
            Rect drawRect = new Rect(rect.position + offset, new Vector2(50, 10));

            EffectUtility.FormatLabel(drawRect, CotName, gUIStyle);
        }
Esempio n. 6
0
 protected internal override void DrawConnection()
 {
     if (connection != null && connection.Body != null)
     {
         EffectUtility.DrawLineDirect(rect.center, connection.rect.center, Color.yellow);
     }
 }
Esempio n. 7
0
        public static void MapDraw(Rect vrect, GUISkin skin)
        {
#if UNITY_EDITOR
            if (MapEditor.curNodeGraph == null)
            {
                return;
            }
            GUILayout.BeginVertical();
            foreach (var clan in NodeStack.clans.Keys)
            {
                EffectUtility.FormatButton(clan, () => { SelectedClan(clan); },
                                           selectedClan.Equals(clan) ? skin.GetStyle("ClanButtonDown") : skin.GetStyle("ClanButton"));
                if (selectedClan.Equals(clan))
                {
                    foreach (var node in NodeStack.clans[selectedClan].clanNode)
                    {
                        EffectUtility.FormatButton(node.GetId, () => { SelectedNode(node.GetId); },
                                                   selectedNode.Equals(node.GetId)
                                ? skin.GetStyle("NodeButtonDown")
                                : skin.GetStyle("NodeButtonUp"));
                    }
                }
            }
            GUILayout.EndVertical();
#endif
        }
Esempio n. 8
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            if (obj == null || !obj.GetType().IsAssignableFrom(typeof(EffectLNumeric)))
            {
                obj = new EffectLNumeric();
            }
            (obj as EffectLNumeric).type =
                (EffectLNumeric.NumericType)EffectUtility.FormatEnum((obj as EffectLNumeric).type);
            switch ((obj as EffectLNumeric).type)
            {
            case EffectLNumeric.NumericType.真值:
                (obj as EffectLNumeric).SetVal(EffectUtility.FormatInt((int)(obj as EffectLNumeric).Val()));
                break;

            case EffectLNumeric.NumericType.实值:
                (obj as EffectLNumeric).SetVal(EffectUtility.FormatFloat((float)(obj as EffectLNumeric).Val()));
                break;

            case EffectLNumeric.NumericType.Double:
                (obj as EffectLNumeric).SetVal(EffectUtility.FormatDouble((double)(obj as EffectLNumeric).Val()));
                break;
            }
#endif
        }
Esempio n. 9
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            if (obj == null || !obj.GetType().IsAssignableFrom(typeof(string)))
            {
                obj = string.Empty;
            }
            obj = EffectUtility.FormatTextfield((string)obj);
#endif
        }
Esempio n. 10
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            if (obj == null || !obj.GetType().IsAssignableFrom(typeof(bool)))
            {
                obj = false;
            }
            obj = EffectUtility.FormatBool((bool)obj);
#endif
        }
Esempio n. 11
0
        static void DrawBindProxy(GameObject obj, GUISkin skin)
        {
#if UNITY_EDITOR
            EffectUtility.FormatLabel(obj.name, skin.GetStyle("HandleLabel1"));
            if (obj.GetComponent <EffectLProxy>() == null)
            {
                EffectUtility.FormatButton("bind", () => { BindProxy(obj); });
            }
#endif
        }
Esempio n. 12
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            if (obj == null || !obj.GetType().IsAssignableFrom(typeof(Vector3)))
            {
                obj = Vector3.zero;
            }
            obj = EffectUtility.FormatVector3((Vector3)obj);
#endif
        }
Esempio n. 13
0
 public static void DrawLinkSelecting()
 {
     if (curNodeEditorState.IsLinkSetting)
     {
         Vector3 startPos = new Vector3(curNodeEditorState.SelectedKnob.rect.center.x,
                                        curNodeEditorState.SelectedKnob.rect.center.y, 0);
         Vector3 endPos = new Vector3(CurNodeInputInfo.InputPos.x, CurNodeInputInfo.InputPos.y, 0);
         EffectUtility.DrawLine(startPos, endPos);
     }
 }
Esempio n. 14
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            if (obj == null || !obj.GetType().IsAssignableFrom(typeof(EffectLPopup)))
            {
                obj = new EffectLPopup(0);
            }
            EffectUtility.FormatPopup(ref (obj as EffectLPopup).index, (obj as EffectLPopup).popup);
#endif
        }
Esempio n. 15
0
        protected virtual void Init(Vector2 pos, Node protoType)
        {
            NodeSkin = EffectUtility.GetGUISkinStyle("NormalSkin");
            var data = NodeStack.nodes[protoType];

            rect  = new Rect(pos, data.Size);
            Title = data.Name;
            GetId = data.Name;
            Clan  = protoType.Clan;
            NodeStack.NodeInit(this);
        }
Esempio n. 16
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            if (obj == null || !obj.GetType().IsAssignableFrom(typeof(EffectLCommand)))
            {
                obj = new EffectLCommand(string.Empty);
                obj = 0.1f;
            }
            EffectUtility.FormatTextArea(ref (obj as EffectLCommand).Content);
#endif
        }
Esempio n. 17
0
        public static NodeDirectKnob Create(Node nodeBody, string name, Side side = Side.Left, float offset = 30f)
        {
            var Direct = CreateInstance <NodeDirectKnob>();

#if UNITY_EDITOR
            Undo.RegisterCreatedObjectUndo(Direct, "Create Node");
#endif
            offset += 20;
            Direct.Init(nodeBody, name, side, offset);
            Direct.texture2D = EffectUtility.Tex(Color.blue);
            return(Direct);
        }
Esempio n. 18
0
        public static void DrawToolBar(Rect rect, GUISkin skin)
        {
#if UNITY_EDITOR
            GUILayout.BeginHorizontal();
            EffectUtility.FormatButton("", NodeEditor.Save, skin.GetStyle("toolbar-Save"));
            EffectUtility.FormatButton("", null, skin.GetStyle("toolbar-SaveAs"));
            EffectUtility.FormatButton("", NodeEditor.CreateNew, skin.GetStyle("toolbar-New"));
            EffectUtility.FormatButton("", NodeEditor.Load, skin.GetStyle("toolbar-Load"));
            //EffectUtility.FormatButton("Play", ()=> { EditorApplication.isPlaying = true; } , skin.GetStyle("ToolBarButton"));
            //EffectUtility.FormatButton("End", () => { EditorApplication.isPlaying = false; }, skin.GetStyle("ToolBarButton"));

            GUILayout.EndHorizontal();
#endif
        }
Esempio n. 19
0
        static void DrawSelectedNode()
        {
            if (curNodeEditorState.SelectedNode == null)
            {
                return;
            }
            var nodeRect = curNodeEditorState.SelectedNode.nodeRect;

            EffectUtility.DrawLineA(Color.yellow,
                                    nodeRect.position,
                                    nodeRect.position + new Vector2(nodeRect.size.x, 0),
                                    nodeRect.position + new Vector2(nodeRect.size.x, nodeRect.size.y),
                                    nodeRect.position + new Vector2(0, nodeRect.size.y),
                                    nodeRect.position
                                    );
        }
Esempio n. 20
0
        public virtual void Draw(Node bodyNode)
        {
#if UNITY_EDITOR
            Body = bodyNode;
            rect = GetGUIKnob();
            EffectUtility.RectConverting(ref rect, Body.curGraph.curNodeState);
            if (texture2D == null)
            {
                CheckColor();
                return;
            }
            DrawCotName();
            //GUI.DrawTexture(rect, texture2D);
            GUI.DrawTextureWithTexCoords(rect, texture2D, new Rect(0, 0, 1, 1));
#endif
        }
Esempio n. 21
0
        public static Node CreateNode(Vector2 pos, string nodeId, NodeGraph graph)
        {
#if UNITY_EDITOR
            Node node = NodeStack.getDefaultNode(nodeId);
            if (node == null)
            {
                Debug.Log("node editor running is warning!");
            }
            var npos       = EffectUtility.RectReConverting(pos, graph.curNodeState);
            var nodeObject = node.Create();
            AssetDatabase.AddObjectToAsset(nodeObject, graph);
            Undo.RecordObject(nodeObject, "Add");
            nodeObject.curGraph = graph;
            nodeObject.Init(npos, node);
            return(nodeObject);
#else
            return(null);
#endif
        }
Esempio n. 22
0
        static void DrawNodeHandle(Node node, GUISkin skin)
        {
#if UNITY_EDITOR
            if (node != target)
            {
                fields = NodeStack.NodeGetAsset(NodeStack.getDefaultNode(node.GetId));
                target = node;
                return;
            }
            EffectUtility.FormatLabel(node.Title, skin.GetStyle("HandleLabel1"));
            EffectUtility.FormatLabel("节点名:", skin.GetStyle("HandleLabel2"));
            EffectUtility.FormatTextfield(ref node.Title);
            foreach (FieldInfo field in fields)
            {
                var value = field.GetValue(node);
                EffectUtility.FormatLabel(field.Name, skin.GetStyle("HandleLabel2"));
                EffectUtility.FormatAssetField(ref value, field.FieldType);
                field.SetValue(node, value);
            }
#endif
        }
Esempio n. 23
0
        private static void HandleWindowScroll(NodeInputInfo inputInfo)
        {
            if (inputInfo.InputPos.x < 0 || inputInfo.InputPos.y < 0)
            {
                return;
            }
            NodeEditorState state = inputInfo.EdState;
            float           Scale = 0.01f * inputInfo.InputEvent.delta.y;

            state.GraphZoom += Scale;
            if (state.GraphZoom <= 0.2f)
            {
                state.GraphZoom = 0.2f;
            }
            else if (state.GraphZoom >= 1.2f)
            {
                state.GraphZoom = 1.2f;
            }
            state.ZoomPos   = state.CurGraphRect.size / 2;
            state.PanAdjust = EffectUtility.PanelScale(ref state.CurGraphRect, state.ZoomPos, state.GraphZoom);
        }
Esempio n. 24
0
        static void DrawCubeHandle(Cube cube, GUISkin skin)
        {
#if UNITY_EDITOR
            if (cube != target)
            {
                fields = NodeStack.NodeGetAsset(NodeStack.getDefaultNode(cube.GetId));
                target = cube;
                return;
            }
            EffectUtility.FormatLabel(cube.Title, skin.GetStyle("HandleLabel1"));
            EffectUtility.FormatLabel("节点名:", skin.GetStyle("HandleLabel2"));
            EffectUtility.FormatTextfield(ref cube.Title);
            EffectUtility.FormatButton("添加组件", () =>
            {
                cube.Component.Add(0);
            });
            for (int i = 0; i < cube.Component.Count; i++)
            {
                GUILayout.BeginHorizontal();
                cube.Component[i] = EffectUtility.FormatPopup(cube.Component[i], 140f, NodeStack.MonoComponentsName.ToArray());
                int j = i;
                EffectUtility.FormatButton("除去", () =>
                {
                    cube.Component.RemoveAt(j);
                });
                GUILayout.EndHorizontal();
            }

            foreach (FieldInfo field in fields)
            {
                var value = field.GetValue(cube);
                EffectUtility.FormatLabel(field.Name, skin.GetStyle("HandleLabel2"));
                EffectUtility.FormatAssetField(ref value, field.FieldType);
                field.SetValue(cube, value);
            }
#endif
        }
Esempio n. 25
0
 protected override void CheckColor()
 {
     texture2D = EffectUtility.Tex(Color.white);
 }
Esempio n. 26
0
 static void SetKnobUI(NodeInput input)
 {
     input.texture2D = EffectUtility.Tex(Color.blue);
 }
Esempio n. 27
0
        public void GUIFill(ref object obj)
        {
#if UNITY_EDITOR
            obj = EffectUtility.FormatEnum((Enum)obj);
#endif
        }
Esempio n. 28
0
 private static void SetKnobUI(NodeOutput output)
 {
     output.texture2D = EffectUtility.Tex(Color.blue);
 }