特效自定义曲线
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 自定义曲线预设
|
||||
/// </summary>
|
||||
public static class CustomCurvePresets
|
||||
{
|
||||
/// <summary>
|
||||
/// 抛物线曲线,在中间达到最大值,两端为起始值
|
||||
/// </summary>
|
||||
/// <param name="totalTime">总时间</param>
|
||||
/// <param name="startValue">起始(和结束)值</param>
|
||||
/// <param name="peakValue">中点最大值</param>
|
||||
public static AnimationCurve Parabolic(float totalTime, float startValue, float peakValue)
|
||||
{
|
||||
Keyframe[] keys = new Keyframe[3];
|
||||
keys[0] = new Keyframe(0, startValue, 0, 0);
|
||||
keys[1] = new Keyframe(totalTime / 2, peakValue, 0, 0);
|
||||
keys[2] = new Keyframe(totalTime, startValue, 0, 0);
|
||||
return new AnimationCurve(keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac4cc158ed88d48af9a350196b874508
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -104,10 +104,10 @@ namespace Ichni.RhythmGame
|
||||
private static Dictionary<string, EffectBase> EffectCollection { get; } =
|
||||
new Dictionary<string, EffectBase>()
|
||||
{
|
||||
{ "Bloom", new BloomEffect(1, 2) },
|
||||
{ "Bloom", new BloomEffect(1, 2, CustomCurvePresets.Parabolic(1,0,2)) },
|
||||
{ "CameraShake", new CameraShakeEffect(1, 50, 1, 1, 1) },
|
||||
{ "ChromaticAberration", new ChromaticAberrationEffect(1, 1) },
|
||||
{ "Vignette", new VignetteEffect(1, 1, 0.4f, Color.black) }
|
||||
{ "ChromaticAberration", new ChromaticAberrationEffect(1, 1, CustomCurvePresets.Parabolic(1,0,1)) },
|
||||
{ "Vignette", new VignetteEffect(1, 1, 0.4f, Color.black, CustomCurvePresets.Parabolic(1,0,1)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Lean.Pool;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.FeedbacksForThirdParty;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
@@ -14,26 +15,29 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public float duration;
|
||||
public float peak;
|
||||
|
||||
public BloomEffect(float duration, float peak)
|
||||
public AnimationCurve intensityCurve;
|
||||
|
||||
public BloomEffect(float duration, float peak, AnimationCurve intensityCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peak = peak;
|
||||
this.intensityCurve = intensityCurve;
|
||||
}
|
||||
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
MMF_Player effect = LeanPool.Spawn(EditorManager.instance.basePrefabs.bloomEffect).GetComponent<MMF_Player>();
|
||||
effect.GetFeedbackOfType<MMF_Bloom_URP>().ShakeDuration = duration;
|
||||
effect.GetFeedbackOfType<MMF_Bloom_URP>().RemapIntensityOne = peak;
|
||||
effect.GetFeedbackOfType<MMF_Bloom_URP>().ShakeIntensity = intensityCurve;
|
||||
effect.PlayFeedbacks();
|
||||
LeanPool.Despawn(effect.gameObject, duration);
|
||||
}
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new BloomEffect_BM(duration, peak);
|
||||
return new BloomEffect_BM(duration, peak, intensityCurve);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
@@ -42,6 +46,11 @@ namespace Ichni.RhythmGame
|
||||
var container = inspector.GenerateContainer("Bloom Shake");
|
||||
var effectTimeField = inspector.GenerateInputField(this, container, "Bloom Time", nameof(duration));
|
||||
var bloomPeakField = inspector.GenerateInputField(this, container, "Bloom Peak", nameof(peak));
|
||||
var intensityCurveButton = inspector.GenerateButton(this, container, "Intensity Curve", () =>
|
||||
{
|
||||
var intensityCurveWindow = inspector.GenerateCompositeParameterWindow(this, "Intensity Curve", nameof(intensityCurve));
|
||||
intensityCurveWindow.SetAsCustomCurve();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,22 +60,24 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public float duration;
|
||||
public float peak;
|
||||
public AnimationCurve intensityCurve;
|
||||
|
||||
public BloomEffect_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BloomEffect_BM(float duration, float peak)
|
||||
public BloomEffect_BM(float duration, float peak, AnimationCurve intensityCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peak = peak;
|
||||
this.intensityCurve = intensityCurve;
|
||||
}
|
||||
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new BloomEffect(duration, peak);
|
||||
return new BloomEffect(duration, peak, intensityCurve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,19 +13,22 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public float duration;
|
||||
public float peak;
|
||||
public AnimationCurve intensityCurve;
|
||||
|
||||
public ChromaticAberrationEffect(float duration, float peak)
|
||||
public ChromaticAberrationEffect(float duration, float peak, AnimationCurve intensityCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peak = peak;
|
||||
this.intensityCurve = intensityCurve;
|
||||
}
|
||||
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
MMF_Player effect = LeanPool.Spawn(EditorManager.instance.basePrefabs.chromaticAberrationEffect).GetComponent<MMF_Player>();
|
||||
effect.GetFeedbackOfType<MMF_ChromaticAberration_URP>().Duration = duration;
|
||||
effect.GetFeedbackOfType<MMF_ChromaticAberration_URP>().RemapIntensityOne = peak;
|
||||
effect.GetFeedbackOfType<MMF_ChromaticAberration_URP>().Intensity = intensityCurve;
|
||||
effect.PlayFeedbacks();
|
||||
LeanPool.Despawn(effect.gameObject, duration);
|
||||
}
|
||||
@@ -41,6 +44,11 @@ namespace Ichni.RhythmGame
|
||||
var container = inspector.GenerateContainer("Chromatic Aberration");
|
||||
var effectTimeField = inspector.GenerateInputField(this, container, "Duration", nameof(duration));
|
||||
var bloomPeakField = inspector.GenerateInputField(this, container, "Peak Value", nameof(peak));
|
||||
var intensityCurveButton = inspector.GenerateButton(this, container, "Intensity Curve", () =>
|
||||
{
|
||||
var intensityCurveWindow = inspector.GenerateCompositeParameterWindow(this, "Intensity Curve", nameof(intensityCurve));
|
||||
intensityCurveWindow.SetAsCustomCurve();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +58,8 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public float duration;
|
||||
public float peak;
|
||||
|
||||
public AnimationCurve intensityCurve;
|
||||
|
||||
public ChromaticAberrationEffect_BM()
|
||||
{
|
||||
|
||||
@@ -65,7 +74,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new ChromaticAberrationEffect(duration, peak);
|
||||
return new ChromaticAberrationEffect(duration, peak, intensityCurve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,21 +15,24 @@ namespace Ichni.RhythmGame
|
||||
public float peak;
|
||||
public float smoothness;
|
||||
public Color color;
|
||||
public AnimationCurve intensityCurve;
|
||||
|
||||
public VignetteEffect(float duration, float peak, float smoothness, Color color)
|
||||
public VignetteEffect(float duration, float peak, float smoothness, Color color, AnimationCurve intensityCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peak = peak;
|
||||
this.smoothness = smoothness;
|
||||
this.color = color;
|
||||
this.intensityCurve = intensityCurve;
|
||||
}
|
||||
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
MMF_Player effect = Lean.Pool.LeanPool.Spawn(EditorManager.instance.basePrefabs.vignetteEffect).GetComponent<MMF_Player>();
|
||||
effect.GetFeedbackOfType<MMF_Vignette_URP>().Duration = duration;
|
||||
effect.GetFeedbackOfType<MMF_Vignette_URP>().RemapIntensityOne = peak;
|
||||
effect.GetFeedbackOfType<MMF_Vignette_URP>().Intensity = intensityCurve;
|
||||
if (EditorManager.instance.postProcessingManager.globalVolume.profile.TryGet(out Vignette vignette))
|
||||
{
|
||||
vignette.smoothness.value = smoothness;
|
||||
@@ -41,7 +44,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new VignetteEffect_BM(duration, peak, smoothness, color);
|
||||
return new VignetteEffect_BM(duration, peak, smoothness, color, intensityCurve);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
@@ -52,6 +55,11 @@ namespace Ichni.RhythmGame
|
||||
var peakField = inspector.GenerateInputField(this, container, "Peak Value", nameof(peak));
|
||||
var smoothnessField = inspector.GenerateInputField(this, container, "Smoothness", nameof(smoothness));
|
||||
var colorField = inspector.GenerateBaseColorPicker(this, container, "Color", nameof(color));
|
||||
var intensityCurveButton = inspector.GenerateButton(this, container, "Intensity Curve", () =>
|
||||
{
|
||||
var intensityCurveWindow = inspector.GenerateCompositeParameterWindow(this, "Intensity Curve", nameof(intensityCurve));
|
||||
intensityCurveWindow.SetAsCustomCurve();
|
||||
});
|
||||
container.SetDeviver(1);
|
||||
}
|
||||
}
|
||||
@@ -64,23 +72,26 @@ namespace Ichni.RhythmGame
|
||||
public float peak;
|
||||
public float smoothness;
|
||||
public Color color;
|
||||
public AnimationCurve intensityCurve;
|
||||
|
||||
public VignetteEffect_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public VignetteEffect_BM(float duration, float peak, float smoothness, Color color)
|
||||
public VignetteEffect_BM(float duration, float peak, float smoothness, Color color, AnimationCurve intensityCurve)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.duration = duration;
|
||||
this.peak = peak;
|
||||
this.smoothness = smoothness;
|
||||
this.color = color;
|
||||
this.intensityCurve = intensityCurve;
|
||||
}
|
||||
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new VignetteEffect(duration, peak, smoothness, color);
|
||||
return new VignetteEffect(duration, peak, smoothness, color, intensityCurve);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user