public override void OnInspectorGUI() { AISettings Target = (AISettings)target; var bs = NavMesh.GetSettingsByID(agentType.intValue); if (bs.agentTypeID != -1) { Rect agentDiagramRect = EditorGUILayout.GetControlRect(false, diagramHeight); UnityEditor.AI.NavMeshEditorHelpers.DrawAgentDiagram(agentDiagramRect, bs.agentRadius, bs.agentHeight, bs.agentClimb, bs.agentSlope); } NavMeshComponentsGUIUtility.AgentTypePopup("Agent Type", agentType); ShowInfo(Target); ObjectFields(Target); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var bs = NavMesh.GetSettingsByID(m_AgentTypeID.intValue); serializedObject.Update(); if (bs.agentTypeID != -1) { // Draw image const float diagramHeight = 80.0f; Rect agentDiagramRect = EditorGUILayout.GetControlRect(false, diagramHeight); NavMeshEditorHelpers.DrawAgentDiagram(agentDiagramRect, bs.agentRadius, bs.agentHeight, bs.agentClimb, bs.agentSlope); } NavMeshComponentsGUIUtility.AgentTypePopup("Agent Type", m_AgentTypeID); serializedObject.ApplyModifiedProperties(); }
void DrawProperties() { serializedObject.Update(); var bs = NavMesh.GetSettingsByID(agentTypeID.intValue); if (bs.agentTypeID != -1) { // Draw image const float diagramHeight = 80.0f; Rect agentDiagramRect = EditorGUILayout.GetControlRect(false, diagramHeight); NavMeshEditorHelpers.DrawAgentDiagram(agentDiagramRect, bs.agentRadius, bs.agentHeight, bs.agentClimb, bs.agentSlope); } NavMeshComponentsGUIUtility.AgentTypePopup("Agent Type", agentTypeID); EditorGUILayout.Space(); NavMeshComponentsGUIUtility.AreaPopup("Default Area", defaultArea); EditorGUILayout.PropertyField(layerMask); EditorGUILayout.PropertyField(useGeometry); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); TileMapToMesh instance = (TileMapToMesh)target; //get a dropDown of layers. instance.layerIndex = EditorGUILayout.LayerField("Layer for Objects:", instance.layerIndex); //create a toggle using navMeshModifer's bool. instance.navMeshModifier = EditorGUILayout.Toggle("Add NavMesh Modifier", instance.navMeshModifier); //if navMeshModifer toggle = true, show Area type field. if (instance.navMeshModifier) { //get a dropDown of Navigation Area's NavMeshComponentsGUIUtility.AreaPopup("Area Type", navigationArea); instance.navigationArea = navigationArea.intValue; } //create a toggle using meshCollider's bool instance.meshCollider = EditorGUILayout.Toggle("Add Mesh Collider", instance.meshCollider); //if meshCollider's toggle = true, show physics material field. if (instance.meshCollider) { //add an object field of type "PhysicsMaterial" instance.physicsMaterial = EditorGUILayout.ObjectField("Physics Material", instance.physicsMaterial, typeof(PhysicMaterial), true) as PhysicMaterial; } //create a button that runs Generate() on click. if (GUILayout.Button("Generate Mesh")) { instance.Generate(); } }
private void DrawLinksGUI() { addNavMeshLinksBetweenRoomsProp.isExpanded = EditorGUILayout.Foldout(addNavMeshLinksBetweenRoomsProp.isExpanded, "Room Links"); if (addNavMeshLinksBetweenRoomsProp.isExpanded) { EditorGUILayout.BeginVertical("box"); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(addNavMeshLinksBetweenRoomsProp, addNavMeshLinksBetweenRoomsLabel); using (new EditorGUI.DisabledScope(!addNavMeshLinksBetweenRoomsProp.boolValue)) { EditorGUILayout.PropertyField(navMeshLinkDistanceFromDoorwayProp, navMeshLinkDistanceFromDoorwayLabel); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(navMeshAgentTypesLabel); if (GUILayout.Button("Add New")) { navMeshAgentTypesProp.InsertArrayElementAtIndex(navMeshAgentTypesProp.arraySize); } EditorGUILayout.EndHorizontal(); int indexToRemove = -1; for (int i = 0; i < navMeshAgentTypesProp.arraySize; i++) { EditorGUILayout.BeginVertical("box"); if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(18))) { indexToRemove = i; } var elementProp = navMeshAgentTypesProp.GetArrayElementAtIndex(i); var agentTypeID = elementProp.FindPropertyRelative("AgentTypeID"); var areaTypeID = elementProp.FindPropertyRelative("AreaTypeID"); var disableWhenDoorIsClosed = elementProp.FindPropertyRelative("DisableLinkWhenDoorIsClosed"); NavMeshComponentsGUIUtility.AgentTypePopup("Agent Type", agentTypeID); NavMeshComponentsGUIUtility.AreaPopup("Area", areaTypeID); EditorGUILayout.PropertyField(disableWhenDoorIsClosed, disableLinkWhenDoorIsClosedLabel); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); if (indexToRemove >= 0 && indexToRemove < navMeshAgentTypesProp.arraySize) { navMeshAgentTypesProp.DeleteArrayElementAtIndex(indexToRemove); } } EditorGUI.indentLevel--; EditorGUILayout.EndVertical(); } }