コード例 #1
0
    private void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.Waypoints.Count; i++)
        {
            if (network.Waypoints[i] != null)
            {
                Handles.Label(network.Waypoints[i].position, network.Waypoints[i].name);
            }
        }


        if (network.DisplayMode == PathDisplayMode.Connections)
        {
            ShowConnectionsMode(network);
        }
        else if (network.DisplayMode == PathDisplayMode.Paths)
        {
            ShowNavMeshPath(network);
        }
        else
        {
        }
    }
コード例 #2
0
    //Making UIStart and UIEnd into graphicals sliders
    public override void OnInspectorGUI()
    {
        //Reference to AIWaypointNetwork script
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        //Drop menu
        network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display mode", network.DisplayMode);

        //We will show these slider only in PATH category
        if (network.DisplayMode == PathDisplayMode.Paths)
        {
            //The network.waypoints.Count - 1 is because it counting from 0
            //so it has 6 waypoints (0,1,2,3,4,5)
            //Making sliders for start point of path
            network.UIStart = EditorGUILayout.IntSlider("Waypoint Start",
                                                        network.UIStart, 0, network.waypoints.Count - 1);

            //Making sliders for end point of path
            network.UIEnd = EditorGUILayout.IntSlider("Waypoint End",
                                                      network.UIEnd, 0, network.waypoints.Count - 1);
        }

        DrawDefaultInspector();
        // base.OnInspectorGUI();
    }
    private void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.waypoints.Count; i++)
        {
            Handles.Label(network.waypoints[i].transform.position, "Waypoint " + i);
        }

        if (network.displayMode == PathDisplayMode.Connections)
        {
            Vector3[] linePoints = new Vector3[network.waypoints.Count + 1];

            for (int i = 0; i <= network.waypoints.Count; i++)
            {
                int index = i == network.waypoints.Count ? 0 : i;
                linePoints[i] = network.waypoints[index].position;
            }

            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
        }
        else if (network.displayMode == PathDisplayMode.Paths)
        {
            NavMeshPath path = new NavMeshPath();
            var         from = network.waypoints[network.UIStart].position;
            var         to   = network.waypoints[network.UIEnd].position;
            NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);

            Handles.color = Color.yellow;
            Handles.DrawPolyLine(path.corners);
        }
    }
        void Start()
        {
            pfo       = GetComponent <PathFindingObject>();
            wayPoints = GetComponent <AIWaypointNetwork>();

            setDictionary();

            setPath();
        }
コード例 #5
0
        protected override void Initialize()
        {
            // get the components on the object we need ( should not be null due to require component so no need to check )
            NavAgent                = GetComponentInChildren <NavMeshAgent>();
            waypointNetwork         = FindObjectOfType <AIWaypointNetwork>();
            NavAgent.updateRotation = false;
            NavAgent.updatePosition = true;

            ConstructFSM();
        }
コード例 #6
0
    void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        GUIStyle style = new GUIStyle();

        style.normal.textColor = Color.green;

        for (int i = 0; i < network.Waypoints.Count; i++)
        {
            if (network.Waypoints[i] != null)
            {
                Handles.Label(network.Waypoints[i].position, "Waypoint " + i.ToString(), style);
            }
        }

        if (network.DisplayMode == PathDisplayMode.Connections)
        {
            // + 1 need to loop back to 0(first waypoint)
            Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];

            for (int i = 0; i <= network.Waypoints.Count; i++)
            {
                // Waypoint 5 points back to Waypoint 0
                int index = i != network.Waypoints.Count ? i : 0;

                if (network.Waypoints[index] != null)
                {
                    linePoints[i] = network.Waypoints[index].position;
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                }
            }
            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
        }
        else if (network.DisplayMode == PathDisplayMode.Paths)
        {
            NavMeshPath path = new NavMeshPath();

            if (network.Waypoints[network.UIStart] != null && network.Waypoints[network.UIEnd] != null)
            {
                // Get World Space Position  of start and end
                Vector3 from = network.Waypoints[network.UIStart].position;
                Vector3 to   = network.Waypoints[network.UIEnd].position;

                NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);
                Handles.color = Color.yellow;
                Handles.DrawPolyLine(path.corners);
            }
        }
    }
