123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- namespace deleteUtility
- {
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text.RegularExpressions;
- using UnityEditor;
- using UnityEngine;
- public class DeleteUtilityWindow : EditorWindow
- {
- #region Config
- protected DeleteUtility Instance;
- protected SerializedProperty Folder;
- protected SerializedObject SerializedObject;
- #endregion
- [MenuItem("DashGame/DeleteUtility")]
- protected static void ShowWindow()
- {
- Type inspectorType = Type.GetType("UnityEditor.InspectorWindow,UnityEditor.dll");
- DeleteUtilityWindow window = GetWindow<DeleteUtilityWindow>(inspectorType);
- window.titleContent = new GUIContent("DeleteUtility");
- window.Show();
- }
- private void OnEnable()
- {
- Instance = InstanceManager.SearchInstance<DeleteUtility>();
- SerializedObject = new SerializedObject(Instance);
- Folder = SerializedObject.FindProperty("Folder");
- }
- private void OnGUI()
- {
- SerializedObject.Update();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(Folder, new GUIContent("Folder"));
- if (GUILayout.Button("UseSelectedPath", GUILayout.MaxWidth(120)))
- {
- GetSelectedPath(ref Instance.Folder);
- }
- EditorGUILayout.EndHorizontal();
- SerializedObject.ApplyModifiedProperties();
- }
- protected void GetSelectedPath(ref string value)
- {
- if (Selection.assetGUIDs.Length > 0)
- {
- string path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
- path = Path.GetDirectoryName(path);
- if (string.IsNullOrEmpty(path))
- {
- value = "Assets";
- }
- else
- {
- value = path;
- }
- }
- }
- }
- }
|