Beispiel #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        pathFinder = GameObject.Find("PathFinder").GetComponent <TileBasedPathFindingManager>();

        if (GUILayout.Button("Connect"))
        {
            GameObject[] points = Selection.gameObjects;
            if (points.Length == 2 && points[0].GetComponent <Tile>() != null && points[1].GetComponent <Tile>() != null)
            {
                pathFinder.ConnectPath(points[0], points[1]);
            }
        }

        if (GUILayout.Button("Disconnect"))
        {
            GameObject[] points = Selection.gameObjects;
            if (points.Length == 2 && points[0].GetComponent <Tile>() != null && points[1].GetComponent <Tile>() != null)
            {
                pathFinder.DisconnectPath(points[0], points[1]);
            }
        }

        // 1. update the dirty data
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        //pathFinder.test = EditorGUILayout.Toggle("haha", pathFinder.test);
        pathFinder = (TileBasedPathFindingManager)target;

        if (GUILayout.Button("Add Tile"))
        {
            GameObject newTile = pathFinder.AddTile();
            Selection.activeGameObject = newTile;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
    }