コード例 #7
0
    private static void DrawPaths(AIWaypointNetwork network)
    {
        NavMeshPath path = new NavMeshPath();
        Vector3     from = network.Waypoints[network.UIFrom].position;
        Vector3     to   = network.Waypoints[network.UITo].position;

        NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);

        Handles.color = Color.yellow;
        Handles.DrawPolyLine(path.corners);
    }
コード例 #8
0
    public override void OnInspectorGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        if (network.pathDisplayMode == PathDisplayMode.NextPath)
        {
            network.UIStart = EditorGUILayout.IntSlider("Start", network.UIStart, 0, network.waypoints.Count - 1);
            network.UIEnd   = EditorGUILayout.IntSlider("End", network.UIEnd, 0, network.waypoints.Count - 1);
        }

        DrawDefaultInspector();
    }
コード例 #9
0
    // Lookup Unity documentation - Editor
    void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.Waypoints.Count; i++)
        {
            // Lookup documentation for Handles
            if (network.Waypoints[i] != null)
            {
                Handles.color = Color.cyan;
            }
            Handles.Label(network.Waypoints[i].position, "Waypoint " + i.ToString());
        }

        if (network.DisplayMode == PathDisplayMode.Connections)
        {
            Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];

            for (int i = 0; i <= network.Waypoints.Count; i++)
            {
                int index = i != network.Waypoints.Count ? i : 0;
                if (network.Waypoints[index] != null)
                {
                    linePoints[i] = network.Waypoints[index].position;
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                }
            }

            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
        }
        else
        {
            if (network.DisplayMode == PathDisplayMode.Paths)
            {
                NavMeshPath path = new NavMeshPath();

                if (network.Waypoints[network.UIStart] != null && network.Waypoints[network.UIEnd] != null)
                {
                    Vector3 from = network.Waypoints[network.UIStart].position;
                    Vector3 to   = network.Waypoints[network.UIEnd].position;

                    // Look up NavMesh in documentation
                    NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);
                    Handles.color = Color.yellow;
                    Handles.DrawPolyLine(path.corners);
                }
            }
        }
    }
コード例 #10
0
    //Render en la vista de escena
    void OnSceneGUI()
    {
        //Obtener referencias de los object con el script waypoint
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        //NOMBRE DEL WAYPOINT
        NameWaypoint(network);


        //Colorar Conections and Path lines waypoints
        NavegationWaypointColor(network);
    }
コード例 #11
0
    public override void OnInspectorGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display Mode", network.DisplayMode);
        if (network.DisplayMode == PathDisplayMode.Paths)
        {
            network.UIStart = EditorGUILayout.IntSlider("Waypoint Start", network.UIStart, 0, network.Waypoints.Count - 1);
            network.UIEnd   = EditorGUILayout.IntSlider("Waypoint End", network.UIEnd, 0, network.Waypoints.Count - 1);
        }
        DrawDefaultInspector();
    }
