1.调整目录结构, 拆分ab包内容2.开始新增volume物体
This commit is contained in:
@@ -74,6 +74,11 @@ namespace Demo
|
||||
{ $"{nameof(ParticleJudgement)}",ParticleJudgement.Make},
|
||||
};
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> SingleVolumeInstantiate = new()
|
||||
{
|
||||
{ $"{nameof(MotionBlurVolume)}", MotionBlurVolume.Make }
|
||||
};
|
||||
|
||||
public static void OpenInstantiateMenu(this ScriptableObject self, RectTransform item)
|
||||
{
|
||||
List<SharedModule.CallbackData> result = new()
|
||||
@@ -90,14 +95,17 @@ namespace Demo
|
||||
SharedModule.instance.OpenCustomMenu(item, result.ToArray());
|
||||
}
|
||||
|
||||
private static Dictionary<string, Func<ScriptableObject>> s_ScriptableObjectInstantiate;
|
||||
|
||||
public static Dictionary<string, Func<ScriptableObject>> GetScriptableObjectInstantiate()
|
||||
{
|
||||
return new Dictionary<string, Func<ScriptableObject>>(GameObjectInstantiate
|
||||
return s_ScriptableObjectInstantiate ??= new Dictionary<string, Func<ScriptableObject>>(GameObjectInstantiate
|
||||
.Union(DDTInstantiate)
|
||||
.Union(TickUpdatementInstantiate)
|
||||
.Union(MaterialUpdatementInstantiate)
|
||||
.Union(SplineInstantiate)
|
||||
.Union(JudgementInstantiate));
|
||||
.Union(JudgementInstantiate)
|
||||
.Union(SingleVolumeInstantiate));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
8
Assets/Scripts/Volume.meta
Normal file
8
Assets/Scripts/Volume.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7ca6b10736f6784fb939efe89aca8f6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
78
Assets/Scripts/Volume/BaseVolume.cs
Normal file
78
Assets/Scripts/Volume/BaseVolume.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Convention;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public abstract class BaseVolume : ScriptableObject
|
||||
{
|
||||
[Resources, SerializeField] private Volume m_volume;
|
||||
protected Volume MyVolume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_volume == null)
|
||||
m_volume = this.GetOrAddComponent<Volume>();
|
||||
return m_volume;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, Type> VolumeOverrideTypes = new()
|
||||
{
|
||||
{ nameof(MotionBlur), typeof(MotionBlur)}
|
||||
};
|
||||
|
||||
public bool HasOverride<T>() where T : VolumeComponent
|
||||
{
|
||||
return MyVolume.profile.Has<T>();
|
||||
}
|
||||
|
||||
public bool HasOverride(string name)
|
||||
{
|
||||
if (VolumeOverrideTypes.TryGetValue(name, out var type))
|
||||
return MyVolume.profile.Has(type);
|
||||
return false;
|
||||
}
|
||||
|
||||
public T GetOverride<T>() where T : VolumeComponent
|
||||
{
|
||||
if (MyVolume.profile.TryGet<T>(out var result))
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
public VolumeComponent GetOverride(string name)
|
||||
{
|
||||
if (VolumeOverrideTypes.TryGetValue(name, out var type))
|
||||
if (MyVolume.profile.TryGet<VolumeComponent>(type, out var result))
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool TrySetOverrideField<T, FieldType>(string name, FieldType value) where T : VolumeComponent
|
||||
{
|
||||
var component = GetOverride<T>();
|
||||
if (component == null)
|
||||
return false;
|
||||
return ConventionUtility.PushValue(component, value, name, BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class BaseForSingleVolume<T> : BaseVolume where T : VolumeComponent
|
||||
{
|
||||
private T m_TargetOverride;
|
||||
public T TargetOverride
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_TargetOverride == null)
|
||||
m_TargetOverride = GetOverride<T>();
|
||||
return TargetOverride;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Volume/BaseVolume.cs.meta
Normal file
2
Assets/Scripts/Volume/BaseVolume.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 690e6449e63422241b10a6cf1d72cdd1
|
||||
47
Assets/Scripts/Volume/MotionBlurVolume.cs
Normal file
47
Assets/Scripts/Volume/MotionBlurVolume.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace Demo.Game
|
||||
{
|
||||
public class MotionBlurVolume : BaseForSingleVolume<MotionBlur>
|
||||
{
|
||||
public static MotionBlurVolume Make()
|
||||
{
|
||||
return new GameObject().AddComponent<MotionBlurVolume>();
|
||||
}
|
||||
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetLowMotionBlurQuality()
|
||||
{
|
||||
TargetOverride.quality.value = MotionBlurQuality.Low;
|
||||
}
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetMediumMotionBlurQuality()
|
||||
{
|
||||
TargetOverride.quality.value = MotionBlurQuality.Medium;
|
||||
}
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetHighMotionBlurQuality()
|
||||
{
|
||||
TargetOverride.quality.value = MotionBlurQuality.High;
|
||||
}
|
||||
/// <summary>
|
||||
/// Use this if you need object motion blur.
|
||||
/// </summary>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void EnableObjectsMotionBlur()
|
||||
{
|
||||
TargetOverride.mode.value = MotionBlurMode.CameraAndObjects;
|
||||
}
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetIntensity(float value)
|
||||
{
|
||||
TargetOverride.intensity.value = value;
|
||||
}
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public void SetClamp(float value)
|
||||
{
|
||||
TargetOverride.clamp.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Volume/MotionBlurVolume.cs.meta
Normal file
2
Assets/Scripts/Volume/MotionBlurVolume.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 420cec8bd1a2bc14ba438908b4c86740
|
||||
Reference in New Issue
Block a user