using UnityEditor;
[CustomEditor(typeof(ProbeObject))]
public class ProbeInspector : Editor
{
SerializedProperty _probe;
public void OnEnable()
{
SerializedProperty p = serializedObject.FindProperty("property");
if(p.propertyType == SerializedPropertyType.Integer) _probe = p;
else Debug.LogError("Bad!!!");
if(_probe == null) Debug.LogWarning("NOT!!!");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
Type ty = target.GetType();
string tip = string.Empty;
FieldInfo[] fields = ty.GetFields();
foreach(FieldInfo field in fields)
{
Attribute[] attrs = Attribute.GetCustomAttributes(field);
foreach(Attribute attr in attrs)
{
MyFieldAttribute sf = attr as MyFieldAttribute;
if(sf == null) continue;
tip = sf.tooltip;
}
}
EditorGUILayout.IntSlider(_probe, 0, 100, new GUIContent("Probe", tip));
serializedObject.ApplyModifiedProperties();
}
}