新增volume更新器
This commit is contained in:
@@ -60,6 +60,14 @@ namespace Demo.Game
|
||||
return false;
|
||||
return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
public bool TrySetOverrideField<FieldType>(string type, string name, FieldType value)
|
||||
{
|
||||
var component = GetOverride(type);
|
||||
if (component == null)
|
||||
return false;
|
||||
return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseForSingleVolume<T> : BaseVolume where T : VolumeComponent
|
||||
|
||||
8
Assets/Scripts/Volume/Updatement.meta
Normal file
8
Assets/Scripts/Volume/Updatement.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6817d5ed5f3f2ba46b718a0003027dee
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Scripts/Volume/Updatement/BaseVolumeUpdatement.cs
Normal file
48
Assets/Scripts/Volume/Updatement/BaseVolumeUpdatement.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Convention;
|
||||
using Demo.Attr;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public abstract class BaseVolumeUpdatement<T> : Updatement<T> where T : unmanaged
|
||||
{
|
||||
[Content, SerializeField] private BaseVolume target;
|
||||
[Content, SerializeField] private string updateOverride;
|
||||
[Content, SerializeField] private string updateField;
|
||||
|
||||
protected override IEnumerator DoSomethingDuringApplyScript()
|
||||
{
|
||||
yield return base.DoSomethingDuringApplyScript();
|
||||
if (target == null)
|
||||
{
|
||||
target = this.UpdateTarget.SeekComponent<BaseVolume>();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateData(T data)
|
||||
{
|
||||
target.TrySetOverrideField<T>(updateOverride, updateField, data);
|
||||
}
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetUpdateOverrideAndField(string updateOverride, string updateField)
|
||||
{
|
||||
this.updateOverride = updateOverride;
|
||||
this.updateField = updateField;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <param name="time">插值时间</param>
|
||||
/// <param name="value">值</param>
|
||||
/// <param name="curveType">缓动曲线</param>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void Add(float time, T value, MathExtension.EaseCurveType curveType)
|
||||
{
|
||||
ManualAddEntry(time, value, curveType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3310713d1026b944facb4c172ad38bb1
|
||||
21
Assets/Scripts/Volume/Updatement/VolumeFloatUpdatement.cs
Normal file
21
Assets/Scripts/Volume/Updatement/VolumeFloatUpdatement.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Convention;
|
||||
using Demo.Attr;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class VolumeFloatUpdatement : BaseVolumeUpdatement<float>
|
||||
{
|
||||
public static VolumeFloatUpdatement Make()
|
||||
{
|
||||
return new GameObject().AddComponent<VolumeFloatUpdatement>();
|
||||
}
|
||||
|
||||
protected override float Lerp(float begin, float end, float t)
|
||||
{
|
||||
return Mathf.Lerp(begin, end, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b3813d5ec8404345bcbd745281e2671
|
||||
19
Assets/Scripts/Volume/Updatement/VolumeIntUpdatement.cs
Normal file
19
Assets/Scripts/Volume/Updatement/VolumeIntUpdatement.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Demo.Attr;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
[Scriptable]
|
||||
public class VolumeIntUpdatement : BaseVolumeUpdatement<int>
|
||||
{
|
||||
public static VolumeIntUpdatement Make()
|
||||
{
|
||||
return new GameObject().AddComponent<VolumeIntUpdatement>();
|
||||
}
|
||||
|
||||
protected override int Lerp(int begin, int end, float t)
|
||||
{
|
||||
return Mathf.FloorToInt(Mathf.Lerp(begin, end, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 600cb8d3ed5900d4baa30e5d8aafa66e
|
||||
40
Assets/Scripts/Volume/VolumeObject.cs
Normal file
40
Assets/Scripts/Volume/VolumeObject.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Volume/VolumeObject.cs.meta
Normal file
2
Assets/Scripts/Volume/VolumeObject.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6905b41c61f830c4fac86087660118e4
|
||||
Reference in New Issue
Block a user