Inheritance: MonoBehaviour
        public static GraphUpdateObject GetGUO(this GraphUpdateScene gus)
        {
            GraphUpdateObject guo = null;

            GetGUO(gus, ref guo);
            return(guo);
        }
示例#2
0
 public void OnEnable()
 {
     _graphUpdate = gameObject.GetComponent <GraphUpdateScene>() ?? gameObject.AddComponent <GraphUpdateScene>();
     _graphUpdate.modifyWalkability = true;
     sAllObstacles.Add(this);
     EventManager.instance.AddListener <LevelStartEvent>(OnLevelStart);
 }
示例#3
0
 void Start ()
 {
     if (positionSelector)
     {
         var r = positionSelector.GetComponent<MeshRenderer>();
         positionSelectorMaterial = r.material;
         positionSelectorInitialColor = r.sharedMaterial.color;
         positionSelectorGraph =  positionSelector.GetComponent<GraphUpdateScene>();
     }
 }
示例#4
0
	// Use this for initialization
	void Start () 
	{
		m_Difficulty = 5;
		m_Score = 0;
		m_Round = 1;
		m_RoundLimit = m_Round * 5;
		m_RoundTime = m_Round * 15;
		m_SpawnTime = m_Difficulty;
		m_Shortest = Mathf.Infinity;
		m_Scalar = 1;
		m_Ready = m_Done = false;

		tehPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
		enemyPool = GameObject.FindGameObjectWithTag("Container");
		cam = GameObject.FindGameObjectWithTag("MainCamera");
		camSize = cam.camera.orthographicSize;
		ground = GameObject.FindGameObjectWithTag("Ground");
		currentScale = ground.transform.localScale;

		graph = (GridGraph)GameObject.FindGameObjectWithTag("Graph").GetComponent<AstarPath>().graphs[0];
		gus = GameObject.FindGameObjectWithTag ("Update").GetComponent<GraphUpdateScene> ();
		roundGUI = GameObject.FindGameObjectWithTag ("RoundGUI").GetComponent<GUIText> ();
	}
示例#5
0
    public override void OnInspectorGUI()
    {
        GraphUpdateScene script = target as GraphUpdateScene;

#if !UNITY_LE_4_3
        Undo.RecordObject(script, "modify settings on GraphUpdateObject");
#endif

        if (script.points == null)
        {
            script.points = new Vector3[0];
        }

        if (script.points == null || script.points.Length == 0)
        {
            if (script.GetComponent <Collider>() != null)
            {
                EditorGUILayout.HelpBox("No points, using collider.bounds", MessageType.Info);
            }
            else if (script.GetComponent <Renderer>() != null)
            {
                EditorGUILayout.HelpBox("No points, using renderer.bounds", MessageType.Info);
            }
            else
            {
                EditorGUILayout.HelpBox("No points and no collider or renderer attached, will not affect anything\nPoints can be added using the transform tool and holding shift", MessageType.Warning);
            }
        }

        Vector3[] prePoints = script.points;

#if UNITY_4
        EditorGUILayout.PropertyField(serializedObject.FindProperty("points"), true);
        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
        }
#else
        DrawDefaultInspector();
#endif

#if UNITY_LE_4_3
        EditorGUI.indentLevel = 1;
#else
        EditorGUI.indentLevel = 0;
