示例#1
0
    public override void OnInspectorGUI(NavGraph target)
    {
        ListGraph graph = target as ListGraph;

#if UNITY_3_3
        graph.root = (Transform)EditorGUILayout.ObjectField(new GUIContent("Root", "All childs of this object will be used as nodes, if it is not set, a tag search will be used instead (see below)"), graph.root, typeof(Transform));
#else
        graph.root = (Transform)EditorGUILayout.ObjectField(new GUIContent("Root", "All childs of this object will be used as nodes, if it is not set, a tag search will be used instead (see below)"), graph.root, typeof(Transform), true);
#endif
        graph.recursive = EditorGUILayout.Toggle(new GUIContent("Recursive", "Should childs of the childs in the root GameObject be searched"), graph.recursive);
        graph.searchTag = EditorGUILayout.TagField(new GUIContent("Tag", "If root is not set, all objects with this tag will be used as nodes"), graph.searchTag);

        if (graph.root != null)
        {
            GUILayout.Label("All childs " + (graph.recursive ? "and sub-childs ":"") + "of 'root' will be used as nodes\nSet root to null to use a tag search instead", AstarPathEditor.helpBox);
        }
        else
        {
            GUILayout.Label("All object with the tag '" + graph.searchTag + "' will be used as nodes" + (graph.searchTag == "Untagged" ? "\nNote: the tag 'Untagged' cannot be used" : ""), AstarPathEditor.helpBox);
        }

        graph.maxDistance = EditorGUILayout.FloatField("Max Distance", graph.maxDistance);
        graph.limits      = EditorGUILayout.Vector3Field("Max Distance (axis aligned)", graph.limits);
        graph.raycast     = EditorGUILayout.Toggle("Raycast", graph.raycast);

        editor.GUILayoutx.BeginFadeArea(graph.raycast, "raycast");

        EditorGUI.indentLevel++;

        graph.thickRaycast = EditorGUILayout.Toggle("Thick Raycast", graph.thickRaycast);

        editor.GUILayoutx.BeginFadeArea(graph.thickRaycast, "thickRaycast");

        graph.thickRaycastRadius = EditorGUILayout.FloatField("Raycast Radius", graph.thickRaycastRadius);

        editor.GUILayoutx.EndFadeArea();

        //graph.mask = 1 << EditorGUILayout.LayerField ("Mask",(int)Mathf.Log (graph.mask,2));
        graph.mask = EditorGUILayoutx.LayerMaskField("Mask", graph.mask);
        EditorGUI.indentLevel--;

        editor.GUILayoutx.EndFadeArea();
    }
示例#2
0
 public static PredatorPlayerJumpData EditJumpData(GameObject gameObject, PredatorPlayerJumpData jumpData)
 {
     jumpData.Name                  = EditorGUILayout.TextField("Name:", jumpData.Name);
     jumpData.JumpForwardTime       = EditorGUILayout.FloatField("Jump forward time", jumpData.JumpForwardTime);
     jumpData.JumpForwardSpeed      = EditorGUILayout.FloatField("Jump forward speed", jumpData.JumpForwardSpeed);
     jumpData.JumpOverSpeed         = EditorGUILayout.FloatField("Jump over speed", jumpData.JumpOverSpeed);
     jumpData.JumpOverCheckDistance = EditorGUILayout.FloatField("Jump over obstacle test distance", jumpData.JumpOverCheckDistance);
     jumpData.ObstacleToJumpOver    = EditorGUILayoutx.LayerMaskField("Jump over obstacle layer:", jumpData.ObstacleToJumpOver);
     jumpData.AnimationLayer        = EditorGUILayout.IntField("Jump animation layer:", jumpData.AnimationLayer);
     jumpData.PreJumpAnimation      = EditorCommon.EditPopup("PreJump Animation",
                                                             jumpData.PreJumpAnimation,
                                                             EditorCommon.GetAnimationNames(gameObject));
     jumpData.JumpingAnimation = EditorCommon.EditPopup("Jumping Animation",
                                                        jumpData.JumpingAnimation,
                                                        EditorCommon.GetAnimationNames(gameObject));
     jumpData.GroundingAnimation = EditorCommon.EditPopup("Grounding Animation",
                                                          jumpData.GroundingAnimation,
                                                          EditorCommon.GetAnimationNames(gameObject));
     return(jumpData);
 }