コード例 #12
0
    private void OnSceneGUI()
    {
        style.normal.textColor = Color.white;

        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.Waypoints.Count; i++)
        {
            if (network.Waypoints[i] != null)
            {
                Handles.Label(network.Waypoints[i].position, "Waypoint " + i.ToString(), style);
            }
        }

        if (network.displayMode == PathDisplayMode.Connections)
        {
            Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];

            for (int i = 0; i < linePoints.Length; i++)
            {
                int index = i != network.Waypoints.Count ? i : 0;

                if (network.Waypoints.Count > 0)
                {
                    if (network.Waypoints[index] != null)
                    {
                        linePoints[i] = network.Waypoints[index].position;
                    }
                    else
                    {
                        Debug.Log("waypoint not set!!");
                    }
                }
            }
            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
        }
        else if (network.displayMode == PathDisplayMode.Paths)
        {
            NavMeshPath path = new NavMeshPath();

            if (network.Waypoints[network.uiStart] != null && network.Waypoints[network.uiEnd] != null)
            {
                Vector3 from = network.Waypoints[network.uiStart].position;
                Vector3 to   = network.Waypoints[network.uiEnd].position;

                NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);

                Handles.color = Color.yellow;
                Handles.DrawPolyLine(path.corners);
            }
        }
    }
    void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.Waypoints.Count; i++)
        {
            if (network.Waypoints[i] != null)
            {
                Handles.Label(network.Waypoints[i].position, "Waypoints " + i);
            }
            else
            {
                return;
            }
        }

        if (network.DisplayMode == PathDisplayMode.Connections)
        {
            Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];
            for (int i = 0; i <= network.Waypoints.Count; i++)
            {
                int index = i != network.Waypoints.Count ? i : 0;
                if (network.Waypoints[index] != null)
                {
                    linePoints[i] = network.Waypoints[index].position;
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                }
            }

            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
        }
        else if (network.DisplayMode == PathDisplayMode.Paths)
        {
            UnityEngine.AI.NavMeshPath path = new UnityEngine.AI.NavMeshPath();

            if (network.Waypoints[network.UIStart] != null && network.Waypoints[network.UIEnd] != null)
            {
                Vector3 from = network.Waypoints[network.UIStart].position;
                Vector3 to   = network.Waypoints[network.UIEnd].position;

                UnityEngine.AI.NavMesh.CalculatePath(from, to, UnityEngine.AI.NavMesh.AllAreas, path);
                Handles.color = Color.yellow;
                Handles.DrawPolyLine(path.corners);
            }
        }
        else if (network.DisplayMode == PathDisplayMode.None)
        {
        }
    }
コード例 #14
0
    private void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.Waypoints.Count; i++)                                  // For every Waypoint in the scene
        {
            if (network.Waypoints[i] != null)                                              //If it isn't null do this
            {
                Handles.Label(network.Waypoints[i].position, "Waypoints " + i.ToString()); //Label around its position it's number
            }
        }


        if (network.DisplayMode == PathDisplayMode.Connections)
        {
            Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];

            for (int i = 0; i <= network.Waypoints.Count; i++)

            {
                int index = i != network.Waypoints.Count ? i : 0;
                if (network.Waypoints[index] != null)
                {
                    linePoints[i] = network.Waypoints[index].position;
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                }
            }
            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
        }
        else
        {
            if (network.DisplayMode == PathDisplayMode.Paths)
            {
                NavMeshPath path = new NavMeshPath();

                if (network.Waypoints[network.UIStart] != null && network.Waypoints[network.UIEnd] != null)
                {
                    Vector3 from = network.Waypoints[network.UIStart].position;
                    Vector3 to   = network.Waypoints[network.UIEnd].position;

                    NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);
                    Handles.color = Color.green;
                    Handles.DrawPolyLine(path.corners);
                }
            }
        }
    }
コード例 #15
0
    public override void OnInspectorGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        EditorGUILayout.BeginVertical();
        network.displayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display Type", network.displayMode);
        if (network.displayMode == PathDisplayMode.Path)
        {
            network.pathStart = EditorGUILayout.IntSlider("Path Start", network.pathStart, 0, network.Waypoints.Count);
            network.pathEnd   = EditorGUILayout.IntSlider("Path End", network.pathEnd, 0, network.Waypoints.Count);
        }
        EditorGUILayout.EndVertical();
        DrawDefaultInspector();
    }
コード例 #16
0
    private void PathsMode(AIWaypointNetwork network)
    {
        NavMeshPath path = new NavMeshPath();

        if (network.Waypoints[network.UIStart] != null && network.Waypoints[network.UIEnd] != null)
        {
            Vector3 from = network.Waypoints[network.UIStart].position;
            Vector3 to   = network.Waypoints[network.UIEnd].position;

            NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);
            Handles.color = Color.yellow;
            Handles.DrawPolyLine(path.corners);
        }
    }
