Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 68 additions & 31 deletions Editor/SDFQuadEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
* https://github.com/kirevdokimov/Unity-UI-Rounded-Corners/blob/master/UiRoundedCorners/Editor/ImageWithIndependentRoundedCornersInspector.cs
**/

using UnityEngine.UI;
using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace TLab.UI.SDF.Editor
{
#if UNITY_EDITOR
//#if UNITY_EDITOR
[CustomEditor(typeof(SDFQuad))]
public class SDFQuadEditor : UnityEditor.Editor
{
Expand All @@ -26,47 +27,83 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

serializedObject.TryDrawProperty("m_" + nameof(m_instance.independent), "Independent Corner");

GUIStyle style = new(EditorStyles.boldLabel)
{
fontSize = 16,
contentOffset = new Vector2(18, 0),
};
EditorGUILayout.LabelField("Fill", style);
EditorGUI.indentLevel++;
{
serializedObject.TryDrawProperty("m_" + nameof(m_instance.mainColor), "Color");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.sprite), "Sprite");
if (m_instance.sprite != null)
{
serializedObject.TryDrawProperty("m_" + nameof(m_instance.mainTextureScale), "Scale");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.mainTextureOffset), "Offset");
}
}
EditorGUI.indentLevel--;
serializedObject.TryDrawLeftToggle("m_" + nameof(m_instance.independent), "Independent Corner");
EditorGUI.indentLevel++;
if (m_instance.independent)
{
serializedObject.TryDrawProperty("m_" + nameof(m_instance.radiusX), "Top Right Corner");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.radiusY), "Bottom Right Corner");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.radiusZ), "Top Left Corner");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.radiusW), "Bottom Left Corner");
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.LabelField("Corners");
EditorGUILayout.BeginVertical();
{
serializedObject.TryDrawPropertyNoLabel("m_" + nameof(m_instance.radiusZ));
serializedObject.TryDrawPropertyNoLabel("m_" + nameof(m_instance.radiusY));
}
EditorGUILayout.EndVertical();
EditorGUILayout.BeginVertical();
{
serializedObject.TryDrawPropertyNoLabel("m_" + nameof(m_instance.radiusX));
serializedObject.TryDrawPropertyNoLabel("m_" + nameof(m_instance.radiusW));
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndHorizontal();
}
else
{
serializedObject.TryDrawProperty("m_" + nameof(m_instance.radius), "Corner");
}
EditorGUI.indentLevel--;

serializedObject.TryDrawProperty("m_" + nameof(m_instance.onion), "Onion");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.onionWidth), "OnionWidth");

serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadow), "Shadow");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowWidth), "ShadowWidth");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowBlur), "ShadowBlur");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowPower), "shadowPower");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowColor), "ShadowColor");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowOffset), "ShadowOffset");

serializedObject.TryDrawProperty("m_" + nameof(m_instance.outline), "Outline");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.outlineWidth), "OutlineWidth");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.outlineColor), "OutlineColor");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.outlineType), "OutlineType");

serializedObject.TryDrawProperty("m_" + nameof(m_instance.sprite), "Frame");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.mainTextureScale), "Scale");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.mainTextureOffset), "Offset");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.mainColor), "Color");
serializedObject.TryDrawLeftToggle("m_" + nameof(m_instance.outline), "Outline");
EditorGUI.indentLevel++;
if (m_instance.outline)
{
serializedObject.TryDrawProperty("m_" + nameof(m_instance.outlineWidth), "OutlineWidth");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.outlineColor), "OutlineColor");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.outlineType), "OutlineType");
}
EditorGUI.indentLevel--;

serializedObject.ApplyModifiedProperties();
serializedObject.TryDrawLeftToggle("m_" + nameof(m_instance.onion), "Onion");
EditorGUI.indentLevel++;
if (m_instance.onion)
{
serializedObject.TryDrawProperty("m_" + nameof(m_instance.onionWidth), "OnionWidth");
}
EditorGUI.indentLevel--;

if (!m_instance.TryGetComponent<MaskableGraphic>(out var _))
serializedObject.TryDrawLeftToggle("m_" + nameof(m_instance.shadow), "Shadow");
EditorGUI.indentLevel++;
if (m_instance.shadow)
{
EditorGUILayout.HelpBox("This m_instance requires an MaskableGraphic (Image or RawImage) component on the same gameobject", MessageType.Warning);
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowColor), "ShadowColor");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowOffset), "ShadowOffset");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowWidth), "ShadowWidth");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowBlur), "ShadowBlur");
serializedObject.TryDrawProperty("m_" + nameof(m_instance.shadowPower), "shadowPower");
}
EditorGUI.indentLevel--;

serializedObject.ApplyModifiedProperties();
}
}
#endif
//#endif
}
Loading