private void LoadPreferences() { waypointPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(PlayerPrefs.GetString(WAYPOINT_PATH_KEY, ""), typeof(GameObject)); templateToSpawn = (PatrolTemplate)AssetDatabase.LoadAssetAtPath(PlayerPrefs.GetString(TEMPLATE_PATH_KEY, ""), typeof(PatrolTemplate)); showAll = IntToBool(PlayerPrefs.GetInt(SHOWALL_KEY, 1)); autoUpdate = IntToBool(PlayerPrefs.GetInt(AUTOUPDATE_KEY, 1)); showLabels = IntToBool(PlayerPrefs.GetInt(SHOW_LABELS_KEY, 1)); showNames = IntToBool(PlayerPrefs.GetInt(SHOWNAMES_KEY, 1)); labelOffset = new Vector2(PlayerPrefs.GetFloat(LABEL_OFFSET_X, 20), PlayerPrefs.GetFloat(LABEL_OFFSET_Y, -10)); }
void OnGUI() { EditorGUILayout.BeginVertical(GUILayout.MaxWidth(500)); GUILayout.Label("Patrols", EditorStyles.boldLabel); var oldShowAll = showAll; showAll = EditorGUILayout.Toggle("Show all / only selected", showAll); autoUpdate = EditorGUILayout.Toggle("Auto update waypoints", autoUpdate); showLabels = EditorGUILayout.Toggle("Show labels", showLabels); showNames = EditorGUILayout.Toggle("Show names", showNames); labelOffset = EditorGUILayout.Vector2Field("Label offset", labelOffset); EditorGUILayout.LabelField("Template Creation", EditorStyles.boldLabel); if (GUILayout.Button("Create template (from selected or empty")) { CreatePatrolTemplate(); } EditorGUILayout.BeginFadeGroup(1); EditorGUILayout.LabelField("Patrol spawning", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Patrol template to spawn"); templateToSpawn = (PatrolTemplate)EditorGUILayout.ObjectField(templateToSpawn, typeof(PatrolTemplate), true); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndFadeGroup(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Waypoint prefab"); waypointPrefab = (GameObject)EditorGUILayout.ObjectField(waypointPrefab, typeof(GameObject), false); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Spawn patrol from template")) { CreatePatrolFromTemplate(); } EditorGUILayout.EndVertical(); if (showAll != oldShowAll) { UpdateActivePatrolsAndVisibility(); } }