コード例 #17
0
    private void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.waypoints.Count; i++)
        {
            Handles.color = Color.blue;
            if (network.waypoints[i] != null)
            {
                Handles.Label(network.waypoints[i].transform.position, "WayPoint " + i.ToString());
            }
        }

        if (network.pathDisplayMode == PathDisplayMode.Connections)
        {
            Vector3[] linePoints = new Vector3[network.waypoints.Count + 1];

            for (int i = 0; i <= network.waypoints.Count; i++)
            {
                int index = i != network.waypoints.Count ? i : 0;

                if (network.waypoints[index] != null)
                {
                    linePoints[i] = network.waypoints[index].transform.position;
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                }
            }

            Handles.color = Color.blue;
            Handles.DrawPolyLine(linePoints);
        }
        else if (network.pathDisplayMode == PathDisplayMode.NextPath)
        {
            NavMeshPath path = new NavMeshPath();
            Vector3     from = network.waypoints[network.UIStart].position;
            Vector3     to   = network.waypoints[network.UIEnd].position;

            NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);

            Handles.color = Color.green;
            Handles.DrawPolyLine(path.corners);
        }
        else if (network.pathDisplayMode == PathDisplayMode.AllPaths)
        {
        }
    }
コード例 #18
0
    private void OnSceneGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        for (int i = 0; i < network.Waypoints.Count; i++)
        {
            if (network.Waypoints[i] != null)
            {
                Handles.Label(network.Waypoints[i].position, "Waypoint " + i.ToString());
            }
        } // End for loop

        if (network.DisplayMode == PathDisplayMode.Connections)
        {
            Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];

            for (int i = 0; i <= network.Waypoints.Count; i++)
            {
                int index = i != network.Waypoints.Count ? i : 0; // After last waypoint get the waypoint at first index

                if (network.Waypoints[index] != null)
                {
                    linePoints[i] = network.Waypoints[index].position;
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                }
            } // End for loop

            Handles.color = Color.cyan;
            Handles.DrawPolyLine(linePoints);
        } // End if
        else
        {
            NavMeshPath path = new NavMeshPath();

            if (network.Waypoints[network.UIStart] != null && network.Waypoints[network.UIEnd] != null) // If start and/or end points are not null
            {
                Vector3 startPoint = network.Waypoints[network.UIStart].position;
                Vector3 endPoint   = network.Waypoints[network.UIEnd].position;

                NavMesh.CalculatePath(startPoint, endPoint, NavMesh.AllAreas, path);

                Handles.color = Color.green;
                Handles.DrawPolyLine(path.corners);
            }
        }
    } // End OnSceneGUI
コード例 #19
0
    // override must be provided to override the OnInspectorGui()
    public override void OnInspectorGUI()
    {
        // this will set the ai waypoint targets to a varb
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display Mode:  ", network.DisplayMode);

        if (network.DisplayMode == PathDisplayMode.PATH)
        {
            network.UIStart = EditorGUILayout.IntSlider("Waypoint Start Path:  ", network.UIStart, 0, network.Waypoints.Count - 1);
            network.UIEnd   = EditorGUILayout.IntSlider("Waypoint End Path: ", network.UIEnd, 0, network.Waypoints.Count - 1);
        }
        // this will draw the current default inspector
        DrawDefaultInspector();
    }
コード例 #20
0
        /// <summary>
        ///     Overriding the default inspector to customize the look of it
        /// </summary>
        public override void OnInspectorGUI()
        {
            // The order we create them in will be how they show up
            AIWaypointNetwork network = (AIWaypointNetwork)target;

            network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup(label: "Display Mode", selected: network.DisplayMode);
            if (network.DisplayMode == PathDisplayMode.Paths)
            {
                network.UIStart = EditorGUILayout.IntSlider(label: "Waypoint Start", value: network.UIStart, leftValue: 0, rightValue: network.Waypoints.Count - 1);
                network.UIEnd   = EditorGUILayout.IntSlider(label: "Waypoint End", value: network.UIEnd, leftValue: 0, rightValue: network.Waypoints.Count - 1);
            }

            //base.OnInspectorGUI();
            DrawDefaultInspector();
        }
コード例 #21
0
    void ShowNavMeshPath(AIWaypointNetwork network)
    {
        NavMeshPath path = new NavMeshPath();

        if (network.Waypoints[network.UIStart] == null || network.Waypoints[network.UIEnd] == null)
        {
            return;
        }
        Vector3 from = network.Waypoints[network.UIStart].position;
        Vector3 to   = network.Waypoints[network.UIEnd].position;

        NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);
        Handles.color = Color.yellow;
        Handles.DrawPolyLine(path.corners);
    }
