修改
This commit is contained in:
parent
457b7f8615
commit
5d125f70ff
@ -1,111 +0,0 @@
|
|||||||
|
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor;
|
|
||||||
public static class UIEditorSkinHelper
|
|
||||||
{
|
|
||||||
public static void DrawProperty(SerializedProperty property, GUISkin skin, string content)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
|
||||||
|
|
||||||
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
|
|
||||||
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DrawProperty(SerializedProperty property, GUISkin skin, string content, string btnName, Action callback)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
|
||||||
if (GUILayout.Button(btnName))
|
|
||||||
{
|
|
||||||
callback?.Invoke();
|
|
||||||
}
|
|
||||||
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
|
|
||||||
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DrawPropertyPlain(SerializedProperty property, GUISkin skin, string content)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
|
|
||||||
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
|
|
||||||
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DrawPropertyCW(SerializedProperty property, GUISkin skin, string content, float width)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
|
||||||
|
|
||||||
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(width));
|
|
||||||
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DrawPropertyPlainCW(SerializedProperty property, GUISkin skin, string content, float width)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
|
|
||||||
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(width));
|
|
||||||
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int DrawTabs(int tabIndex, GUIContent[] tabs, GUISkin skin)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
GUILayout.Space(17);
|
|
||||||
|
|
||||||
tabIndex = GUILayout.Toolbar(tabIndex, tabs, skin.FindStyle("Tab Indicator"));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
GUILayout.Space(-40);
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
GUILayout.Space(17);
|
|
||||||
|
|
||||||
return tabIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DrawComponentHeader(GUISkin skin, string content)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
GUILayout.Box(new GUIContent(""), skin.FindStyle(content));
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
GUILayout.Space(-42);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DrawHeader(GUISkin skin, string content, int space)
|
|
||||||
{
|
|
||||||
GUILayout.Space(space);
|
|
||||||
GUILayout.Box(new GUIContent(""), skin.FindStyle(content));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool DrawToggle(bool value, GUISkin skin, string content)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
|
||||||
|
|
||||||
value = GUILayout.Toggle(value, new GUIContent(content), skin.FindStyle("Toggle"));
|
|
||||||
value = GUILayout.Toggle(value, new GUIContent(""), skin.FindStyle("Toggle Helper"));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool DrawTogglePlain(bool value, GUISkin skin, string content)
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal();
|
|
||||||
|
|
||||||
value = GUILayout.Toggle(value, new GUIContent(content), skin.FindStyle("Toggle"));
|
|
||||||
value = GUILayout.Toggle(value, new GUIContent(""), skin.FindStyle("Toggle Helper"));
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -3,7 +3,7 @@ using System.Reflection;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AlicizaX.UI.Extension.Editor.Editor.Editor_Handlers
|
namespace AlicizaX.UI.Extension.Editor
|
||||||
{
|
{
|
||||||
public static class ExtensionHelper
|
public static class ExtensionHelper
|
||||||
{
|
{
|
114
Editor/Helper/GUISkinHelper.cs
Normal file
114
Editor/Helper/GUISkinHelper.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace AlicizaX.UI.Extension.Editor
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
public static class GUISkinHelper
|
||||||
|
{
|
||||||
|
public static void DrawProperty(SerializedProperty property, GUISkin skin, string content)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
|
||||||
|
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawProperty(SerializedProperty property, GUISkin skin, string content, string btnName, Action callback)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
||||||
|
if (GUILayout.Button(btnName))
|
||||||
|
{
|
||||||
|
callback?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
|
||||||
|
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawPropertyPlain(SerializedProperty property, GUISkin skin, string content)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(120));
|
||||||
|
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawPropertyCW(SerializedProperty property, GUISkin skin, string content, float width)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(width));
|
||||||
|
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawPropertyPlainCW(SerializedProperty property, GUISkin skin, string content, float width)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField(new GUIContent(content), skin.FindStyle("Text"), GUILayout.Width(width));
|
||||||
|
EditorGUILayout.PropertyField(property, new GUIContent(""));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int DrawTabs(int tabIndex, GUIContent[] tabs, GUISkin skin)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Space(17);
|
||||||
|
|
||||||
|
tabIndex = GUILayout.Toolbar(tabIndex, tabs, skin.FindStyle("Tab Indicator"));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.Space(-40);
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Space(17);
|
||||||
|
|
||||||
|
return tabIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawComponentHeader(GUISkin skin, string content)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Box(new GUIContent(""), skin.FindStyle(content));
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.Space(-42);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawHeader(GUISkin skin, string content, int space)
|
||||||
|
{
|
||||||
|
GUILayout.Space(space);
|
||||||
|
GUILayout.Box(new GUIContent(""), skin.FindStyle(content));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool DrawToggle(bool value, GUISkin skin, string content)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal(EditorStyles.helpBox);
|
||||||
|
|
||||||
|
value = GUILayout.Toggle(value, new GUIContent(content), skin.FindStyle("Toggle"));
|
||||||
|
value = GUILayout.Toggle(value, new GUIContent(""), skin.FindStyle("Toggle Helper"));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool DrawTogglePlain(bool value, GUISkin skin, string content)
|
||||||
|
{
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
|
||||||
|
value = GUILayout.Toggle(value, new GUIContent(content), skin.FindStyle("Toggle"));
|
||||||
|
value = GUILayout.Toggle(value, new GUIContent(""), skin.FindStyle("Toggle Helper"));
|
||||||
|
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AlicizaX.UI.Extension.Editor.Editor.Editor_Handlers;
|
using AlicizaX.UI.Extension.Editor;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditorInternal;
|
using UnityEditorInternal;
|
||||||
using UnityEditor.UI;
|
using UnityEditor.UI;
|
||||||
@ -187,7 +187,7 @@ public class UXButtonEditor : Editor
|
|||||||
EditorGUILayout.PropertyField(m_Mode);
|
EditorGUILayout.PropertyField(m_Mode);
|
||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup();
|
||||||
|
|
||||||
var interactable = UIEditorSkinHelper.DrawToggle(m_Interactable.boolValue, customSkin, "Interactable");
|
var interactable = GUISkinHelper.DrawToggle(m_Interactable.boolValue, customSkin, "Interactable");
|
||||||
m_Interactable.boolValue = interactable;
|
m_Interactable.boolValue = interactable;
|
||||||
|
|
||||||
GUILayout.Space(1);
|
GUILayout.Space(1);
|
||||||
@ -216,14 +216,14 @@ public class UXButtonEditor : Editor
|
|||||||
|
|
||||||
private void DrawAudioTab()
|
private void DrawAudioTab()
|
||||||
{
|
{
|
||||||
UIEditorSkinHelper.DrawProperty(hoverAudioClip, customSkin, "Hover Sound", "Play", () =>
|
GUISkinHelper.DrawProperty(hoverAudioClip, customSkin, "Hover Sound", "Play", () =>
|
||||||
{
|
{
|
||||||
if (hoverAudioClip.objectReferenceValue != null)
|
if (hoverAudioClip.objectReferenceValue != null)
|
||||||
{
|
{
|
||||||
PlayAudio((AudioClip)hoverAudioClip.objectReferenceValue);
|
PlayAudio((AudioClip)hoverAudioClip.objectReferenceValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UIEditorSkinHelper.DrawProperty(clickAudioClip, customSkin, "Click Sound", "Play", () =>
|
GUISkinHelper.DrawProperty(clickAudioClip, customSkin, "Click Sound", "Play", () =>
|
||||||
{
|
{
|
||||||
if (hoverAudioClip.objectReferenceValue != null)
|
if (hoverAudioClip.objectReferenceValue != null)
|
||||||
{
|
{
|
||||||
@ -251,7 +251,7 @@ public class UXButtonEditor : Editor
|
|||||||
|
|
||||||
if (m_Mode.enumValueIndex == (int)ButtonModeType.Toggle)
|
if (m_Mode.enumValueIndex == (int)ButtonModeType.Toggle)
|
||||||
{
|
{
|
||||||
UIEditorSkinHelper.DrawProperty(m_UXGroup, customSkin, "UXGroup");
|
GUISkinHelper.DrawProperty(m_UXGroup, customSkin, "UXGroup");
|
||||||
|
|
||||||
UXGroup newGroup = (UXGroup)m_UXGroup.objectReferenceValue;
|
UXGroup newGroup = (UXGroup)m_UXGroup.objectReferenceValue;
|
||||||
if (newGroup != group)
|
if (newGroup != group)
|
||||||
|
Loading…
Reference in New Issue
Block a user