更新至unity6并且更改Scriptable完成
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
using System.Collections;
|
||||
using Convention;
|
||||
using Demo.Editor.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public class SkyUpdatement : Updatement<string>, IAssetBundleLoader
|
||||
public class SkyUpdatement : Updatement<Material>, IAssetBundleLoader
|
||||
{
|
||||
public static SkyUpdatement Make()
|
||||
{
|
||||
@@ -13,33 +12,26 @@ namespace Demo.Game
|
||||
}
|
||||
|
||||
public string SkyAssetBundlePath;
|
||||
private IEnumerator SkyAssetBundleLoading;
|
||||
public AssetBundle SkyAssetBundle;
|
||||
|
||||
protected override string Lerp(string begin, string end, float t)
|
||||
protected override Material Lerp(Material begin, Material end, float t)
|
||||
{
|
||||
return begin;
|
||||
}
|
||||
|
||||
[Content, SerializeField] private string Cache;
|
||||
[Content, SerializeField] private Material Cache;
|
||||
|
||||
protected override void UpdateData(string data)
|
||||
protected override void UpdateData(Material data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(SkyAssetBundlePath))
|
||||
return;
|
||||
if (Cache != data)
|
||||
{
|
||||
RenderSettings.skybox = SkyAssetBundle.LoadAsset<Material>(data);
|
||||
RenderSettings.skybox = data;
|
||||
Cache = data;
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerator LoadScript(string script)
|
||||
{
|
||||
yield return base.LoadScript(script);
|
||||
yield return SkyAssetBundleLoading;
|
||||
}
|
||||
|
||||
public override IEnumerator UnloadScript()
|
||||
{
|
||||
Cache = null;
|
||||
@@ -69,20 +61,15 @@ namespace Demo.Game
|
||||
/// <param name="time"></param>
|
||||
/// <param name="sky"></param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(string time, string sky)
|
||||
public IEnumerator Add(float time, string sky)
|
||||
{
|
||||
ManualAddEntry(time, sky, default);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var ir = SkyAssetBundle.LoadAssetAsync<Material>(sky);
|
||||
ir.completed += delegate
|
||||
{
|
||||
var mat = ir.asset as Material;
|
||||
ManualAddEntry(time, mat, default);
|
||||
};
|
||||
yield return ir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user