Added FieldLabelFrom attribute
This commit is contained in:
parent
52ee51c61c
commit
81bac32538
6 changed files with 60 additions and 0 deletions
3
Editor/Predrawers.meta
Normal file
3
Editor/Predrawers.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b11bc545d74c48e4aaac5cd734c534a9
|
||||
timeCreated: 1638612721
|
||||
25
Editor/Predrawers/FieldLabelFromAttributeDrawer.cs
Normal file
25
Editor/Predrawers/FieldLabelFromAttributeDrawer.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.Inspector.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(FieldLabelFromAttribute))]
|
||||
internal sealed class FieldLabelFromAttributeDrawer : PredrawerModifierPropertyDrawer
|
||||
{
|
||||
public override void Modify(PredrawerModifierPropertyAttribute attribute, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var att = (FieldLabelFromAttribute)attribute;
|
||||
SerializedProperty sp = property.GetRelativeProperty(att.fieldName);
|
||||
|
||||
if (sp == null)
|
||||
return;
|
||||
|
||||
string str = sp.GetValueAsString();
|
||||
|
||||
if (att.nicify)
|
||||
str = ObjectNames.NicifyVariableName(str);
|
||||
|
||||
label.text = str;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Predrawers/FieldLabelFromAttributeDrawer.cs.meta
Normal file
3
Editor/Predrawers/FieldLabelFromAttributeDrawer.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 30eda277627d4bca8ddce716ef21b657
|
||||
timeCreated: 1638612733
|
||||
Loading…
Add table
Add a link
Reference in a new issue