public override void OnInspectorGUI() { if (Application.isPlaying) { EditorGUILayout.HelpBox("These settings cannot be edited in play mode.", MessageType.Info); return; } this.serializedObject.Update(); EditorUtilities.Section("Height Sampling"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_heightSampling); if (EditorGUI.EndChangeCheck()) { DefaultHeightNavigatorEditor.EnsureValidProviders((HeightSamplingMode)_heightSampling.intValue); } if (_heightSampling.intValue == (int)HeightSamplingMode.HeightMap) { EditorGUILayout.PropertyField(_heightMapDetail); } bool isFlat = (_heightSampling.intValue == (int)HeightSamplingMode.NoHeightSampling); if (!isFlat) { EditorGUILayout.PropertyField(_heightSamplingGranularity); EditorGUILayout.PropertyField(_ledgeThreshold); EditorGUILayout.Separator(); EditorGUI.indentLevel--; EditorGUILayout.PropertyField(_useGlobalHeightNavigationSettings); if (_useGlobalHeightNavigationSettings.boolValue) { EditorGUILayout.PropertyField(_unitsHeightNavigationCapability, GUIContent.none, true); } } EditorGUILayout.Separator(); EditorGUILayout.PropertyField(_useClearance); if (!isFlat && _useClearance.boolValue) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_heightDiffThreshold); EditorGUI.indentLevel--; } InspectorGUI(); this.serializedObject.ApplyModifiedProperties(); if (GUI.changed) { var t = this.target as NavigationSettingsComponent; t.Refresh(); } }
internal static void Upgrade() { Replace <TurnableUnitComponent, SteerToAlignWithVelocity>( (a, b) => { b.alignWithElevation = (a.ignoreAxis == WorldGeometry.Axis.None); }); var nsc = AddGameWorldItem <NavigationSettingsComponent>( (gw, ns, added) => { if (added) { var grid = FindComponent <GridComponent>(); if (grid == null) { return; } ns.heightSamplingGranularity = grid.heightGranularity; var unitnav = ns.unitsHeightNavigationCapability; unitnav.maxClimbHeight = grid.maxScaleHeight; unitnav.maxSlopeAngle = grid.maxWalkableSlopeAngle; ns.unitsHeightNavigationCapability = unitnav; } //Fix old sphere cast option if ((int)ns.heightSampling == 3) { ns.heightSampling = HeightSamplingMode.Raycast; } }); //Ensure each unit has a height navigator var suc = GetAllNonPrefabInstances <SteerableUnitComponent>(); foreach (var c in suc) { if (c.As <IHeightNavigator>() == null) { var dhn = c.gameObject.AddComponent <DefaultHeightNavigator>(); dhn.gravity = c.gravity; dhn.groundStickynessFactor = c.groundStickynessFactor; dhn.terminalVelocity = c.terminalVelocity; DefaultHeightNavigatorEditor.EnsureValidProvider(dhn, nsc.heightSampling); //Set the default constraints of the rigidbody, we no longer want to force this on awake var rb = c.GetComponent <Rigidbody>(); if (rb != null) { rb.constraints |= RigidbodyConstraints.FreezeRotation; } } } //Get path finder options from steer for path var sfp = GetAllNonPrefabInstances <SteerForPathComponent>(); FixPathOptions(sfp); //Get selection visual from selectable unit if present var selectables = GetAllNonPrefabInstances <SelectableUnitComponent>(); FixSelectables(selectables); //Set any basic avoidance to the same prio as steer for path var sfba = GetAllNonPrefabInstances <SteerForBasicAvoidanceComponent>(); foreach (var a in sfba) { if (a.priority == 0) { a.priority = 5; } } var units = GetAllNonPrefabInstances <UnitComponent>(); ApexComponentMaster m; foreach (var u in units) { if (AddIfMissing <ApexComponentMaster>(u.gameObject, false, out m)) { while (UnityEditorInternal.ComponentUtility.MoveComponentUp(m)) { /* NOOP */ } } } AddGameWorldItem <ApexComponentMaster>(); Debug.Log("Scene and Prefabs were successfully updated to the latest version of Apex Path."); Debug.LogWarning("Please note that all prefab instances that had modified properties have been reset to the values of their prefab (Only applies to Apex Path Components)."); UpdateSteer(); }