#endif

        script.updatePhysics = EditorGUILayout.Toggle(new GUIContent("Update Physics", "Perform similar calculations on the nodes as during scan.\n" +
                                                                     "Grid Graphs will update the position of the nodes and also check walkability using collision.\nSee online documentation for more info."), script.updatePhysics);

        if (script.updatePhysics)
        {
            EditorGUI.indentLevel++;
            script.resetPenaltyOnPhysics = EditorGUILayout.Toggle(new GUIContent("Reset Penalty On Physics", "Will reset the penalty to the default value during the update."), script.resetPenaltyOnPhysics);
            EditorGUI.indentLevel--;
        }

        script.updateErosion = EditorGUILayout.Toggle(new GUIContent("Update Erosion", "Recalculate erosion for grid graphs.\nSee online documentation for more info"), script.updateErosion);

        if (prePoints != script.points)
        {
            script.RecalcConvex();
            HandleUtility.Repaint();
        }

        bool preConvex = script.convex;
        script.convex = EditorGUILayout.Toggle(new GUIContent("Convex", "Sets if only the convex hull of the points should be used or the whole polygon"), script.convex);
        if (script.convex != preConvex)
        {
            script.RecalcConvex(); HandleUtility.Repaint();
        }

        script.minBoundsHeight = EditorGUILayout.FloatField(new GUIContent("Min Bounds Height", "Defines a minimum height to be used for the bounds of the GUO.\nUseful if you define points in 2D (which would give height 0)"), script.minBoundsHeight);
        script.applyOnStart    = EditorGUILayout.Toggle("Apply On Start", script.applyOnStart);
        script.applyOnScan     = EditorGUILayout.Toggle("Apply On Scan", script.applyOnScan);

        script.modifyWalkability = EditorGUILayout.Toggle(new GUIContent("Modify walkability", "If true, walkability of all nodes will be modified"), script.modifyWalkability);
        if (script.modifyWalkability)
        {
            EditorGUI.indentLevel++;
            script.setWalkability = EditorGUILayout.Toggle(new GUIContent("Walkability", "Nodes' walkability will be set to this value"), script.setWalkability);
            EditorGUI.indentLevel--;
        }

        script.penaltyDelta = EditorGUILayout.IntField(new GUIContent("Penalty Delta", "A penalty will be added to the nodes, usually you need very large values, at least 1000-10000.\n" +
                                                                      "A higher penalty will mean that agents will try to avoid those nodes."), script.penaltyDelta);

        if (script.penaltyDelta < 0)
        {
            EditorGUILayout.HelpBox("Be careful when lowering the penalty. Negative penalties are not supported and will instead underflow and get really high.\n" +
                                    "You can set an initial penalty on graphs (see their settings) and then lower them like this to get regions which are easier to traverse.", MessageType.Warning);
        }

        script.modifyTag = EditorGUILayout.Toggle(new GUIContent("Modify Tags", "Should the tags of the nodes be modified"), script.modifyTag);
        if (script.modifyTag)
        {
            EditorGUI.indentLevel++;
            script.setTag = EditorGUILayout.Popup("Set Tag", script.setTag, AstarPath.FindTagNames());
            EditorGUI.indentLevel--;
        }

        if (GUILayout.Button("Tags can be used to restrict which units can walk on what ground. Click here for more info", "HelpBox"))
        {
            Application.OpenURL(AstarPathEditor.GetURL("tags"));
        }

        EditorGUILayout.Separator();

        bool worldSpace = EditorGUILayout.Toggle(new GUIContent("Use World Space", "Specify coordinates in world space or local space. When using local space you can move the GameObject " +
                                                                "around and the points will follow.\n" +
                                                                "Some operations, like calculating the convex hull, and snapping to Y will change axis depending on how the object is rotated if world space is not used."
                                                                ), script.useWorldSpace);
        if (worldSpace != script.useWorldSpace)
        {
#if !UNITY_LE_4_3
            Undo.RecordObject(script, "switch use-world-space");
#endif
            script.ToggleUseWorldSpace();
        }

#if UNITY_4
        EditorGUI.BeginChangeCheck();
#endif
        script.lockToY = EditorGUILayout.Toggle("Lock to Y", script.lockToY);

        if (script.lockToY)
        {
            EditorGUI.indentLevel++;
            script.lockToYValue = EditorGUILayout.FloatField("Lock to Y value", script.lockToYValue);
            EditorGUI.indentLevel--;

#if !UNITY_LE_4_3
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(script, "change Y locking");
            }
#endif
            script.LockToY();
        }

        EditorGUILayout.Separator();

        if (GUILayout.Button("Clear all points"))
        {
#if UNITY_LE_4_3
            Undo.RegisterUndo(script, "Removed All Points");
#endif
            script.points = new Vector3[0];
            EditorUtility.SetDirty(target);
            script.RecalcConvex();
        }

        if (GUI.changed)
        {
                        #if UNITY_LE_4_3
            Undo.RegisterUndo(script, "Modify Settings on GraphUpdateObject");
                        #endif
            EditorUtility.SetDirty(target);
        }
    }
