Last active
April 8, 2019 19:46
-
-
Save XakazukinX/9f9e2cbd49d9d85601b5b8be88dcf686 to your computer and use it in GitHub Desktop.
変数名の代わりに好きな文字列をインスペクタに表示できるカスタム属性
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEditor; | |
using UnityEngine; | |
namespace shigeno_EditorUtility | |
{ | |
public class CustomLabelAttribute : PropertyAttribute | |
{ | |
public string newFieldLabel; | |
public CustomLabelAttribute(string _newLabel) | |
{ | |
this.newFieldLabel = _newLabel; | |
} | |
} | |
[CustomPropertyDrawer(typeof(CustomLabelAttribute))] | |
public class Drawer : PropertyDrawer | |
{ | |
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | |
{ | |
CustomLabelAttribute customLabel = (CustomLabelAttribute) attribute; | |
label.text = customLabel.newFieldLabel; | |
EditorGUI.PropertyField(position, property, label); | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment