private void OnGUIAvoidance() { CAINavEditorSettings targ = (CAINavEditorSettings)target; string[] names = targ.avoidanceNames; EditorGUILayout.Separator(); for (int i = 0; i < names.Length; i++) { string val = EditorGUILayout.TextField(i.ToString(), names[i]); names[i] = (val.Length == 0 ? names[i] : val); } }
private void OnGUIFlags() { CAINavEditorSettings targ = (CAINavEditorSettings)target; string[] names = targ.flagNames; EditorGUILayout.Separator(); for (int i = 0; i < names.Length; i++) { string val = EditorGUILayout.TextField(string.Format("0x{0:X}", 1 << i), names[i]); names[i] = (val.Length == 0 ? names[i] : val); } }
private byte NextUndefinedArea() { CAINavEditorSettings targ = (CAINavEditorSettings)target; string[] areaNames = targ.areaNames; for (int i = 1; i < areaNames.Length; i++) { if (areaNames[i] == CAINavEditorSettings.Undefined) { return((byte)i); } } return(0); }
static void EditSettings() { CAINavEditorSettings item = EditorUtil.GetGlobalAsset <CAINavEditorSettings>(); Selection.activeObject = item; }
private void OnGUIAreas() { CAINavEditorSettings targ = (CAINavEditorSettings)target; string[] areaNames = targ.areaNames; EditorGUILayout.Separator(); for (int i = 0; i < areaNames.Length; i++) { if (areaNames[i] == CAINavEditorSettings.Undefined) { continue; } EditorGUILayout.BeginHorizontal(); GUI.enabled = (i != Navmesh.NullArea); string areaName = EditorGUILayout.TextField(i.ToString(), areaNames[i]); // Note: Extra checks reduce the need to run the last check, which is more expensive. if (areaName.Length > 0 && areaName != areaNames[i] && areaName != CAINavEditorSettings.NotWalkable && // Quick check. areaName != CAINavEditorSettings.Undefined && // This check is important. targ.GetArea(areaName) == CAINavEditorSettings.UnknownArea) { areaNames[i] = areaName; } GUI.enabled = !(i == Navmesh.NullArea || i == Navmesh.MaxArea); if (GUILayout.Button("X", GUILayout.Width(30))) { areaNames[i] = CAINavEditorSettings.Undefined; mNewArea = NextUndefinedArea(); mFocusNew = true; // Prevents off GUI behavior. GUI.changed = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUI.SetNextControlName(AddAreaName); mNewArea = NavUtil.ClampArea(EditorGUILayout.IntField(mNewArea, GUILayout.Width(80))); if (mFocusNew) { GUI.FocusControl(AddAreaName); mFocusNew = false; } GUI.enabled = (areaNames[mNewArea] == CAINavEditorSettings.Undefined); if (GUILayout.Button("Add", GUILayout.Width(80))) { areaNames[mNewArea] = "Area " + mNewArea; mNewArea = NextUndefinedArea(); mFocusNew = true; GUI.changed = true; } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Maximum allowed area: " + Navmesh.MaxArea , EditorUtil.HelpStyle, GUILayout.ExpandWidth(true)); }
/// <summary> /// Gets a clone of the global well known avoidance type names. /// </summary> /// <returns>A clone of the well known avoidance type names.</returns> public static string[] GetAvoidanceNames() { CAINavEditorSettings settings = EditorUtil.GetGlobalAsset <CAINavEditorSettings>(); return((string[])settings.avoidanceNames.Clone()); }
/// <summary> /// Creates a control useful for assigning area values. /// </summary> /// <param name="label">The default label for the control.</param> /// <returns></returns> public static AreaGUIControl CreateAreaControl(string label) { CAINavEditorSettings settings = EditorUtil.GetGlobalAsset <CAINavEditorSettings>(); return(new AreaGUIControl(label, (string[])settings.areaNames.Clone())); }