示例#6
0
    public void OnSceneGUI()
    {
        GraphUpdateScene script = target as GraphUpdateScene;

        if (script.points == null)
        {
            script.points = new Vector3[0];
        }
        List <Vector3> points = Pathfinding.Util.ListPool <Vector3> .Claim();

        points.AddRange(script.points);

        Matrix4x4 invMatrix = script.useWorldSpace ? Matrix4x4.identity : script.transform.worldToLocalMatrix;

        if (!script.useWorldSpace)
        {
            Matrix4x4 matrix = script.transform.localToWorldMatrix;
            for (int i = 0; i < points.Count; i++)
            {
                points[i] = matrix.MultiplyPoint3x4(points[i]);
            }
        }


        if (Tools.current != Tool.View && Event.current.type == EventType.Layout)
        {
            for (int i = 0; i < script.points.Length; i++)
            {
                HandleUtility.AddControl(-i - 1, HandleUtility.DistanceToLine(points[i], points[i]));
            }
        }

        if (Tools.current != Tool.View)
        {
            HandleUtility.AddDefaultControl(0);
        }

        for (int i = 0; i < points.Count; i++)
        {
            if (i == selectedPoint && Tools.current == Tool.Move)
            {
                Handles.color = PointSelectedColor;
#if UNITY_LE_4_3
                Undo.SetSnapshotTarget(script, "Moved Point");
#else
                Undo.RecordObject(script, "Moved Point");
#endif
                Handles.SphereCap(-i - 1, points[i], Quaternion.identity, HandleUtility.GetHandleSize(points[i]) * pointGizmosRadius * 2);
                Vector3 pre  = points[i];
                Vector3 post = Handles.PositionHandle(points[i], Quaternion.identity);
                if (pre != post)
                {
                    script.points[i] = invMatrix.MultiplyPoint3x4(post);
                }
            }
            else
            {
                Handles.color = PointColor;
                Handles.SphereCap(-i - 1, points[i], Quaternion.identity, HandleUtility.GetHandleSize(points[i]) * pointGizmosRadius);
            }
        }

#if UNITY_LE_4_3
        if (Input.GetMouseButtonDown(0))
        {
            // Register the undos when we press the Mouse button.
            Undo.CreateSnapshot();
            Undo.RegisterSnapshot();
        }
#endif

        if (Event.current.type == EventType.MouseDown)
        {
            int pre = selectedPoint;
            selectedPoint = -(HandleUtility.nearestControl + 1);
            if (pre != selectedPoint)
            {
                GUI.changed = true;
            }
        }

        if (Event.current.type == EventType.MouseDown && Event.current.shift && Tools.current == Tool.Move)
        {
            if (((int)Event.current.modifiers & (int)EventModifiers.Alt) != 0)
            {
                //int nearestControl = -(HandleUtility.nearestControl+1);

                if (selectedPoint >= 0 && selectedPoint < points.Count)
                {
#if UNITY_LE_4_3
                    Undo.RegisterUndo(script, "Removed Point");
#else
                    Undo.RecordObject(script, "Removed Point");
#endif
                    List <Vector3> arr = new List <Vector3>(script.points);
                    arr.RemoveAt(selectedPoint);
                    points.RemoveAt(selectedPoint);
                    script.points = arr.ToArray();
                    script.RecalcConvex();
                    GUI.changed = true;
                }
            }
            else if (((int)Event.current.modifiers & (int)EventModifiers.Control) != 0 && points.Count > 1)
            {
                int   minSeg  = 0;
                float minDist = float.PositiveInfinity;
                for (int i = 0; i < points.Count; i++)
                {
                    float dist = HandleUtility.DistanceToLine(points[i], points[(i + 1) % points.Count]);
                    if (dist < minDist)
                    {
                        minSeg  = i;
                        minDist = dist;
                    }
                }

                System.Object hit = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(Event.current.mousePosition));
                if (hit != null)
                {
                    RaycastHit rayhit = (RaycastHit)hit;
#if UNITY_LE_4_3
                    Undo.RegisterUndo(script, "Added Point");
#else
                    Undo.RecordObject(script, "Added Point");
#endif
                    List <Vector3> arr = Pathfinding.Util.ListPool <Vector3> .Claim();

                    arr.AddRange(script.points);

                    points.Insert(minSeg + 1, rayhit.point);
                    if (!script.useWorldSpace)
                    {
                        rayhit.point = invMatrix.MultiplyPoint3x4(rayhit.point);
                    }

                    arr.Insert(minSeg + 1, rayhit.point);
                    script.points = arr.ToArray();
                    script.RecalcConvex();
                    Pathfinding.Util.ListPool <Vector3> .Release(arr);

                    GUI.changed = true;
                }
            }
            else
            {
                System.Object hit = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(Event.current.mousePosition));
                if (hit != null)
                {
                    RaycastHit rayhit = (RaycastHit)hit;

#if UNITY_LE_4_3
                    Undo.RegisterUndo(script, "Added Point");
#else
                    Undo.RecordObject(script, "Added Point");
#endif

                    Vector3[] arr = new Vector3[script.points.Length + 1];
                    for (int i = 0; i < script.points.Length; i++)
                    {
                        arr[i] = script.points[i];
                    }
                    points.Add(rayhit.point);
                    if (!script.useWorldSpace)
                    {
                        rayhit.point = invMatrix.MultiplyPoint3x4(rayhit.point);
                    }

                    arr[script.points.Length] = rayhit.point;
                    script.points             = arr;
                    script.RecalcConvex();
                    GUI.changed = true;
                }
            }
            Event.current.Use();
        }

        if (Event.current.shift && Event.current.type == EventType.MouseDrag)
        {
            //Event.current.Use ();
        }

