DisplayLayout() public method

Function to automatically draw and update the output with a label for it's name
public DisplayLayout ( ) : void
return void
Exemplo n.º 1
0
        protected override void Draw()
        {
            UnityEditor.EditorGUIUtility.fieldWidth = 140;
            UnityEditor.EditorGUIUtility.labelWidth = 50;
            this.LayoutPropertyField("variable");

            UpdateIOWithSource();

            GUILayout.BeginHorizontal();
            UnityEditor.EditorGUIUtility.labelWidth = 1;
            input.DisplayLayout(GUIContent.none);
            output.DisplayLayout(GUIContent.none);
            GUILayout.EndHorizontal();
        }
Exemplo n.º 2
0
    private void DrawSelect(NodeOutput outPut)
    {
        if (outPut == null || !selects.ContainsKey(outPut))
            return;
        outPut.DisplayLayout();
        SelectManager selectManager = selects[outPut].selectManager;
        var functions = selects[outPut].functions;
        if (isExpanded)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("이름");
            if (selects.ContainsKey(outPut))
                selects[outPut].selectManager.gameObject.name = EditorGUILayout.TextField(selects[outPut].selectManager.gameObject.name);
            string buttonName = (nodeType == NodeType.Route) ? "조건 실행 삭제" : "선택지 삭제";
            if(GUILayout.Button(buttonName))
            {
                if (!selects.ContainsKey(outPut))
                    return;
                List<NodeInput> keyInputList = new List<NodeInput>(selects[outPut].functions.Keys);
                foreach (var inPut in keyInputList)
                {
                    var functions1 = selects[outPut].functions;
                    var target = functions1[inPut];
                    DestroyImmediate((MonoBehaviour)functions[inPut]);
                    DestroyImmediate(target, true);
                    functions1.Remove(inPut);
                    try
                    {
                        inPut.connection.connections.Remove(inPut);
                    }
                    catch (NullReferenceException e)
                    {

                    }
                    Inputs.Remove(inPut);
                }
                DestroyImmediate(selects[outPut], true);
                DestroyImmediate(selects[outPut].selectManager.gameObject);
                selects.Remove(outPut);
                //  Outputs.Remove(outPut);
                Vector2 topLeft = rect.position;
                rect = new Rect (topLeft.x, topLeft.y, 200, 100);
                foreach (NodeInput inPut in outPut.connections)
                {
                    inPut.connection = null;
                }
                Outputs.Remove(outPut);
                DrawConnectors();
                return;
            }
            GUILayout.EndHorizontal();
            selectManager.isActive = EditorGUILayout.Toggle("활성화", selectManager.isActive);
            selectManager.isOnce = EditorGUILayout.Toggle("일회용", selects[outPut].selectManager.isOnce);
            selectManager.requireTime = EditorGUILayout.FloatField("소요시간", selectManager.requireTime);
            //  selects[outPut].selectManager.dangers.isActive = EditorGUILayout.Toggle("위험 활성화", selects[outPut].selectManager.dangers.isActive);
            selectManager.dangers.dangerCount = EditorGUILayout.IntField("위험도", selectManager.dangers.dangerCount);
            GUILayout.BeginHorizontal();
            selectOptionIndex = EditorGUILayout.Popup("종류", selectOptionIndex, selectOptions);
            if(GUILayout.Button("기능 추가"))
            {
                NodeInput key;
                Function executor = null;
                if (!selects.ContainsKey(outPut))
                    return;
                switch (selectOptionIndex)
                {
                    case 0:
                        executor = selectManager.gameObject.AddComponent<SpriteChanger>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.ObjectOnly);
                        break;
                    case 1:
                        executor = selectManager.gameObject.AddComponent<Enabler>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.General);
                        break;
                    case 2:
                        executor = selectManager.gameObject.AddComponent<SoundPlayer>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                        break;
                    case 3:
                        executor = selectManager.gameObject.AddComponent<MessageDisplayer>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                        break;
                    case 4:
                        executor = selectManager.gameObject.AddComponent<ItemGainer>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.ItemOnly);
                        break;
                    case 5:
                        executor = selectManager.gameObject.AddComponent<DangerChanger>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.SelectionOnly);
                        break;
                    case 6:
                        executor = selectManager.gameObject.AddComponent<SpriteShower>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                        break;
                    case 7:
                        executor = selectManager.gameObject.AddComponent<EventMaker>();
                        key = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                        break;
                    default:
                        executor = null;
                        key = null;
                        break;
                }
                functions.Add(key, executor);
                DrawNode();
            }
            GUILayout.EndHorizontal();
        }

        List<NodeInput> keyList = new List<NodeInput>(functions.Keys);
        foreach (var item in keyList)
        {
            DrawSelectFunction(outPut, item);
        }

        DrawConnectors();
        if (isExpanded)
            GUILayout.Space(20);
    }
