Files
Convention-Unity-Demo/Assets/Scripts/Volume/VolumeObject.cs
2025-12-12 15:54:16 +08:00

40 lines
1.1 KiB
C#

using Convention;
using Demo.Attr;
using System.Collections;
using UnityEngine;
using UnityEngine.Rendering;
namespace Demo.Game
{
[Scriptable]
public class VolumeObject : BaseVolume, IAssetBundleLoader
{
public static VolumeObject Make()
{
return new GameObject().AddComponent<VolumeObject>();
}
[Content, SerializeField] private bool IsLoading = false;
protected override IEnumerator DoSomethingDuringApplyScript()
{
yield return base.DoSomethingDuringApplyScript();
yield return new WaitUntil(() => !IsLoading);
if (MyVolume.profile == null)
{
MyVolume.profile = Resources.Load<VolumeProfile>("Volume/Default");
}
}
[Convention.RScript.Variable.Attr.Method]
public void Load(string ab, string profile)
{
IsLoading = true;
ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x =>
{
MyVolume.profile = x.LoadAsset<VolumeProfile>(profile);
IsLoading = false;
}));
}
}
}