Files
plugin-library/Assets/07.RKTools/Editor/ARTrackedImageEvoObjEditor.cs
zhangzheng 2c230960db 修改
2026-03-25 16:58:26 +08:00

54 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Stary.Evo.Editor;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.RKTools
{
#if Evo_Rokid
[CustomEditor(typeof(ARTrackedImageEvoObj))]
public class ARTrackedImageEvoObjEditor : UnityEditor.Editor
{
/// <summary>
/// 序列化属性在OnEnable中获取
/// </summary>
private SerializedProperty domain;
private SerializedProperty trackedTransform;
/// <summary>
private string[] domainNames;
private void OnEnable()
{
domain = serializedObject.FindProperty("domain");
trackedTransform = serializedObject.FindProperty("trackedTransform");
domainNames = CreatAssetWindow.GetCreatDomainAllName();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
// 获取当前选中的索引
int selectedIndex = System.Array.IndexOf(domainNames, domain.stringValue);
if (selectedIndex < 0) selectedIndex = 0; // 默认选中第一个
// 绘制下拉选择框
selectedIndex = EditorGUILayout.Popup("Domain", selectedIndex, domainNames);
// 更新选择的域名
domain.stringValue = domainNames[selectedIndex];
EditorGUI.BeginChangeCheck();
var newTrackedTransform
= EditorGUILayout.ObjectField(new GUIContent("Tracked Transform"), trackedTransform.objectReferenceValue, typeof(Transform), true) as Transform;
if (EditorGUI.EndChangeCheck())
{
trackedTransform.objectReferenceValue = newTrackedTransform;
}
serializedObject.ApplyModifiedProperties();
base.OnInspectorGUI();
}
}
#endif
}