123456789101112131415161718192021222324252627282930313233343536373839 |
- using UnityEngine;
- using UnityEditor;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- [CanEditMultipleObjects]
- [CustomEditor(typeof(LocationManager))]
- public class LocationManagerEditor : Editor
- {
- public override void OnInspectorGUI()
- {
- LocationManager myMenusController = target as LocationManager;
- base.OnInspectorGUI();
- EditorGUILayout.Space();
- EditorGUILayout.LabelField("Tools:", EditorStyles.boldLabel);
- if (GUILayout.Button("Update All Locations)"))
- {
- Undo.RecordObject(myMenusController, "Update All Menus");
- myMenusController.locations = GettAllMenus();
- }
- }
- string[] GettAllMenus()
- {
- string[] allNames = Directory.GetFiles("Assets/Prefab/Locations", "*.prefab", SearchOption.AllDirectories);
- for (int i = 0; i < allNames.Length; i++)
- {
- allNames[i] = Path.GetFileName(allNames[i]);
- allNames[i] = allNames[i].Remove(allNames[i].Length - 7);
- }
- return allNames;
- }
- }
|