Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        //GUILayout.Toggle(viewKeyHeld, "is ALT held?", GUILayout.Width(50));
        DrawDefaultInspector();
        GUILayout.BeginHorizontal("box");
        if (m_editMode)
        {
            if (GUILayout.Button("Apply", GUILayout.Width(60)))
            {
                if (!thisObject.worldContainsEndNode || !thisObject.worldContainsStartNode)
                {
                    Debug.LogError("Make sure the path contains a valid Start and End node.");
                    return;
                }

                //AstarPath.FindAstarPath();

                AstarPath.active.Scan();

                thisObject.OnUpdateNode?.Invoke();
                m_editMode = false;
            }

            if (GUILayout.Button("Cancel", GUILayout.Width(60)))
            {
                thisObject.worldContainsEndNode   = false;
                thisObject.worldContainsStartNode = false;
                thisObject.isStartNode            = false;
                thisObject.isEndNode = false;

                thisObject.RemoveNodes();

                AstarPath.active.Scan();
                m_editMode = false;
            }
        }
        else
        {
            if (GUILayout.Button("Create Node Track", GUILayout.Width(200)))
            {
                thisObject.OnBeginNodeCreation?.Invoke();
                m_editMode = true;
            }

            if (GUILayout.Button("Remove All Nodes", GUILayout.Width(200)))
            {
                thisObject.worldContainsEndNode   = false;
                thisObject.worldContainsStartNode = false;
                thisObject.isStartNode            = false;
                thisObject.isEndNode = false;

                thisObject.RemoveNodes();

                AstarPath.active.Scan();
                m_editMode = false;
            }
        }
        GUILayout.EndHorizontal();
    }