com.sky.ondeviceagent / Runtime /AgentCore /Editor /PasswordFieldDrawer.cs
Sky-Kim's picture
Initial commit
2e7837a
Raw
History Blame Contribute Delete
902 Bytes
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using OnDeviceAgent.AgentCore;
namespace OnDeviceAgent.AgentCore.Editor
{
[CustomPropertyDrawer(typeof(PasswordFieldAttribute))]
public sealed class PasswordFieldDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (property.propertyType != SerializedPropertyType.String)
{
EditorGUI.PropertyField(position, property, label);
return;
}
EditorGUI.BeginProperty(position, label, property);
EditorGUI.BeginChangeCheck();
var value = EditorGUI.PasswordField(position, label, property.stringValue);
if (EditorGUI.EndChangeCheck())
property.stringValue = value;
EditorGUI.EndProperty();
}
}
}
#endif