Files
plugin-library/Assets/00.StaryEvo/Runtime/PlayerSettings/ArtSceneData.cs
2025-11-05 11:36:35 +08:00

58 lines
1.9 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 System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo
{
[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
{
[LabelText("场景名称")] public string sceneName;
#if UNITY_EDITOR
[LabelText("场景实例")] [OnValueChanged("LoadScenePath")]
public SceneAsset sceneAsset;
#endif
[LabelText("场景路径")] [ReadOnly] public string scenePath;
[LabelText("场景标识符")] [ReadOnly] public string sceneIdentifier;
#if UNITY_EDITOR
public void LoadScenePath()
{
if (sceneAsset == null)
{
Debug.LogError($"ArtScene {sceneName} 资源不存在,请检查!");
return;
}
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;
}
scenePath = AssetDatabase.GetAssetPath(sceneAsset);
sceneIdentifier = $"Scenes_{sceneAsset.name}";
AssetDatabase.SaveAssets();
}
#endif
}
}