using Convention; using Demo.Game.Attr; using System.Collections; using System.IO; using UnityEngine; using UnityEngine.Rendering; namespace Demo.Game { namespace ConfigType { // VolumeObject 配置 public class VolumeObjectConfig : BaseVolumeConfig { public string MyAssetBundle, MyProfile; public override void Deserialize(BinaryReader reader) { MyAssetBundle = BinarySerializeUtility.ReadString(reader); MyProfile = BinarySerializeUtility.ReadString(reader); base.Deserialize(reader); } public override void Serialize(BinaryWriter writer) { BinarySerializeUtility.WriteString(writer, MyAssetBundle); BinarySerializeUtility.WriteString(writer, MyProfile); base.Serialize(writer); } } } [Scriptable] public class VolumeObject : BaseVolume, IAssetBundleLoader { public static VolumeObject Make() { return new GameObject().AddComponent(); } private bool IsLoading = false; [Content, SerializeField] private string MyAssetBundle, MyProfile; protected override IEnumerator DoSomethingDuringApplyScript() { yield return base.DoSomethingDuringApplyScript(); yield return new WaitUntil(() => !IsLoading); if (MyVolume.profile == null) { MyVolume.profile = Resources.Load("Volume/Default"); } } [Convention.RScript.Variable.Attr.Method] public void Load(string ab, string profile) { IsLoading = true; MyAssetBundle = ab; MyProfile = profile; ConventionUtility.StartCoroutine(this.LoadAssetBundle(ab, x => { MyVolume.profile = x.LoadAsset(profile); IsLoading = false; })); } } }