Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        SceneGraph sceneGraph = (SceneGraph)target; //Script del grafo


        if (GUILayout.Button("Crear vertice"))
        {
            sceneGraph.AddVertex();
        }

        //Crear arcos



        DrawDefaultInspector(); //mostrar listas
        GUILayout.BeginHorizontal();

        EditorGUIUtility.fieldWidth = 5;

        GUILayout.Label("V1");
        vertice1 = EditorGUILayout.IntField(vertice1);
        GUILayout.Label("V2");
        vertice2 = EditorGUILayout.IntField(vertice2);

        GUILayout.EndHorizontal();

        if (GUILayout.Button("Crear arco"))
        {
            sceneGraph.AddArc(vertice1, vertice2);
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("Vertice");
        verticeElim = EditorGUILayout.IntField(verticeElim);
        if (GUILayout.Button("Eliminar vertice"))
        {
            sceneGraph.RemoveVertex(verticeElim);
        }

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("V1");
        arcoElim1 = EditorGUILayout.IntField(arcoElim1);
        GUILayout.Label("V2");
        arcoElim2 = EditorGUILayout.IntField(arcoElim2);
        if (GUILayout.Button("Eliminar arco"))
        {
            sceneGraph.RemoveArc(arcoElim1, arcoElim2);
        }

        GUILayout.EndHorizontal();


        if (GUILayout.Button("Construir grafo"))
        {
            sceneGraph.CreateGraph();
        }
    }