【m】图像识别添加

This commit is contained in:
2025-05-19 16:14:25 +08:00
parent 53902896c0
commit b8c67a2cd6
9 changed files with 127 additions and 2 deletions

View File

@@ -0,0 +1,52 @@
using Stary.Evo.Editor;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.RKTools
{
[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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 72092625ebc64a538340f91e8ddedfc3
timeCreated: 1747641457

View File

@@ -0,0 +1,17 @@
{
"name": "RKTools.Editor",
"rootNamespace": "",
"references": [
"GUID:10c9b58b77ad42b4193e2a393b1a9899",
"GUID:044184040b21c434b8aee6f2a3424c06"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7b267fe3452f4939bf6a21810fbeab2b
timeCreated: 1747641687