示例#3
0
    public virtual void EditBooleanConditionData(AtomConditionData ConditionData)
    {
        EditorGUILayout.BeginHorizontal();
        ConditionData.BooleanCondition = (AIBooleanConditionEnum)EditorGUILayout.EnumPopup(ConditionData.BooleanCondition);
        ConditionData.BooleanOperator  = (BooleanComparisionOperator)EditorGUILayout.EnumPopup(ConditionData.BooleanOperator);
        switch (ConditionData.BooleanCondition)
        {
        case AIBooleanConditionEnum.AlwaysTrue:
            break;

        case AIBooleanConditionEnum.CurrentTargetInLayer:
            ConditionData.LayerMaskForComparision = EditorGUILayoutx.LayerMaskField("Current target in layermask:", ConditionData.LayerMaskForComparision);
            break;

        case AIBooleanConditionEnum.EnemyInDetectiveRange:
            break;

        case AIBooleanConditionEnum.EnemyInOffensiveRange:
            break;

        case AIBooleanConditionEnum.InArea:
            ConditionData.CheckArea = (Collider)EditorGUILayout.ObjectField("Check against collider:", ConditionData.CheckArea, typeof(Collider));
            break;

        case AIBooleanConditionEnum.LatestBehaviorNameIs:
            string[] AllBehaviorName = AI.Behaviors.Select(x => x.Name).ToArray();
            ConditionData.StringValue = EditorCommon.EditPopup("behavior name:", ConditionData.StringValue
                                                               , AllBehaviorName);
            break;

        case AIBooleanConditionEnum.LastestBehaviorNameIsOneOf:
            AllBehaviorName = AI.Behaviors.Select(x => x.Name).ToArray();
            EditorGUILayout.BeginVertical();
            ConditionData.StringValueArray = EditorCommon.EditStringArray("behavior name:", ConditionData.StringValueArray
                                                                          , AllBehaviorName);
            EditorGUILayout.EndVertical();
            break;
        }
        EditorGUILayout.EndHorizontal();
    }
示例#4
0
    public override void OnInspectorGUI(NavGraph target)
    {
        PointGraph graph = target as PointGraph;

        graph.root = ObjectField(new GUIContent("Root", "All children of this object will be used as nodes, if it is not set, a tag search will be used instead (see below)"), graph.root, typeof(Transform), true) as Transform;

        graph.recursive = EditorGUILayout.Toggle(new GUIContent("Recursive", "Should children of the children in the root GameObject be searched"), graph.recursive);
        graph.searchTag = EditorGUILayout.TagField(new GUIContent("Tag", "If root is not set, all objects with this tag will be used as nodes"), graph.searchTag);

        if (graph.root != null)
        {
            EditorGUILayout.HelpBox("All children " + (graph.recursive ? "and sub-children " : "") + "of 'root' will be used as nodes\nSet root to null to use a tag search instead", MessageType.None);
        }
        else
        {
            EditorGUILayout.HelpBox("All object with the tag '" + graph.searchTag + "' will be used as nodes" + (graph.searchTag == "Untagged" ? "\nNote: the tag 'Untagged' cannot be used" : ""), MessageType.None);
        }

        graph.maxDistance = EditorGUILayout.FloatField(new GUIContent("Max Distance", "The max distance in world space for a connection to be valid. A zero counts as infinity"), graph.maxDistance);

        graph.limits  = EditorGUILayout.Vector3Field("Max Distance (axis aligned)", graph.limits);
        graph.raycast = EditorGUILayout.Toggle(new GUIContent("Raycast", "Use raycasting to check if connections are valid between each pair of nodes"), graph.raycast);

        if (graph.raycast)
        {
            EditorGUI.indentLevel++;

            graph.thickRaycast = EditorGUILayout.Toggle(new GUIContent("Thick Raycast", "A thick raycast checks along a thick line with radius instead of just along a line"), graph.thickRaycast);

            if (graph.thickRaycast)
            {
                graph.thickRaycastRadius = EditorGUILayout.FloatField(new GUIContent("Raycast Radius", "The radius in world units for the thick raycast"), graph.thickRaycastRadius);
            }

            graph.mask = EditorGUILayoutx.LayerMaskField(/*new GUIContent (*/ "Mask" /*,"Used to mask which layers should be checked")*/, graph.mask);
            EditorGUI.indentLevel--;
        }
    }
