2025-10-24 19:08:10 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2025-10-31 11:18:23 +08:00
|
|
|
|
namespace Stary.Evo
|
2025-10-24 19:08:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
[CreateAssetMenu(fileName = "ArtSceneData", menuName = "Evo/ArtSceneData")]
|
|
|
|
|
|
public class ArtSceneData : ScriptableObject
|
|
|
|
|
|
{
|
|
|
|
|
|
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false)]
|
|
|
|
|
|
public List<ArtScene> artScenes = new List<ArtScene>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public class ArtScene
|
|
|
|
|
|
{
|
2025-10-31 11:18:23 +08:00
|
|
|
|
[LabelText("场景名称")] public string sceneName;
|
|
|
|
|
|
|
2025-10-31 12:27:49 +08:00
|
|
|
|
#if UNITY_EDITOR
|
2025-10-31 11:18:23 +08:00
|
|
|
|
[LabelText("场景实例")] [OnValueChanged("LoadScenePath")]
|
2025-10-24 19:08:10 +08:00
|
|
|
|
public SceneAsset sceneAsset;
|
2025-10-31 12:27:49 +08:00
|
|
|
|
#endif
|
2025-10-31 11:18:23 +08:00
|
|
|
|
[LabelText("场景路径")] [ReadOnly] public string scenePath;
|
|
|
|
|
|
[LabelText("场景标识符")] [ReadOnly] public string sceneIdentifier;
|
|
|
|
|
|
#if UNITY_EDITOR
|
2025-10-24 19:08:10 +08:00
|
|
|
|
public void LoadScenePath()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sceneAsset == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"ArtScene {sceneName} 资源不存在,请检查!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-10-31 11:18:23 +08:00
|
|
|
|
|
2025-11-05 11:36:35 +08:00
|
|
|
|
string assetPath = AssetDatabase.GetAssetPath(sceneAsset);
|
|
|
|
|
|
|
|
|
|
|
|
// 验证路径是否在Assets/Art目录下
|
|
|
|
|
|
if (!assetPath.StartsWith("Assets/Art/"))
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"场景必须位于Assets/Art目录下,当前路径: {assetPath}");
|
|
|
|
|
|
EditorUtility.DisplayDialog("提示", "场景必须位于Assets/Art目录下,才可配置!", "确定");
|
|
|
|
|
|
|
|
|
|
|
|
// 可以选择自动清空无效的场景引用
|
|
|
|
|
|
sceneAsset = null;
|
|
|
|
|
|
scenePath = "";
|
|
|
|
|
|
sceneIdentifier = "";
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 19:08:10 +08:00
|
|
|
|
scenePath = AssetDatabase.GetAssetPath(sceneAsset);
|
2025-10-31 11:18:23 +08:00
|
|
|
|
sceneIdentifier = $"Scenes_{sceneAsset.name}";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AssetDatabase.SaveAssets();
|
2025-10-24 19:08:10 +08:00
|
|
|
|
}
|
2025-10-31 11:18:23 +08:00
|
|
|
|
#endif
|
2025-10-24 19:08:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|