2025-09-25 19:04:05 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using Convention;
|
|
|
|
|
|
using Demo.Editor.UI;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Demo.Game
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SkyUpdatement : Updatement<string>, IAssetBundleLoader
|
|
|
|
|
|
{
|
|
|
|
|
|
public static SkyUpdatement Make()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new GameObject().AddComponent<SkyUpdatement>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string SkyAssetBundlePath;
|
|
|
|
|
|
private IEnumerator SkyAssetBundleLoading;
|
|
|
|
|
|
public AssetBundle SkyAssetBundle;
|
|
|
|
|
|
|
|
|
|
|
|
protected override string Lerp(string begin, string end, float t)
|
|
|
|
|
|
{
|
|
|
|
|
|
return begin;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Content, SerializeField] private string Cache;
|
|
|
|
|
|
|
|
|
|
|
|
protected override void UpdateData(string data)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(SkyAssetBundlePath))
|
|
|
|
|
|
return;
|
|
|
|
|
|
if (Cache != data)
|
|
|
|
|
|
{
|
|
|
|
|
|
RenderSettings.skybox = SkyAssetBundle.LoadAsset<Material>(data);
|
|
|
|
|
|
Cache = data;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override IEnumerator LoadScript(string script)
|
|
|
|
|
|
{
|
|
|
|
|
|
yield return base.LoadScript(script);
|
|
|
|
|
|
yield return SkyAssetBundleLoading;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override IEnumerator UnloadScript()
|
|
|
|
|
|
{
|
|
|
|
|
|
Cache = null;
|
|
|
|
|
|
if (string.IsNullOrEmpty(SkyAssetBundlePath) == false)
|
|
|
|
|
|
yield return this.UnloadAssetBundle(SkyAssetBundlePath);
|
|
|
|
|
|
SkyAssetBundlePath = "";
|
|
|
|
|
|
yield return base.UnloadScript();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 对应ab包名称,自动匹配对应平台
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ab"></param>
|
2025-10-27 20:24:15 +08:00
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
2025-10-06 16:09:52 +08:00
|
|
|
|
public IEnumerator Load(string ab)
|
2025-09-25 19:04:05 +08:00
|
|
|
|
{
|
2025-10-06 16:09:52 +08:00
|
|
|
|
yield return this.LoadAssetBundle(ab, x =>
|
2025-09-25 19:04:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
SkyAssetBundlePath = ab;
|
|
|
|
|
|
SkyAssetBundle = x;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在指定时刻切换天空
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="time"></param>
|
|
|
|
|
|
/// <param name="sky"></param>
|
2025-10-27 20:24:15 +08:00
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
2025-09-25 19:04:05 +08:00
|
|
|
|
public void Add(string time, string sky)
|
|
|
|
|
|
{
|
|
|
|
|
|
ManualAddEntry(time, sky, default);
|
|
|
|
|
|
}
|
2025-11-12 10:18:50 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在指定时刻切换天空
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="time"></param>
|
|
|
|
|
|
/// <param name="sky"></param>
|
|
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
|
|
|
|
public void Add(float time, string sky)
|
|
|
|
|
|
{
|
|
|
|
|
|
ManualAddEntry(time, sky, default);
|
|
|
|
|
|
}
|
2025-09-25 19:04:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|