示例#5
0
    /** Draws the inspector for a \link Pathfinding.GraphCollision GraphCollision class \endlink */
    public void DrawCollisionEditor(GraphCollision collision)
    {
        if (collision == null)
        {
            collision = new GraphCollision();
        }

        /*GUILayout.Space (5);
        *  Rect r = EditorGUILayout.BeginVertical (AstarPathEditor.graphBoxStyle);
        *  GUI.Box (r,"",AstarPathEditor.graphBoxStyle);
        *  GUILayout.Space (2);*/
        Separator();

        /*GUILayout.BeginHorizontal ();
         * GUIStyle boxHeader = AstarPathEditor.astarSkin.FindStyle ("CollisionHeader");
         * GUILayout.Label ("Collision testing",boxHeader);
         * collision.collisionCheck = GUILayout.Toggle (collision.collisionCheck,"");
         *
         * bool preEnabledRoot = GUI.enabled;
         * GUI.enabled = collision.collisionCheck;
         * GUILayout.EndHorizontal ();*/
        collision.collisionCheck = ToggleGroup("Collision testing", collision.collisionCheck);
        bool preEnabledRoot = GUI.enabled;

        GUI.enabled = collision.collisionCheck;

        //GUILayout.BeginHorizontal ();
        collision.type = (ColliderType)EditorGUILayout.EnumPopup("Collider type", collision.type);
        //new string[3] {"Sphere","Capsule","Ray"}

        bool preEnabled = GUI.enabled;

        if (collision.type != ColliderType.Capsule && collision.type != ColliderType.Sphere)
        {
            GUI.enabled = false;
        }
        collision.diameter = EditorGUILayout.FloatField(new GUIContent("Diameter", "Diameter of the capsule of sphere where 1 equals one node"), collision.diameter);

        GUI.enabled = preEnabled;

        if (collision.type != ColliderType.Capsule && collision.type != ColliderType.Ray)
        {
            GUI.enabled = false;
        }
        collision.height = EditorGUILayout.FloatField(new GUIContent("Height/Length", "Height of cylinder of length of ray in world units"), collision.height);
        GUI.enabled      = preEnabled;

        collision.collisionOffset = EditorGUILayout.FloatField(new GUIContent("Offset", "Offset upwards from the node. Can be used so obstacles can be used as ground and as obstacles for lower nodes"), collision.collisionOffset);

        //collision.mask = 1 << EditorGUILayout.LayerField ("Mask",Mathf.Clamp ((int)Mathf.Log (collision.mask,2),0,31));

        collision.mask = EditorGUILayoutx.LayerMaskField("Mask", collision.mask);

        GUILayout.Space(2);


        GUI.enabled = preEnabledRoot;

        collision.heightCheck = ToggleGroup("Height testing", collision.heightCheck);
        GUI.enabled           = collision.heightCheck && GUI.enabled;

        /*GUILayout.BeginHorizontal ();
         * GUILayout.Label ("Height testing",boxHeader);
         * collision.heightCheck = GUILayout.Toggle (collision.heightCheck,"");
         * GUI.enabled = collision.heightCheck;
         * GUILayout.EndHorizontal ();*/

        collision.fromHeight = EditorGUILayout.FloatField(new GUIContent("Ray length", "The height from which to check for ground"), collision.fromHeight);

        collision.heightMask = EditorGUILayoutx.LayerMaskField("Mask", collision.heightMask);
        //collision.heightMask = 1 << EditorGUILayout.LayerField ("Mask",Mathf.Clamp ((int)Mathf.Log (collision.heightMask,2),0,31));

        collision.thickRaycast = EditorGUILayout.Toggle(new GUIContent("Thick Raycast", "Use a thick line instead of a thin line"), collision.thickRaycast);

        editor.GUILayoutx.BeginFadeArea(collision.thickRaycast, "thickRaycastDiameter");

        if (editor.GUILayoutx.DrawID("thickRaycastDiameter"))
        {
            EditorGUI.indentLevel++;
            collision.thickRaycastDiameter = EditorGUILayout.FloatField(new GUIContent("Diameter", "Diameter of the thick raycast"), collision.thickRaycastDiameter);
            EditorGUI.indentLevel--;
        }

        editor.GUILayoutx.EndFadeArea();

        collision.unwalkableWhenNoGround = EditorGUILayout.Toggle(new GUIContent("Unwalkable when no ground", "Make nodes unwalkable when no ground was found with the height raycast. If height raycast is turned off, this doesn't affect anything"), collision.unwalkableWhenNoGround);

        GUI.enabled = preEnabledRoot;

        //GUILayout.Space (2);
        //EditorGUILayout.EndVertical ();
        //GUILayout.Space (5);
    }
