mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
Fix incorrect TextArea attribute rendering
This commit is contained in:
parent
a17cfcf39d
commit
eb5a95c9d8
@ -26,6 +26,14 @@ using UnityEngine;
|
||||
|
||||
namespace TriInspector.Drawers
|
||||
{
|
||||
public class StringDrawer : BuiltinDrawerBase<string>
|
||||
{
|
||||
protected override string OnValueGUI(Rect position, GUIContent label, string value)
|
||||
{
|
||||
return EditorGUI.TextField(position, label, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class BooleanDrawer : BuiltinDrawerBase<bool>
|
||||
{
|
||||
protected override bool OnValueGUI(Rect position, GUIContent label, bool value)
|
||||
|
@ -1,80 +0,0 @@
|
||||
using TriInspector;
|
||||
using TriInspector.Drawers;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[assembly: RegisterTriValueDrawer(typeof(StringDrawer), TriDrawerOrder.Fallback)]
|
||||
|
||||
namespace TriInspector.Drawers
|
||||
{
|
||||
public class StringDrawer : TriValueDrawer<string>
|
||||
{
|
||||
public override TriElement CreateElement(TriValue<string> value, TriElement next)
|
||||
{
|
||||
if (value.Property.TryGetSerializedProperty(out var serializedProperty))
|
||||
{
|
||||
return new StringSerializedPropertyDrawerElement(value.Property, serializedProperty);
|
||||
}
|
||||
|
||||
return new StringDrawerElement(value);
|
||||
}
|
||||
|
||||
private class StringDrawerElement : TriElement
|
||||
{
|
||||
private TriValue<string> _propertyValue;
|
||||
|
||||
public StringDrawerElement(TriValue<string> propertyValue)
|
||||
{
|
||||
_propertyValue = propertyValue;
|
||||
}
|
||||
|
||||
public override float GetHeight(float width)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
var value = _propertyValue.SmartValue;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
value = EditorGUI.TextField(position, _propertyValue.Property.DisplayNameContent, value);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
_propertyValue.SmartValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class StringSerializedPropertyDrawerElement : TriElement
|
||||
{
|
||||
private readonly TriProperty _property;
|
||||
private readonly SerializedProperty _serializedProperty;
|
||||
|
||||
public StringSerializedPropertyDrawerElement(TriProperty property, SerializedProperty serializedProperty)
|
||||
{
|
||||
_property = property;
|
||||
_serializedProperty = serializedProperty;
|
||||
}
|
||||
|
||||
public override float GetHeight(float width)
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
EditorGUI.PropertyField(position, _serializedProperty, _property.DisplayNameContent);
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
_property.NotifyValueChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e5a2105103347338b704022e9a860d4
|
||||
timeCreated: 1639316821
|
9
Editor.Samples/Styling/Styling_TextArea.cs
Normal file
9
Editor.Samples/Styling/Styling_TextArea.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_TextArea : ScriptableObject
|
||||
{
|
||||
public string simpleText;
|
||||
|
||||
[TextArea(10, 15)]
|
||||
public string textArea;
|
||||
}
|
3
Editor.Samples/Styling/Styling_TextArea.cs.meta
Normal file
3
Editor.Samples/Styling/Styling_TextArea.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 902c15a04330446fb0a38fb0d5282470
|
||||
timeCreated: 1657887155
|
Loading…
Reference in New Issue
Block a user