コード例 #22
0
    void OnSceneGUI()
    {
        AIWaypointNetwork aiWaypointNetwork = (AIWaypointNetwork)target;

        Vector3[] linePoints = new Vector3[aiWaypointNetwork.Waypoints.Count + 1];

        Handles.color = Color.magenta;
        for (int i = 0; i < aiWaypointNetwork.Waypoints.Count; i++)
        {
            if (aiWaypointNetwork.Waypoints[i] != null)
            {
                Handles.Label(aiWaypointNetwork.Waypoints[i].position, ("Waypoint " + i.ToString()));
            }
        }

        if (aiWaypointNetwork.displayMode == PathDisplayMode.Connections)
        {
            for (int i = 0; i < aiWaypointNetwork.Waypoints.Count; i++)
            {
                int index = i != aiWaypointNetwork.Waypoints.Count ? 1 : 0;

                if (aiWaypointNetwork.Waypoints[i] != null)
                {
                    linePoints[i] = aiWaypointNetwork.Waypoints[i].position;
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                }

                Handles.color = Color.cyan;
                Handles.DrawPolyLine(linePoints);
            }
        }
        else if (aiWaypointNetwork.displayMode == PathDisplayMode.Path)
        {
            NavMeshPath path = new NavMeshPath();

            Vector3 pathStart = aiWaypointNetwork.Waypoints[aiWaypointNetwork.pathStart].position;
            Vector3 pathEnd   = aiWaypointNetwork.Waypoints[aiWaypointNetwork.pathEnd].position;

            if (NavMesh.CalculatePath(pathStart, pathEnd, NavMesh.AllAreas, path))
            {
                Handles.color = Color.yellow;
                Handles.DrawPolyLine(path.corners);
            }
        }
    }
コード例 #23
0
    private void NameWaypoint(AIWaypointNetwork network)
    {
        //cambiar color letras
        GUIStyle style = new GUIStyle();

        style.normal.textColor = Color.white;

        //iterar waypoint y asignacion del nombre
        for (int i = 0; i < network._waypoints.Count; i++)
        {
            if (network._waypoints[i] != null)
            {
                Handles.Label(network._waypoints[i].position, "Waypoint " + i.ToString(), style);
            }
        }
    }
コード例 #24
0
    public override void OnInspectorGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        //Enumerar opeciones en el inpector
        network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display mode:", network.DisplayMode);

        //Asignar Waypoint Inicial y Final
        if (network.DisplayMode == PathDisplayMode.Paths)
        {
            network.WInitial = EditorGUILayout.IntSlider("Waypoint Start ", network.WInitial, 0, network._waypoints.Count - 1);
            network.WEnd     = EditorGUILayout.IntSlider("Waypoint End ", network.WEnd, 0, network._waypoints.Count - 1);
        }

        DrawDefaultInspector();
    }
コード例 #25
0
    // Below function overwrites the default ui controls in inspector panel
    public override void OnInspectorGUI()
    {
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        // Cast to PathDisplayMode ???
        network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display Mode", network.DisplayMode);

        if (network.DisplayMode == PathDisplayMode.Paths)
        {
            network.UIStart = EditorGUILayout.IntSlider("Waypoint Start", network.UIStart, 0, network.Waypoints.Capacity + 1);
            network.UIEnd   = EditorGUILayout.IntSlider("Waypoint Start", network.UIEnd, 0, network.Waypoints.Capacity + 1);
        }


        // Below method worksin combination with [HideInInspector] in AIWayPointNetwork.cs
        DrawDefaultInspector();
    }
    // --------------------------------------------------------------------------------
    // Name	:	OnInspectorGUI (Override)
    // Desc	:	Called by Unity Editor when the Inspector needs repainting for an
    //			AIWaypointNetwork Component
    // --------------------------------------------------------------------------------
    public override void OnInspectorGUI()
    {
        // Get reference to selected component
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        // Show the Display Mode Enumeration Selector
        network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display Mode", network.DisplayMode);

        // If we are in Paths display mode then display the integer sliders for the Start and End waypoint indices
        if (network.DisplayMode == PathDisplayMode.Paths)
        {
            network.UIStart = EditorGUILayout.IntSlider("Waypoint Start", network.UIStart, 0, network.Waypoints.Count - 1);
            network.UIEnd   = EditorGUILayout.IntSlider("Waypoint End", network.UIEnd, 0, network.Waypoints.Count - 1);
        }

        // Tell Unity to do its default drawing of all serialized members that are NOT hidden in the inspector
        DrawDefaultInspector();
    }
