private void SelectNavMeshArea() { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_AreaIndex.hasMultipleDifferentValues; string[] navMeshAreaNames = GameObjectUtility.GetNavMeshAreaNames(); int intValue = this.m_AreaIndex.intValue; int selectedIndex = -1; for (int i = 0; i < navMeshAreaNames.Length; i++) { if (GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[i]) == intValue) { selectedIndex = i; break; } } int index = EditorGUILayout.Popup("Navigation Area", selectedIndex, navMeshAreaNames, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { int navMeshAreaFromName = GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[index]); this.m_AreaIndex.intValue = navMeshAreaFromName; } }
private void SelectNavMeshArea() { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_AreaIndex.hasMultipleDifferentValues; var areaNames = GameObjectUtility.GetNavMeshAreaNames(); var currentAbsoluteIndex = m_AreaIndex.intValue; var areaIndex = -1; //Need to find the index as the list of names will compress out empty layers for (var i = 0; i < areaNames.Length; i++) { if (GameObjectUtility.GetNavMeshAreaFromName(areaNames[i]) == currentAbsoluteIndex) { areaIndex = i; break; } } var area = EditorGUILayout.Popup(Styles.NavigationArea, areaIndex, areaNames); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { var newAreaIndex = GameObjectUtility.GetNavMeshAreaFromName(areaNames[area]); m_AreaIndex.intValue = newAreaIndex; } }
private static void ObjectSettings(Object[] components, GameObject[] gos) { ComponentBasedWorkflowButton(); EditorGUILayout.MultiSelectionObjectTitleBar(components); using (var so = new SerializedObject(gos)) { using (new EditorGUI.DisabledScope(!SceneModeUtility.StaticFlagField("Navigation Static", so.FindProperty("m_StaticEditorFlags"), (int)StaticEditorFlags.NavigationStatic))) { SceneModeUtility.StaticFlagField("Generate OffMeshLinks", so.FindProperty("m_StaticEditorFlags"), (int)StaticEditorFlags.OffMeshLinkGeneration); var property = so.FindProperty("m_NavMeshLayer"); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = property.hasMultipleDifferentValues; var navAreaNames = GameObjectUtility.GetNavMeshAreaNames(); var currentAbsoluteIndex = GameObjectUtility.GetNavMeshArea(gos[0]); var navAreaIndex = -1; // Need to find the index as the list of names will compress out empty area for (var i = 0; i < navAreaNames.Length; i++) { if (GameObjectUtility.GetNavMeshAreaFromName(navAreaNames[i]) == currentAbsoluteIndex) { navAreaIndex = i; break; } } var navMeshArea = EditorGUILayout.Popup("Navigation Area", navAreaIndex, navAreaNames); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { //Convert the selected index into absolute index... var newNavAreaIndex = GameObjectUtility.GetNavMeshAreaFromName(navAreaNames[navMeshArea]); GameObjectUtility.ShouldIncludeChildren includeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(Selection.gameObjects, "Change Navigation Area", "Do you want change the navigation area to " + navAreaNames[navMeshArea] + " for all the child objects as well?"); if (includeChildren != GameObjectUtility.ShouldIncludeChildren.Cancel) { property.intValue = newNavAreaIndex; SetNavMeshArea(newNavAreaIndex, includeChildren == 0); } } } so.ApplyModifiedProperties(); } }
private static void ObjectSettings(UnityEngine.Object[] components, GameObject[] gos) { EditorGUILayout.MultiSelectionObjectTitleBar(components); SerializedObject serializedObject = new SerializedObject(gos); EditorGUI.BeginDisabledGroup(!SceneModeUtility.StaticFlagField("Navigation Static", serializedObject.FindProperty("m_StaticEditorFlags"), 8)); SceneModeUtility.StaticFlagField("Generate OffMeshLinks", serializedObject.FindProperty("m_StaticEditorFlags"), 32); SerializedProperty serializedProperty = serializedObject.FindProperty("m_NavMeshLayer"); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = serializedProperty.hasMultipleDifferentValues; string[] navMeshAreaNames = GameObjectUtility.GetNavMeshAreaNames(); int navMeshArea = GameObjectUtility.GetNavMeshArea(gos[0]); int selectedIndex = -1; for (int i = 0; i < navMeshAreaNames.Length; i++) { if (GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[i]) == navMeshArea) { selectedIndex = i; break; } } int num = EditorGUILayout.Popup("Navigation Area", selectedIndex, navMeshAreaNames, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { int navMeshAreaFromName = GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[num]); GameObjectUtility.ShouldIncludeChildren shouldIncludeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(Selection.gameObjects, "Change Navigation Area", "Do you want change the navigation area to " + navMeshAreaNames[num] + " for all the child objects as well?"); if (shouldIncludeChildren != GameObjectUtility.ShouldIncludeChildren.Cancel) { serializedProperty.intValue = navMeshAreaFromName; NavMeshEditorWindow.SetNavMeshArea(navMeshAreaFromName, shouldIncludeChildren == GameObjectUtility.ShouldIncludeChildren.IncludeChildren); } } EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (s_Styles == null) { s_Styles = new Styles(); } serializedObject.Update(); AgentTypePopupInternal("Agent Type", m_AgentTypeID); EditorGUILayout.PropertyField(m_BaseOffset); EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.m_AgentSteeringHeader, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_Speed); EditorGUILayout.PropertyField(m_AngularSpeed); EditorGUILayout.PropertyField(m_Acceleration); EditorGUILayout.PropertyField(m_StoppingDistance); EditorGUILayout.PropertyField(m_AutoBraking); EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.m_AgentAvoidanceHeader, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_Radius); EditorGUILayout.PropertyField(m_Height); EditorGUILayout.PropertyField(m_ObstacleAvoidanceType, GUIContent.Temp("Quality")); EditorGUILayout.PropertyField(m_AvoidancePriority, GUIContent.Temp("Priority")); EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.m_AgentPathFindingHeader, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_AutoTraverseOffMeshLink); EditorGUILayout.PropertyField(m_AutoRepath); //Initially needed data var areaNames = GameObjectUtility.GetNavMeshAreaNames(); var currentMask = m_WalkableMask.longValue; var compressedMask = 0; //Need to find the index as the list of names will compress out empty areas for (var i = 0; i < areaNames.Length; i++) { var areaIndex = GameObjectUtility.GetNavMeshAreaFromName(areaNames[i]); if (((1 << areaIndex) & currentMask) != 0) { compressedMask = compressedMask | (1 << i); } } //TODO: Refactor this to use the mask field that takes a label. float kH = EditorGUI.kSingleLineHeight; var position = GUILayoutUtility.GetRect(EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW, kH, kH, EditorStyles.layerMaskField); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_WalkableMask.hasMultipleDifferentValues; var areaMask = EditorGUI.MaskField(position, "Area Mask", compressedMask, areaNames, EditorStyles.layerMaskField); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { if (areaMask == ~0) { m_WalkableMask.longValue = 0xffffffff; } else { uint newMask = 0; for (var i = 0; i < areaNames.Length; i++) { //If the bit has been set in the compacted mask if (((areaMask >> i) & 1) != 0) { //Find out the 'real' layer from the name, then set it in the new mask newMask = newMask | (uint)(1 << GameObjectUtility.GetNavMeshAreaFromName(areaNames[i])); } } m_WalkableMask.longValue = newMask; } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (NavMeshAgentInspector.s_Styles == null) { NavMeshAgentInspector.s_Styles = new NavMeshAgentInspector.Styles(); } base.serializedObject.Update(); NavMeshAgentInspector.AgentTypePopupInternal("Agent Type", this.m_AgentTypeID); EditorGUILayout.PropertyField(this.m_BaseOffset, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(NavMeshAgentInspector.s_Styles.m_AgentSteeringHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Speed, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AngularSpeed, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Acceleration, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_StoppingDistance, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AutoBraking, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(NavMeshAgentInspector.s_Styles.m_AgentAvoidanceHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Radius, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Height, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ObstacleAvoidanceType, GUIContent.Temp("Quality"), new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AvoidancePriority, GUIContent.Temp("Priority"), new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(NavMeshAgentInspector.s_Styles.m_AgentPathFindingHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AutoTraverseOffMeshLink, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AutoRepath, new GUILayoutOption[0]); string[] navMeshAreaNames = GameObjectUtility.GetNavMeshAreaNames(); long longValue = this.m_WalkableMask.longValue; int num = 0; for (int i = 0; i < navMeshAreaNames.Length; i++) { int navMeshAreaFromName = GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[i]); if ((1L << (navMeshAreaFromName & 31) & longValue) != 0L) { num |= 1 << i; } } Rect rect = GUILayoutUtility.GetRect(EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW, 16f, 16f, EditorStyles.layerMaskField); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_WalkableMask.hasMultipleDifferentValues; int num2 = EditorGUI.MaskField(rect, "Area Mask", num, navMeshAreaNames, EditorStyles.layerMaskField); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { if (num2 == -1) { this.m_WalkableMask.longValue = (long)((ulong)-1); } else { uint num3 = 0u; for (int j = 0; j < navMeshAreaNames.Length; j++) { if ((num2 >> j & 1) != 0) { num3 |= 1u << GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[j]); } } this.m_WalkableMask.longValue = (long)((ulong)num3); } } base.serializedObject.ApplyModifiedProperties(); }
public static string[] GetNavMeshLayerNames() { return(GameObjectUtility.GetNavMeshAreaNames()); }
public override void OnInspectorGUI() { if (s_Styles == null) { s_Styles = new Styles(); } base.serializedObject.Update(); EditorGUILayout.LabelField(s_Styles.m_AgentSizeHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Radius, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Height, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_BaseOffset, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.m_AgentSteeringHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Speed, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AngularSpeed, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Acceleration, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_StoppingDistance, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AutoBraking, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.m_AgentAvoidanceHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ObstacleAvoidanceType, GUIContent.Temp("Quality"), new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AvoidancePriority, GUIContent.Temp("Priority"), new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.m_AgentPathFindingHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AutoTraverseOffMeshLink, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AutoRepath, new GUILayoutOption[0]); string[] navMeshAreaNames = GameObjectUtility.GetNavMeshAreaNames(); long longValue = this.m_WalkableMask.longValue; int mask = 0; for (int i = 0; i < navMeshAreaNames.Length; i++) { int navMeshAreaFromName = GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[i]); if (((((int)1) << navMeshAreaFromName) & longValue) != 0) { mask |= ((int)1) << i; } } Rect position = GUILayoutUtility.GetRect(EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW, 16f, 16f, EditorStyles.layerMaskField); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_WalkableMask.hasMultipleDifferentValues; int num6 = EditorGUI.MaskField(position, "Area Mask", mask, navMeshAreaNames, EditorStyles.layerMaskField); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { if (num6 == -1) { this.m_WalkableMask.longValue = 0xffffffffL; } else { uint num7 = 0; for (int j = 0; j < navMeshAreaNames.Length; j++) { if (((num6 >> j) & 1) != 0) { num7 |= ((uint)1) << GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[j]); } } this.m_WalkableMask.longValue = num7; } } base.serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (NavMeshAgentInspector.s_Styles == null) { NavMeshAgentInspector.s_Styles = new NavMeshAgentInspector.Styles(); } this.serializedObject.Update(); EditorGUILayout.LabelField(NavMeshAgentInspector.s_Styles.m_AgentSizeHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Radius); EditorGUILayout.PropertyField(this.m_Height); EditorGUILayout.PropertyField(this.m_BaseOffset); EditorGUILayout.Space(); EditorGUILayout.LabelField(NavMeshAgentInspector.s_Styles.m_AgentSteeringHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Speed); EditorGUILayout.PropertyField(this.m_AngularSpeed); EditorGUILayout.PropertyField(this.m_Acceleration); EditorGUILayout.PropertyField(this.m_StoppingDistance); EditorGUILayout.PropertyField(this.m_AutoBraking); EditorGUILayout.Space(); EditorGUILayout.LabelField(NavMeshAgentInspector.s_Styles.m_AgentAvoidanceHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_ObstacleAvoidanceType, GUIContent.Temp("Quality"), new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AvoidancePriority, GUIContent.Temp("Priority"), new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.LabelField(NavMeshAgentInspector.s_Styles.m_AgentPathFindingHeader, EditorStyles.boldLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_AutoTraverseOffMeshLink); EditorGUILayout.PropertyField(this.m_AutoRepath); string[] navMeshAreaNames = GameObjectUtility.GetNavMeshAreaNames(); long longValue = this.m_WalkableMask.longValue; int mask = 0; for (int index = 0; index < navMeshAreaNames.Length; ++index) { if (((long)(1 << GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[index])) & longValue) != 0L) { mask |= 1 << index; } } Rect rect = GUILayoutUtility.GetRect(EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW, 16f, 16f, EditorStyles.layerMaskField); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_WalkableMask.hasMultipleDifferentValues; int num1 = EditorGUI.MaskField(rect, "Area Mask", mask, navMeshAreaNames, EditorStyles.layerMaskField); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { if (num1 == -1) { this.m_WalkableMask.longValue = (long)uint.MaxValue; } else { uint num2 = 0; for (int index = 0; index < navMeshAreaNames.Length; ++index) { if ((num1 >> index & 1) != 0) { num2 |= (uint)(1 << GameObjectUtility.GetNavMeshAreaFromName(navMeshAreaNames[index])); } } this.m_WalkableMask.longValue = (long)num2; } } this.serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); AgentTypePopupInternal(m_AgentTypeID); EditorGUILayout.PropertyField(m_BaseOffset, Styles.BaseOffset); EditorGUILayout.Space(); EditorGUILayout.LabelField(Styles.AgentSteeringHeader, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_Speed, Styles.Speed); EditorGUILayout.PropertyField(m_AngularSpeed, Styles.AngularSpeed); EditorGUILayout.PropertyField(m_Acceleration, Styles.Acceleration); EditorGUILayout.PropertyField(m_StoppingDistance, Styles.StoppingDistance); EditorGUILayout.PropertyField(m_AutoBraking, Styles.AutoBraking); EditorGUILayout.Space(); EditorGUILayout.LabelField(Styles.AgentAvoidanceHeader, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_Radius, Styles.Radius); EditorGUILayout.PropertyField(m_Height, Styles.Height); EditorGUILayout.PropertyField(m_ObstacleAvoidanceType, Styles.Quality); EditorGUILayout.PropertyField(m_AvoidancePriority, Styles.Priority); EditorGUILayout.Space(); EditorGUILayout.LabelField(Styles.AgentPathFindingHeader, EditorStyles.boldLabel); EditorGUILayout.PropertyField(m_AutoTraverseOffMeshLink, Styles.AutoTraverseOffMeshLink); EditorGUILayout.PropertyField(m_AutoRepath, Styles.AutoRepath); //Initially needed data var areaNames = GameObjectUtility.GetNavMeshAreaNames(); var currentMask = m_WalkableMask.longValue; var compressedMask = 0; if (currentMask == 0xffffffff) { compressedMask = ~0; } else { //Need to find the index as the list of names will compress out empty areas for (var i = 0; i < areaNames.Length; i++) { var areaIndex = GameObjectUtility.GetNavMeshAreaFromName(areaNames[i]); if (((1 << areaIndex) & currentMask) != 0) { compressedMask = compressedMask | (1 << i); } } } var position = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(position, GUIContent.none, m_WalkableMask); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_WalkableMask.hasMultipleDifferentValues; var areaMask = EditorGUI.MaskField(position, Styles.AreaMask, compressedMask, areaNames, EditorStyles.layerMaskField); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { if (areaMask == ~0) { m_WalkableMask.longValue = 0xffffffff; } else { uint newMask = 0; for (var i = 0; i < areaNames.Length; i++) { //If the bit has been set in the compacted mask if (((areaMask >> i) & 1) != 0) { //Find out the 'real' layer from the name, then set it in the new mask newMask = newMask | (uint)(1 << GameObjectUtility.GetNavMeshAreaFromName(areaNames[i])); } } m_WalkableMask.longValue = newMask; } } EditorGUI.EndProperty(); serializedObject.ApplyModifiedProperties(); }