123456789101112131415161718192021222324252627282930313233343536373839 |
- using UnityEngine;
- using UnityEditor;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- [CanEditMultipleObjects]
- [CustomEditor(typeof(CharacterManager))]
- public class CharacterManagerEditor : Editor
- {
- public override void OnInspectorGUI()
- {
- CharacterManager myMenusController = target as CharacterManager;
- base.OnInspectorGUI();
- EditorGUILayout.Space();
- EditorGUILayout.LabelField("Tools:", EditorStyles.boldLabel);
- if (GUILayout.Button("Update All Characters)"))
- {
- Undo.RecordObject(myMenusController, "Update All Menus");
- myMenusController.NPCs = GettAllMenus();
- }
- }
- string[] GettAllMenus()
- {
- string[] allNames = Directory.GetFiles("Assets/Resources/NPCs", "*.prefab");
- 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;
- }
- }
|