新增volume更新器
This commit is contained in:
@@ -75,8 +75,8 @@ MonoBehaviour:
|
||||
m_OverrideState: 0
|
||||
m_Value: 65472
|
||||
tint:
|
||||
m_OverrideState: 0
|
||||
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_OverrideState: 1
|
||||
m_Value: {r: 0, g: 0, b: 0, a: 1}
|
||||
highQualityFiltering:
|
||||
m_OverrideState: 0
|
||||
m_Value: 0
|
||||
@@ -261,7 +261,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c01700fd266d6914ababb731e09af2eb, type: 3}
|
||||
m_Name: DepthOfField
|
||||
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.DepthOfField
|
||||
active: 1
|
||||
active: 0
|
||||
mode:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
|
||||
@@ -616,7 +616,8 @@ PrefabInstance:
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_RemovedGameObjects:
|
||||
- {fileID: 8780852774427548101, guid: c659abfe74df5de47a769f8d52c18fcc, type: 3}
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: c659abfe74df5de47a769f8d52c18fcc, type: 3}
|
||||
|
||||
@@ -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
|
||||
@@ -422,7 +422,7 @@ MonoBehaviour:
|
||||
- line: '| - m_BuildTarget: '
|
||||
- line: '| m_Icons:'
|
||||
- line: '| - serializedVersion: 2'
|
||||
- line: '| m_Icon: {fileID: 2800000, guid: 8a1e37e4b2571444b95d20abbea33454,
|
||||
- line: '| m_Icon: {fileID: 2800000, guid: e7fd089a9ebf1be4589638221dc0a006,
|
||||
type: 3}'
|
||||
- line: '| m_Width: 128'
|
||||
- line: '| m_Height: 128'
|
||||
|
||||
Reference in New Issue
Block a user