【m】优化卸载加载逻辑
This commit is contained in:
@@ -26,22 +26,30 @@ namespace Stary.Evo
|
||||
/// </summary>
|
||||
[Sirenix.OdinInspector.ReadOnly] public string className;
|
||||
|
||||
[InfoBox( "Prefab(仅加载预制体) Scene(加载场景)")]
|
||||
[OnValueChanged("SetLoadResType")]
|
||||
public LoadResType loadResType;
|
||||
|
||||
|
||||
[Sirenix.OdinInspector.ReadOnly] [ShowIf("loadResType", LoadResType.Prefab)]
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
[ShowIf("loadResType", LoadResType.Scene)] [OnValueChanged("LoadScenePath")]
|
||||
[ValidateInput("ValidateScenePath", "只能使用 本Domain 目录下的场景!", InfoMessageType.Error)]
|
||||
public SceneAsset sceneAsset;
|
||||
#endif
|
||||
[InfoBox( "Static(持久化存在,不可手动卸载) Additive(叠加,可手动卸载) Single(下一个加载自动卸载) ")]
|
||||
[ShowIf("loadResType", LoadResType.Prefab)]
|
||||
public DomainLoadType domainLoadType;
|
||||
|
||||
[ShowIf("loadResType", LoadResType.Scene)]
|
||||
public LoadSceneMode loadSceneMode;
|
||||
/// <summary>
|
||||
/// 入口预制体
|
||||
/// </summary>
|
||||
[Sirenix.OdinInspector.ReadOnly] [ShowIf("loadResType", LoadResType.Prefab)]
|
||||
public string mainPrefab;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[ShowIf("loadResType", LoadResType.Scene)] [OnValueChanged("LoadScenePath")]
|
||||
public SceneAsset sceneAsset;
|
||||
#endif
|
||||
[ShowIf("loadResType", LoadResType.Scene)]
|
||||
public LoadSceneMode loadSceneMode;
|
||||
|
||||
[ShowIf("loadResType", LoadResType.Scene)] [ReadOnly]
|
||||
public string scenePath;
|
||||
|
||||
@@ -61,11 +69,43 @@ namespace Stary.Evo
|
||||
scenePath = AssetDatabase.GetAssetPath(sceneAsset);
|
||||
sceneIdentifier = $"Scenes_{sceneAsset.name}";
|
||||
}
|
||||
private bool ValidateScenePath(SceneAsset scene)
|
||||
{
|
||||
if (scene == null) return true;
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(scene);
|
||||
return path.StartsWith($"Assets/Domain/{domain}/AddressableRes/Scenes/");
|
||||
}
|
||||
#endif
|
||||
private void SetLoadResType()
|
||||
{
|
||||
if (loadResType == LoadResType.Prefab)
|
||||
{
|
||||
sceneAsset = null;
|
||||
scenePath = null;
|
||||
sceneIdentifier = null;
|
||||
}
|
||||
}
|
||||
public enum LoadResType
|
||||
{
|
||||
Prefab,
|
||||
Scene
|
||||
}
|
||||
|
||||
public enum DomainLoadType
|
||||
{
|
||||
/// <summary>
|
||||
/// 下一个加载自动卸载
|
||||
/// </summary>
|
||||
Single,
|
||||
/// <summary>
|
||||
/// 叠加,可手动卸载
|
||||
/// </summary>
|
||||
Additive,
|
||||
/// <summary>
|
||||
/// 持久化存在,不可手动卸载
|
||||
/// </summary>
|
||||
Static
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user