Tri-Inspector/Unity.InternalAPIEditorBridge.012/ScriptAttributeUtilityProxy.cs

53 lines
1.5 KiB
C#
Raw Normal View History

using UnityEditor;
using UnityEngine;
2023-07-29 05:08:53 -04:00
using UnityEngine.UIElements;
2022-06-01 04:19:33 -04:00
namespace TriInspectorUnityInternalBridge
{
internal static class ScriptAttributeUtilityProxy
{
public static PropertyHandlerProxy GetHandler(SerializedProperty property)
{
var handler = ScriptAttributeUtility.GetHandler(property);
return new PropertyHandlerProxy(handler);
}
}
internal readonly struct PropertyHandlerProxy
{
private readonly PropertyHandler _handler;
internal PropertyHandlerProxy(PropertyHandler handler)
{
_handler = handler;
}
// ReSharper disable once InconsistentNaming
public bool hasPropertyDrawer => _handler.hasPropertyDrawer;
2023-10-15 04:56:15 -04:00
public void SetPreferredLabel(string label)
{
#if UNITY_2022_2_OR_NEWER
if (_handler.propertyDrawer != null)
{
_handler.propertyDrawer.m_PreferredLabel = label;
}
#endif
}
2023-07-29 05:08:53 -04:00
public VisualElement CreatePropertyGUI(SerializedProperty property)
{
return _handler.propertyDrawer?.CreatePropertyGUI(property);
}
public float GetHeight(SerializedProperty property, GUIContent label, bool includeChildren)
{
return _handler.GetHeight(property, label, includeChildren);
}
public bool OnGUI(Rect position, SerializedProperty property, GUIContent label, bool includeChildren)
{
return _handler.OnGUI(position, property, label, includeChildren);
}
}
}