#if !UNITY_LE_4_3
        if (lastUndoGroup != Undo.GetCurrentGroup())
        {
            script.RecalcConvex();
        }
#endif

        Pathfinding.Util.ListPool <Vector3> .Release(points);

        if (GUI.changed)
        {
            HandleUtility.Repaint(); EditorUtility.SetDirty(target);
        }
    }
        public static void GetGUO(this GraphUpdateScene gus, ref GraphUpdateObject guo)
        {
            if (gus.points == null || gus.points.Length == 0)
            {
                var polygonCollider = gus.GetComponent <PolygonCollider2D>();
                if (polygonCollider != null)
                {
                    var       points2D = polygonCollider.points;
                    Vector3[] pts      = new Vector3[points2D.Length];
                    for (int i = 0; i < pts.Length; i++)
                    {
                        var p = points2D[i] + polygonCollider.offset;
                        pts[i] = new Vector3(p.x, 0, p.y);
                    }

                    var mat   = gus.transform.localToWorldMatrix * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one);
                    var shape = new GraphUpdateShape(gus.points, gus.convex, mat, gus.minBoundsHeight);
                    if (guo == null)
                    {
                        guo = new GraphUpdateObject();
                    }
                    guo.bounds = shape.GetBounds();
                    guo.shape  = shape;
                }
                else
                {
                    var bounds = gus.GetBounds();
                    if (bounds.center == Vector3.zero && bounds.size == Vector3.zero)
                    {
                        Debug.LogError("Cannot apply GraphUpdateScene, no points defined and no renderer or collider attached", gus);
                    }

                    if (guo == null)
                    {
                        guo = new GraphUpdateObject(bounds);
                    }
                    else
                    {
                        guo.bounds = bounds;
                    }
                    guo.shape = null;
                }
            }
            else
            {
                GraphUpdateShape shape;

                // Used for compatibility with older versions
                var worldPoints = new Vector3[gus.points.Length];
                for (int i = 0; i < gus.points.Length; i++)
                {
                    worldPoints[i] = gus.transform.TransformPoint(gus.points[i]);
                }
                shape = new GraphUpdateShape(worldPoints, gus.convex, Matrix4x4.identity, gus.minBoundsHeight);

                if (guo == null)
                {
                    guo = new GraphUpdateObject();
                }
                guo.bounds = shape.GetBounds();
                guo.shape  = shape;
            }

            guo.nnConstraint          = NNConstraint.None;
            guo.modifyWalkability     = gus.modifyWalkability;
            guo.setWalkability        = gus.setWalkability;
            guo.addPenalty            = gus.penaltyDelta;
            guo.updatePhysics         = gus.updatePhysics;
            guo.updateErosion         = gus.updateErosion;
            guo.resetPenaltyOnPhysics = gus.resetPenaltyOnPhysics;

            guo.modifyTag = gus.modifyTag;
            guo.setTag    = gus.setTag;
        }
    public void OnSceneGUI()
    {
        GraphUpdateScene script = target as GraphUpdateScene;

        if (script.points == null)
        {
            script.points = new Vector3[0];
        }

        if (Event.current.type == EventType.Layout)
        {
            for (int i = 0; i < script.points.Length; i++)
            {
                HandleUtility.AddControl(-i - 1, HandleUtility.DistanceToLine(script.points[i], script.points[i]));
            }
        }
        HandleUtility.AddDefaultControl(0);

        for (int i = 0; i < script.points.Length; i++)
        {
            if (i == selectedPoint && Tools.current == Tool.Move)
            {
                Handles.color = PointSelectedColor;
                Undo.SetSnapshotTarget(script, "Moved Point");
                Handles.SphereCap(-i - 1, script.points[i], Quaternion.identity, HandleUtility.GetHandleSize(script.points[i]) * pointGizmosRadius * 2);
                script.points[i] = Handles.PositionHandle(script.points[i], Quaternion.identity);
            }
            else
            {
                Handles.color = PointColor;
                Handles.SphereCap(-i - 1, script.points[i], Quaternion.identity, HandleUtility.GetHandleSize(script.points[i]) * pointGizmosRadius);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            // Register the undos when we press the Mouse button.
            Undo.CreateSnapshot();
            Undo.RegisterSnapshot();
        }

        if (Event.current.type == EventType.MouseDown)
        {
            int pre = selectedPoint;
            selectedPoint = -(HandleUtility.nearestControl + 1);
            if (pre != selectedPoint)
            {
                GUI.changed = true;
            }
        }

        if (Event.current.type == EventType.MouseDown && Event.current.shift && Tools.current == Tool.Move)
        {
            if (((int)Event.current.modifiers & (int)EventModifiers.Alt) != 0)
            {
                //int nearestControl = -(HandleUtility.nearestControl+1);

                if (selectedPoint >= 0 && selectedPoint < script.points.Length)
                {
                    Undo.RegisterUndo(script, "Removed Point");
                    List <Vector3> arr = new List <Vector3>(script.points);
                    arr.RemoveAt(selectedPoint);
                    script.points = arr.ToArray();
                    script.RecalcConvex();
                    GUI.changed = true;
                }
            }
            else
            {
                System.Object hit = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(Event.current.mousePosition));
                if (hit != null)
                {
                    RaycastHit rayhit = (RaycastHit)hit;

                    Undo.RegisterUndo(script, "Added Point");

                    Vector3[] points = new Vector3[script.points.Length + 1];
                    for (int i = 0; i < script.points.Length; i++)
                    {
                        points[i] = script.points[i];
                    }
                    points[points.Length - 1] = rayhit.point;
                    script.points             = points;
                    script.RecalcConvex();
                    GUI.changed = true;
                }
            }
            Event.current.Use();
        }

        if (Event.current.shift && Event.current.type == EventType.MouseDrag)
        {
            //Event.current.Use ();
        }

        if (GUI.changed)
        {
            HandleUtility.Repaint(); EditorUtility.SetDirty(target);
        }
    }
    public override void OnInspectorGUI()
    {
        GraphUpdateScene script = target as GraphUpdateScene;

        if (script.points == null)
        {
            script.points = new Vector3[0];
        }

        Vector3[] prePoints = script.points;
        DrawDefaultInspector();
        EditorGUI.indentLevel = 1;

        if (prePoints != script.points)
        {
            script.RecalcConvex(); HandleUtility.Repaint();
        }

        bool preConvex = script.convex;

        script.convex = EditorGUILayout.Toggle(new GUIContent("Convex", "Sets if only the convex hull of the points should be used or the whole polygon"), script.convex);
        if (script.convex != preConvex)
        {
            script.RecalcConvex(); HandleUtility.Repaint();
        }

        script.applyOnStart = EditorGUILayout.Toggle("Apply On Start", script.applyOnStart);
        script.applyOnScan  = EditorGUILayout.Toggle("Apply On Scan", script.applyOnScan);

        script.modifyWalkability = EditorGUILayout.Toggle("Modify walkability", script.modifyWalkability);
        if (script.modifyWalkability)
        {
            EditorGUI.indentLevel++;
            script.setWalkability = EditorGUILayout.Toggle("Walkability", script.setWalkability);
            EditorGUI.indentLevel--;
        }

        script.penalty = EditorGUILayout.IntField("Penalty", script.penalty);

#if ConfigureTagsAsMultiple
        script.modifyTag = EditorGUILayout.Toggle(new GUIContent("Modify Tags", "Should the tags of the nodes be modified"), script.modifyTag);
        EditorGUILayoutx.TagsMaskField(new GUIContent("Tags Change", "Which tags to change the value of. The values the tags will gain can be set below"), new GUIContent("Tags Set", "What to set the tag to if it is going to be changed"), ref script.tags);
#else
        script.modifyTag = EditorGUILayout.Toggle(new GUIContent("Modify Tags", "Should the tags of the nodes be modified"), script.modifyTag);
        if (script.modifyTag)
        {
            EditorGUI.indentLevel++;
            script.setTag = EditorGUILayout.Popup("Set Tag", script.setTag, AstarPath.FindTagNames());
            EditorGUI.indentLevel--;
        }
#endif

        //GUI.color = Color.red;
        if (GUILayout.Button("Tags can be used to restrict which units can walk on what ground. Click here for more info", "HelpBox"))
        {
            Application.OpenURL(AstarPathEditor.GetURL("tags"));
        }

        //GUI.color = Color.white;

        if (GUILayout.Button("Clear all points"))
        {
            Undo.RegisterUndo(script, "Removed All Points");
            script.points = new Vector3[0];
            script.RecalcConvex();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
示例#10
0
	// Use this for initialization
	void Start () {
		graphUpdate = GameObject.FindGameObjectWithTag("Update").GetComponent<GraphUpdateScene> ();

	}
示例#11
0
    private void Start()
    {
        graph = this.GetComponent <GraphUpdateScene>();

        this.Sync();
    }
示例#12
0
    public override void OnInspectorGUI()
    {
        GraphUpdateScene script = target as GraphUpdateScene;

        if (script.points == null)
        {
            script.points = new Vector3[0];
        }

        Vector3[] prePoints = script.points;
        DrawDefaultInspector();
        EditorGUI.indentLevel = 1;

        if (prePoints != script.points)
        {
            script.RecalcConvex(); HandleUtility.Repaint();
        }

        bool preConvex = script.convex;

        script.convex = EditorGUILayout.Toggle(new GUIContent("Convex", "Sets if only the convex hull of the points should be used or the whole polygon"), script.convex);
        if (script.convex != preConvex)
        {
            script.RecalcConvex(); HandleUtility.Repaint();
        }

        script.minBoundsHeight = EditorGUILayout.FloatField(new GUIContent("Min Bounds Height", "Defines a minimum height to be used for the bounds of the GUO.\nUseful if you define points in 2D (which would give height 0)"), script.minBoundsHeight);
        script.applyOnStart    = EditorGUILayout.Toggle("Apply On Start", script.applyOnStart);
        script.applyOnScan     = EditorGUILayout.Toggle("Apply On Scan", script.applyOnScan);

        script.modifyWalkability = EditorGUILayout.Toggle("Modify walkability", script.modifyWalkability);
        if (script.modifyWalkability)
        {
            EditorGUI.indentLevel++;
            script.setWalkability = EditorGUILayout.Toggle("Walkability", script.setWalkability);
            EditorGUI.indentLevel--;
        }

        script.penaltyDelta = EditorGUILayout.IntField("Penalty Delta", script.penaltyDelta);

        if (script.penaltyDelta < 0)
        {
            GUILayout.Label("Be careful when lowering the penalty. Negative penalties are not supported and will instead underflow and get really high.", "HelpBox");
        }

        bool worldSpace = EditorGUILayout.Toggle(new GUIContent("Use World Space", "Specify coordinates in world space or local space. When using local space you can move the GameObject around and the points will follow"
                                                                ), script.useWorldSpace);

        if (worldSpace != script.useWorldSpace)
        {
            script.ToggleUseWorldSpace();
        }

        script.modifyTag = EditorGUILayout.Toggle(new GUIContent("Modify Tags", "Should the tags of the nodes be modified"), script.modifyTag);
        if (script.modifyTag)
        {
            EditorGUI.indentLevel++;
            script.setTag = EditorGUILayout.Popup("Set Tag", script.setTag, AstarPath.FindTagNames());
            EditorGUI.indentLevel--;
        }

        //GUI.color = Color.red;
        if (GUILayout.Button("Tags can be used to restrict which units can walk on what ground. Click here for more info", "HelpBox"))
        {
            Application.OpenURL(AstarPathEditor.GetURL("tags"));
        }

        //GUI.color = Color.white;

        EditorGUILayout.Separator();

        //GUILayout.Space (0);
        //GUI.Toggle (r,script.lockToY,"","Button");
        script.lockToY = EditorGUILayout.Toggle("Lock to Y", script.lockToY);

        if (script.lockToY)
        {
            EditorGUI.indentLevel++;
            script.lockToYValue = EditorGUILayout.FloatField("Lock to Y value", script.lockToYValue);
            EditorGUI.indentLevel--;
            script.LockToY();
        }

        EditorGUILayout.Separator();

        if (GUI.changed)
        {
            Undo.RegisterUndo(script, "Modify Settings on GraphUpdateObject");
            EditorUtility.SetDirty(target);
        }

        if (GUILayout.Button("Clear all points"))
        {
            Undo.RegisterUndo(script, "Removed All Points");
            script.points = new Vector3[0];
            script.RecalcConvex();
        }
    }
示例#13
0
 public void OnDisable()
 {
     EventManager.instance.RemoveListener <LevelStartEvent>(OnLevelStart);
     sAllObstacles.Remove(this);
     _graphUpdate = null;
 }