コード例 #27
0
    // --------------------------------------------------------------------------------
    // Name	:	OnInspectorGUI (Override)
    // Desc	:	由Unity Editor调用,用于调整Unity Inspector
    // --------------------------------------------------------------------------------
    public override void OnInspectorGUI()
    {
        // 获取目标组件
        AIWaypointNetwork network = (AIWaypointNetwork)target;

        //调整显示模式
        network.DisplayMode = (PathDisplayMode)EditorGUILayout.EnumPopup("Display Mode", network.DisplayMode);

        //如果显示模式为Paths,则显示起始和终止位置输入框
        if (network.DisplayMode == PathDisplayMode.Paths)
        {
            network.UIStart = EditorGUILayout.IntSlider("Waypoint Start", network.UIStart, 0, network.Waypoints.Count - 1);
            network.UIEnd   = EditorGUILayout.IntSlider("Waypoint End", network.UIEnd, 0, network.Waypoints.Count - 1);
        }

        // 渲染
        DrawDefaultInspector();
    }
コード例 #28
0
    void ShowConnectionsMode(AIWaypointNetwork network)
    {
        Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];

        for (int i = 0; i <= network.Waypoints.Count; i++)
        {
            int index = i != network.Waypoints.Count ? i : 0;
            if (network.Waypoints[index] != null)
            {
                linePoints[i] = network.Waypoints[index].position;
            }
            else
            {
                linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
            }
        }
        Handles.color = Color.cyan;
        Handles.DrawAAPolyLine(linePoints);
    }
コード例 #29
0
    private static void DrawConnections(AIWaypointNetwork network)
    {
        Vector3[] linePoints = new Vector3[network.Waypoints.Count + 1];

        for (int waypointIndex = 0; waypointIndex < network.Waypoints.Count; waypointIndex++)
        {
            int lineIndex = waypointIndex != network.Waypoints.Count ? waypointIndex : 0;
            if (network.Waypoints[waypointIndex])
            {
                linePoints[waypointIndex] = network.Waypoints[lineIndex].position;
            }
            else
            {
                linePoints[waypointIndex] = Vector3.zero;
            }
        }
        linePoints[linePoints.Length - 1] = linePoints[0];
        Handles.color = Color.cyan;
        Handles.DrawAAPolyLine(linePoints);
    }
コード例 #30
0
    private void NavegationWaypointColor(AIWaypointNetwork network)
    {
        if (network.DisplayMode == PathDisplayMode.Connections)
        {
            //Inicializar un vector vacio con la cantidad de waypoint
            Vector3[] linePoints = new Vector3[network._waypoints.Count];

            for (int i = 0; i < network._waypoints.Count; i++)
            {
                // index va a tomar el valor de la posicion distinta a la cantidad de waypoint o 0.
                int index = i != network._waypoints.Count ? i : 0;

                if (network._waypoints[index] != null)
                {
                    linePoints[i] = network._waypoints[index].position;
                    //Debug.Log("EN FOR" + linePoints[i]);
                }
                else
                {
                    linePoints[i] = new Vector3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity);
                    Debug.Log("EN FOR" + linePoints[i]);
                }
            }

            //Cambiar color a la linea
            Handles.color = Color.cyan;
            //Metodo magico para dibujar los vectores de los waypoint
            Handles.DrawPolyLine(linePoints);
        }
        else if (network.DisplayMode == PathDisplayMode.Paths)
        {
            NavMeshPath path = new NavMeshPath();
            Vector3     from = network._waypoints[network.WInitial].position;
            Vector3     to   = network._waypoints[network.WEnd].position;

            NavMesh.CalculatePath(from, to, NavMesh.AllAreas, path);

            Handles.color = Color.yellow;
            Handles.DrawPolyLine(path.corners);
        }
    }