インスペクタのパラメータの名前を簡単に変えるエディタ拡張
属性
CustomLabelAttribute.cs
using UnityEngine;
public class CustomLabelAttribute : PropertyAttribute
{
public readonly string Value;
public CustomLabelAttribute(string value)
{
Value = value;
}
}
エディタ側のコード
CustomLabelDrawer.cs
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(CustomLabelAttribute))]
public class CustomLabelDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var newLabel = attribute as CustomLabelAttribute;
EditorGUI.PropertyField(position, property, new GUIContent(newLabel.Value), true);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, true);
}
}
追記2019/7/19
Rectや配列等のマルチラインに対応
使用側のコードサンプル
UseCustomLabelAttribute.cs
using UnityEngine;
public class UseCustomLabelAttribute : MonoBehaviour
{
[CustomLabel("カウント")]
public int Count;
}
適用前
適用後
名前だけ表示を変えたい事がよくあるんですけど
Unityの標準機能であるかな、と探してても見つからなかったので作りました。
競合とかは一切考えてないです
Author And Source
この問題について(インスペクタのパラメータの名前を簡単に変えるエディタ拡張), 我々は、より多くの情報をここで見つけました https://qiita.com/Basuhei_Acheron/items/419f19d6532f1ffd3f33著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .