using System; using System.Linq; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; namespace Superlazy.UI { [CanEditMultipleObjects] [CustomEditor(typeof(SLUIDragButton))] public class SLUIDragButtonEditor : Editor { private SLUIDragButton component; private string[] methods; private static string filter; private void OnEnable() { component = target as SLUIDragButton; methods = SLUIEditorUtil.GetAllCommands(); } public override void OnInspectorGUI() { if (component.button != null) { UnityEngine.Events.UnityAction p = component.ButtonAction; UnityEditor.Events.UnityEventTools.RemovePersistentListener(component.button.onClick, p); } if (component.bindParent == null) { EditorGUILayout.LabelField("Can't find session Entity"); } else { EditorGUILayout.LabelField("SessionEntity : " + component.bindParent.BindPath); } filter = EditorGUILayout.TextField("Binding Command Filter", filter); var filterMethods = methods; if (string.IsNullOrEmpty(filter) == false) { filterMethods = methods.Where(name => name.ToLower().Contains(filter.ToLower())).ToArray(); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Binding Command : " + component.command); var currMethod = Array.FindIndex(filterMethods, methodName => methodName == component.command); currMethod = currMethod < 0 ? 0 : currMethod; // None 표기용 var newMethod = EditorGUILayout.Popup(currMethod, filterMethods); if (newMethod > 0) { component.command = filterMethods[newMethod]; } else { component.command = ""; } } EditorGUILayout.EndHorizontal(); if (component.comparison == null) component.comparison = new SLValueComparison(); if (component.bindParent) component.comparison.OnInspector(component.bindParent); if (component.comparison.useCheckValue) { component.useGrayScale = EditorGUILayout.Toggle("Use GrayScale Disable", component.useGrayScale); } component.focus = EditorGUILayout.Toggle("focus", component.focus); if (string.IsNullOrEmpty(component.focusBind) == false) EditorGUILayout.LabelField($"focus bind{component.bindParent.BindPath}.{component.focusBind}"); component.focusBind = EditorGUILayout.TextField("focus bind", component.focusBind); component.fastClick = EditorGUILayout.Toggle("fast click", component.fastClick); component.clickSound = EditorGUILayout.TextField("click sound", component.clickSound); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Cancel Command : " + component.cancelCommand); var currMethod = Array.FindIndex(filterMethods, methodName => methodName == component.cancelCommand); currMethod = currMethod < 0 ? 0 : currMethod; // None 표기용 var newMethod = EditorGUILayout.Popup(currMethod, filterMethods); if (newMethod > 0) { component.cancelCommand = filterMethods[newMethod]; } else { component.cancelCommand = ""; } } EditorGUILayout.EndHorizontal(); component.ViewEntity(); if (GUI.changed && Application.isPlaying == false) { EditorUtility.SetDirty(component); EditorSceneManager.MarkAllScenesDirty(); } } } }