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 static int GetNavMeshLayer(GameObject go) { return(GameObjectUtility.GetNavMeshArea(go)); }