Exemplo n.º 3
0
    private void DrawSelect(NodeOutput outPut)
    {
        if (outPut == null || !selects.ContainsKey(outPut))
        {
            return;
        }
        outPut.DisplayLayout();
        SelectManager selectManager = selects[outPut].selectManager;
        var           functions     = selects[outPut].functions;

        if (isExpanded)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("이름");
            if (selects.ContainsKey(outPut))
            {
                selects[outPut].selectManager.gameObject.name = EditorGUILayout.TextField(selects[outPut].selectManager.gameObject.name);
            }
            string buttonName = (nodeType == NodeType.Route) ? "조건 실행 삭제" : "선택지 삭제";
            if (GUILayout.Button(buttonName))
            {
                if (!selects.ContainsKey(outPut))
                {
                    return;
                }
                List <NodeInput> keyInputList = new List <NodeInput>(selects[outPut].functions.Keys);
                foreach (var inPut in keyInputList)
                {
                    var functions1 = selects[outPut].functions;
                    var target     = functions1[inPut];
                    DestroyImmediate((MonoBehaviour)functions[inPut]);
                    DestroyImmediate(target, true);
                    functions1.Remove(inPut);
                    try
                    {
                        inPut.connection.connections.Remove(inPut);
                    }
                    catch (NullReferenceException e)
                    {
                    }
                    Inputs.Remove(inPut);
                }
                DestroyImmediate(selects[outPut], true);
                DestroyImmediate(selects[outPut].selectManager.gameObject);
                selects.Remove(outPut);
                //  Outputs.Remove(outPut);
                Vector2 topLeft = rect.position;
                rect = new Rect(topLeft.x, topLeft.y, 200, 100);
                foreach (NodeInput inPut in outPut.connections)
                {
                    inPut.connection = null;
                }
                Outputs.Remove(outPut);
                DrawConnectors();
                return;
            }
            GUILayout.EndHorizontal();
            selectManager.isActive    = EditorGUILayout.Toggle("활성화", selectManager.isActive);
            selectManager.isOnce      = EditorGUILayout.Toggle("일회용", selects[outPut].selectManager.isOnce);
            selectManager.requireTime = EditorGUILayout.FloatField("소요시간", selectManager.requireTime);
            //  selects[outPut].selectManager.dangers.isActive = EditorGUILayout.Toggle("위험 활성화", selects[outPut].selectManager.dangers.isActive);
            selectManager.dangers.dangerCount = EditorGUILayout.IntField("위험도", selectManager.dangers.dangerCount);
            GUILayout.BeginHorizontal();
            selectOptionIndex = EditorGUILayout.Popup("종류", selectOptionIndex, selectOptions);
            if (GUILayout.Button("기능 추가"))
            {
                NodeInput key;
                Function  executor = null;
                if (!selects.ContainsKey(outPut))
                {
                    return;
                }
                switch (selectOptionIndex)
                {
                case 0:
                    executor = selectManager.gameObject.AddComponent <SpriteChanger>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.ObjectOnly);
                    break;

                case 1:
                    executor = selectManager.gameObject.AddComponent <Enabler>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.General);
                    break;

                case 2:
                    executor = selectManager.gameObject.AddComponent <SoundPlayer>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                    break;

                case 3:
                    executor = selectManager.gameObject.AddComponent <MessageDisplayer>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                    break;

                case 4:
                    executor = selectManager.gameObject.AddComponent <ItemGainer>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.ItemOnly);
                    break;

                case 5:
                    executor = selectManager.gameObject.AddComponent <DangerChanger>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.SelectionOnly);
                    break;

                case 6:
                    executor = selectManager.gameObject.AddComponent <SpriteShower>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                    break;

                case 7:
                    executor = selectManager.gameObject.AddComponent <EventMaker>();
                    key      = NodeInput.Create(this, "기능 출력", IOtype.Closed);
                    break;

                default:
                    executor = null;
                    key      = null;
                    break;
                }
                functions.Add(key, executor);
                DrawNode();
            }
            GUILayout.EndHorizontal();
        }


        List <NodeInput> keyList = new List <NodeInput>(functions.Keys);

        foreach (var item in keyList)
        {
            DrawSelectFunction(outPut, item);
        }

        DrawConnectors();
        if (isExpanded)
        {
            GUILayout.Space(20);
        }
    }