【M】适配XReal art生成
This commit is contained in:
@@ -20,9 +20,20 @@ namespace Stary.Evo.Editor
|
|||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
[EnumToggleButtons, HideLabel] [OnValueChanged("SetUseTypeData")]
|
[BoxGroup("Selection")]
|
||||||
|
[EnumToggleButtons, HideLabel]
|
||||||
|
[OnValueChanged("SetUseTypeData")]
|
||||||
public UseType useType = UseType.Member;
|
public UseType useType = UseType.Member;
|
||||||
|
|
||||||
|
private static DeviceMode _DeviceMode = DeviceMode.Evo_Rokid;
|
||||||
|
[BoxGroup("Selection")]
|
||||||
|
[ShowInInspector, ShowIf("@useType == UseType.Art")]
|
||||||
|
public DeviceMode deviceMode
|
||||||
|
{
|
||||||
|
get => _DeviceMode;
|
||||||
|
set { _DeviceMode = value; }
|
||||||
|
}
|
||||||
|
|
||||||
private string _titleGroupName;
|
private string _titleGroupName;
|
||||||
|
|
||||||
[TitleGroup("@ _titleGroupName")] public string productName;
|
[TitleGroup("@ _titleGroupName")] public string productName;
|
||||||
@@ -104,11 +115,39 @@ namespace Stary.Evo.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 5. 载入并实例化 RKCameraRig.prefab */
|
/* 5. 载入并实例化 RKCameraRig.prefab */
|
||||||
string prefabPath = "Prefabs/BaseSetting/RKCameraRig";
|
|
||||||
|
|
||||||
var prefab = Resources.Load<GameObject>(prefabPath);
|
if (deviceMode == DeviceMode.Evo_Rokid)
|
||||||
var spawned = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
{
|
||||||
spawned.name = "RKCameraRigTest";
|
string prefabPath = "Prefabs/BaseSetting/RKCameraRig";
|
||||||
|
|
||||||
|
var prefab = Resources.Load<GameObject>(prefabPath);
|
||||||
|
var spawned = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||||
|
spawned.name = "RKCameraRigTest";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string prefabPath = "Prefabs/BaseSetting/RKCameraRig";
|
||||||
|
// 模糊搜索
|
||||||
|
GameObject prefab = LoadByFuzzy();
|
||||||
|
GameObject instance = null;
|
||||||
|
if (prefab != null)
|
||||||
|
{
|
||||||
|
instance = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||||
|
instance.transform.position = Vector3.zero;
|
||||||
|
Debug.Log($"✅ 已加载: {prefab.name}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError($"无法加载 Prefab: {prefabPath}\n请检查路径是否正确,或 XR Interaction Toolkit 样本是否已导入。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选中并聚焦
|
||||||
|
// Selection.activeGameObject = instance;
|
||||||
|
// EditorGUIUtility.PingObject(instance);
|
||||||
|
if (instance) Debug.Log($"成功加载: {instance.name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 6. 保存场景 */
|
/* 6. 保存场景 */
|
||||||
string scenePath = Path.Combine("Assets/Art", productName, "Scenes", "TestScene.unity");
|
string scenePath = Path.Combine("Assets/Art", productName, "Scenes", "TestScene.unity");
|
||||||
@@ -120,6 +159,32 @@ namespace Stary.Evo.Editor
|
|||||||
artList.Add(creatArtDomainEntity);
|
artList.Add(creatArtDomainEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameObject LoadByFuzzy()
|
||||||
|
{
|
||||||
|
// 通过文件名模糊搜索,完全无视路径
|
||||||
|
var guids = AssetDatabase.FindAssets("XR Origin (XR Rig) t:Prefab");
|
||||||
|
|
||||||
|
if (guids.Length == 0)
|
||||||
|
{
|
||||||
|
Debug.LogError("未找到 XR Origin (XR Rig) Prefab");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果找到多个,优先选择 XR Interaction Toolkit 路径下的
|
||||||
|
foreach (var guid in guids)
|
||||||
|
{
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||||
|
if (path.Contains("XR Interaction Toolkit"))
|
||||||
|
{
|
||||||
|
return AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认返回第一个
|
||||||
|
return AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GUIDToAssetPath(guids[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建成员目录
|
/// 创建成员目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -438,5 +503,13 @@ namespace Stary.Evo.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Art
|
Art
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum DeviceMode
|
||||||
|
{
|
||||||
|
//Xreal,
|
||||||
|
Evo_Xreal,
|
||||||
|
//Rokid,
|
||||||
|
Evo_Rokid,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.buildoriginality",
|
"name": "com.staryevo.buildoriginality",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"displayName": "00.StaryEvo.BuildOriginality",
|
"displayName": "00.StaryEvo.BuildOriginality",
|
||||||
"description": "美术打包工具",
|
"description": "美术打包工具",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user