2023-08-17 08:43:02 +08:00
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
2022-06-14 12:39:13 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace Coffee.NanoMonitor
|
|
|
|
|
{
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
[CustomPropertyDrawer(typeof(CustomMonitorItem))]
|
|
|
|
|
internal sealed class CustomMonitorItemDrawer : PropertyDrawer
|
|
|
|
|
{
|
|
|
|
|
public override void OnGUI(Rect p, SerializedProperty property, GUIContent label)
|
|
|
|
|
{
|
2023-08-17 08:43:02 +08:00
|
|
|
|
var pos = new Rect(p.x, p.y + 18 * 0, p.width, 16);
|
|
|
|
|
EditorGUI.PropertyField(pos, property.FindPropertyRelative("m_Text"));
|
|
|
|
|
pos.y += 18;
|
|
|
|
|
EditorGUI.PropertyField(pos, property.FindPropertyRelative("m_Format"));
|
|
|
|
|
pos.y += 18;
|
2022-06-14 12:39:13 +08:00
|
|
|
|
EditorGUI.indentLevel++;
|
2023-08-17 08:43:02 +08:00
|
|
|
|
EditorGUI.PropertyField(pos, property.FindPropertyRelative("m_Arg0"));
|
|
|
|
|
pos.y += 18;
|
|
|
|
|
EditorGUI.PropertyField(pos, property.FindPropertyRelative("m_Arg1"));
|
|
|
|
|
pos.y += 18;
|
|
|
|
|
EditorGUI.PropertyField(pos, property.FindPropertyRelative("m_Arg2"));
|
2022-06-14 12:39:13 +08:00
|
|
|
|
EditorGUI.indentLevel--;
|
|
|
|
|
|
|
|
|
|
property.serializedObject.ApplyModifiedProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
|
|
|
|
{
|
|
|
|
|
return (EditorGUIUtility.singleLineHeight + 2) * 5;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-08-17 08:43:02 +08:00
|
|
|
|
[Serializable]
|
2022-06-14 12:39:13 +08:00
|
|
|
|
public class CustomMonitorItem
|
|
|
|
|
{
|
2023-08-17 08:43:02 +08:00
|
|
|
|
[SerializeField] private MonitorUI m_Text;
|
2022-06-14 12:39:13 +08:00
|
|
|
|
[SerializeField] private string m_Format = "";
|
2023-08-17 08:43:02 +08:00
|
|
|
|
[SerializeField] private NumericProperty m_Arg0;
|
|
|
|
|
[SerializeField] private NumericProperty m_Arg1;
|
|
|
|
|
[SerializeField] private NumericProperty m_Arg2;
|
2022-06-14 12:39:13 +08:00
|
|
|
|
|
|
|
|
|
public void UpdateText()
|
|
|
|
|
{
|
|
|
|
|
if (m_Text)
|
2023-08-17 08:43:02 +08:00
|
|
|
|
{
|
2022-06-14 12:39:13 +08:00
|
|
|
|
m_Text.SetText(m_Format, m_Arg0.Get(), m_Arg1.Get(), m_Arg2.Get());
|
2023-08-17 08:43:02 +08:00
|
|
|
|
}
|
2022-06-14 12:39:13 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|