示例#6
0
    public override void OnInspectorGUI(NavGraph target)
    {
        RecastGraph graph = target as RecastGraph;

        bool preEnabled = GUI.enabled;

        //if (graph.forceBounds) {

        graph.useCRecast = GUILayout.Toolbar(graph.useCRecast ?1:0, new GUIContent[2] {
            new GUIContent("C# Recast", "I have translated a portion of Recast to C#, this can be used in a webplayer but is more limited than the C++ version"),
            new GUIContent("C++ Recast", "Use the original C++ version of Recast, faster scanning times and has more features than the C# version, but it can only be used in the editor or on standalone applications (note that you can still scan the graph in the editor and then cache the startup if you want to build for a webplayer)"
                           + "\nTake a look in the docs on RecastGraph.useCRecast for more information on the special considerations when using this mode")
        }) == 1;

        if (graph.useCRecast)
        {
            BuildTarget bt = EditorUserBuildSettings.activeBuildTarget;
            if (bt != BuildTarget.StandaloneOSXIntel)
            {
                if (GUILayout.Button("Note that the C++ version of Recast does not work in your selected build target (" + bt + ")\n" +
                                     "Change build target to standalone (osx) if you want to be able to use C++\n" +
                                     "Click here for more info", AstarPathEditor.helpBox))
                {
                    Application.OpenURL(AstarPathEditor.GetURL("cRecastHelp"));
                }
            }
            else
            {
                if (GUILayout.Button("Note the special considerations when using C++ Recast\nClick here for more info", AstarPathEditor.helpBox))
                {
                    Application.OpenURL(AstarPathEditor.GetURL("cRecastHelp"));
                }
            }

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                GUILayout.Label("C++ Recast can currently not be used on Windows", AstarPathEditor.helpBox);
            }
        }

        System.Int64 estWidth = Mathf.RoundToInt(Mathf.Ceil(graph.forcedBoundsSize.x / graph.cellSize));
        System.Int64 estDepth = Mathf.RoundToInt(Mathf.Ceil(graph.forcedBoundsSize.z / graph.cellSize));

        if (estWidth * estDepth >= 1024 * 1024 || estDepth >= 1024 * 1024 || estWidth >= 1024 * 1024)
        {
            GUIStyle helpBox = GUI.skin.FindStyle("HelpBox");
            if (helpBox == null)
            {
                helpBox = GUI.skin.FindStyle("Box");
            }

            Color preColor = GUI.color;
            if (estWidth * estDepth >= 2048 * 2048 || estDepth >= 2048 * 2048 || estWidth >= 2048 * 2048)
            {
                GUI.color = Color.red;
            }
            else
            {
                GUI.color = Color.yellow;
            }

            GUILayout.Label("Warning : Might take some time to calculate", helpBox);
            GUI.color = preColor;
        }

        GUI.enabled = false;
        EditorGUILayout.LabelField("Width (samples)", estWidth.ToString());

        EditorGUILayout.LabelField("Depth (samples)", estDepth.ToString());

        /*} else {
         *      GUI.enabled = false;
         *      EditorGUILayout.LabelField ("Width (samples)","undetermined");
         *      EditorGUILayout.LabelField ("Depth (samples)","undetermined");
         * }*/
        GUI.enabled = preEnabled;

        graph.cellSize = EditorGUILayout.FloatField(new GUIContent("Cell Size", "Size of one voxel in world units"), graph.cellSize);
        if (graph.cellSize < 0.001F)
        {
            graph.cellSize = 0.001F;
        }

        graph.cellHeight = EditorGUILayout.FloatField(new GUIContent("Cell Height", "Height of one voxel in world units"), graph.cellHeight);
        if (graph.cellHeight < 0.001F)
        {
            graph.cellHeight = 0.001F;
        }

        graph.walkableHeight  = EditorGUILayout.FloatField(new GUIContent("Walkable Height", "Minimum distance to the roof for an area to be walkable"), graph.walkableHeight);
        graph.walkableClimb   = EditorGUILayout.FloatField(new GUIContent("Walkable Climb", "How high can the character climb"), graph.walkableClimb);
        graph.characterRadius = EditorGUILayout.FloatField(new GUIContent("Character Radius", "Radius of the character, it's good to add some margin though"), graph.characterRadius);

        if (graph.useCRecast)
        {
            graph.regionMinSize = EditorGUILayout.IntField(new GUIContent("Min Region Size", "The lowest number of voxles in one area for it not to be deleted"), graph.regionMinSize);
        }

        graph.maxSlope      = EditorGUILayout.Slider(new GUIContent("Max Slope", "Approximate maximum slope"), graph.maxSlope, 0F, 90F);
        graph.maxEdgeLength = EditorGUILayout.FloatField(new GUIContent("Max Edge Length", "Maximum length of one edge in the completed navmesh before it is split. A lower value can often yield better quality graphs"), graph.maxEdgeLength);
        graph.maxEdgeLength = graph.maxEdgeLength < graph.cellSize ? graph.cellSize : graph.maxEdgeLength;

        /*if (!graph.useCRecast) {
         *      graph.erosionRadius = EditorGUILayout.IntSlider ("Erosion radius",graph.erosionRadius,0,256);
         * }*/

        graph.contourMaxError = EditorGUILayout.FloatField(new GUIContent("Max edge error", "Amount of simplification to apply to edges"), graph.contourMaxError);

        graph.rasterizeTerrain = EditorGUILayout.Toggle(new GUIContent("Rasterize Terrain", "Should a rasterized terrain be included"), graph.rasterizeTerrain);
        if (graph.rasterizeTerrain)
        {
            EditorGUI.indentLevel++;
            graph.rasterizeTrees = EditorGUILayout.Toggle(new GUIContent("Rasterize Trees", "Rasterize tree colliders on terrains. " +
                                                                         "If the tree prefab has a collider, that collider will be rasterized. " +
                                                                         "Otherwise a simple box collider will be used and the script will " +
                                                                         "try to adjust it to the tree's scale, it might not do a very good job though so " +
                                                                         "an attached collider is preferable."), graph.rasterizeTrees);
            if (graph.rasterizeTrees)
            {
                EditorGUI.indentLevel++;
                graph.colliderRasterizeDetail = EditorGUILayout.FloatField(new GUIContent("Collider Detail", "Controls the detail of the generated collider meshes. Increasing does not necessarily yield better navmeshes, but lowering will speed up scan"), graph.colliderRasterizeDetail);
                EditorGUI.indentLevel--;
            }

            graph.terrainSampleSize = EditorGUILayout.IntField(new GUIContent("Terrain Sample Size", "Size of terrain samples. A lower value is better, but slower"), graph.terrainSampleSize);
            graph.terrainSampleSize = graph.terrainSampleSize < 1 ? 1 : graph.terrainSampleSize;            //Clamp to at least 1
            EditorGUI.indentLevel--;
        }

        graph.rasterizeMeshes    = EditorGUILayout.Toggle(new GUIContent("Rasterize Meshes", "Should meshes be rasterized and used for building the navmesh"), graph.rasterizeMeshes);
        graph.rasterizeColliders = EditorGUILayout.Toggle(new GUIContent("Rasterize Colliders", "Should colliders be rasterized and used for building the navmesh"), graph.rasterizeColliders);
        if (graph.rasterizeColliders)
        {
            EditorGUI.indentLevel++;
            graph.colliderRasterizeDetail = EditorGUILayout.FloatField(new GUIContent("Collider Detail", "Controls the detail of the generated collider meshes. Increasing does not necessarily yield better navmeshes, but lowering will speed up scan"), graph.colliderRasterizeDetail);
            EditorGUI.indentLevel--;
        }

        graph.mask = EditorGUILayoutx.LayerMaskField("Layer Mask", graph.mask);

        graph.includeOutOfBounds = EditorGUILayout.Toggle(new GUIContent("Include out of bounds", "Should voxels out of bounds, on the Y axis below the graph, be included or not"), graph.includeOutOfBounds);
        Separator();

        graph.forcedBoundsCenter = EditorGUILayout.Vector3Field("Center", graph.forcedBoundsCenter);
        graph.forcedBoundsSize   = EditorGUILayout.Vector3Field("Size", graph.forcedBoundsSize);

        if (GUILayout.Button(new GUIContent("Snap bounds to scene", "Will snap the bounds of the graph to exactly contain all active meshes in the scene")))
        {
            graph.SnapForceBoundsToScene();
            GUI.changed = true;
        }

        Separator();

        tagMaskFoldout = EditorGUILayoutx.UnityTagMaskList(new GUIContent("Tag Mask"), tagMaskFoldout, graph.tagMask);

        Separator();

        graph.showMeshOutline = EditorGUILayout.Toggle(new GUIContent("Show mesh outline", "Toggles gizmos for drawing an outline of the mesh"), graph.showMeshOutline);

        graph.accurateNearestNode = EditorGUILayout.Toggle(new GUIContent("Accurate Nearest Node Queries", "More accurate nearest node queries. See docs for more info"), graph.accurateNearestNode);

        if (GUILayout.Button("Export to file"))
        {
            ExportToFile(graph);
        }

        /*graph.replaceMesh = (Mesh)ObjectField (new GUIContent ("Replacement Mesh","If you make edits to the mesh manually, you can drop the new mesh file here to import it"), graph.replaceMesh,typeof(Mesh),false);
         *
         * if (graph.replaceMesh != null) {
         *      HelpBox ("Note: Graph will be replaced by the mesh");
         * }*/
        //graph.mask = 1 << EditorGUILayout.LayerField ("Mask",(int)Mathf.Log (graph.mask,2));
    }