爆修
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
{
|
||||
@@ -8,8 +9,16 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
public class DTMGlobalFog_BM : EnvironmentObject_BM
|
||||
{
|
||||
public float fogIntensity = 1f;
|
||||
public float fogColorStartR = 0.5f, fogColorStartG = 0.75f, fogColorStartB = 1.0f, fogColorStartA = 1.0f;
|
||||
public float fogColorEndR = 0.75f, fogColorEndG = 1.0f, fogColorEndB = 1.25f, fogColorEndA = 1.0f;
|
||||
|
||||
// 新字段(新存档使用)
|
||||
public Color fogColorStart = new Color(0.5f, 0.75f, 1f, 1f);
|
||||
public Color fogColorEnd = new Color(0.75f, 1f, 1.25f, 1f);
|
||||
public float fogColorStartIntensity = 0f;
|
||||
public float fogColorEndIntensity = 0f;
|
||||
|
||||
// 旧字段(保留以兼容旧存档 JSON 反序列化)
|
||||
public float fogColorStartR = -1f, fogColorStartG = -1f, fogColorStartB = -1f, fogColorStartA = -1f;
|
||||
public float fogColorEndR = -1f, fogColorEndG = -1f, fogColorEndB = -1f, fogColorEndA = -1f;
|
||||
public float fogColorDuo = 0f;
|
||||
|
||||
public float skyboxFogIntensity = 1f;
|
||||
@@ -26,8 +35,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
public DTMGlobalFog_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
string themeBundleName, string objectName, bool isStatic,
|
||||
float fogIntensity,
|
||||
float fogColorStartR, float fogColorStartG, float fogColorStartB, float fogColorStartA,
|
||||
float fogColorEndR, float fogColorEndG, float fogColorEndB, float fogColorEndA,
|
||||
Color fogColorStart, Color fogColorEnd,
|
||||
float fogColorStartIntensity, float fogColorEndIntensity,
|
||||
float fogColorDuo,
|
||||
float skyboxFogIntensity, float skyboxFogHeight,
|
||||
float skyboxFogFalloff, float skyboxFogOffset,
|
||||
@@ -35,8 +44,10 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
: base(elementName, elementGuid, tags, attachedElement, themeBundleName, objectName, isStatic)
|
||||
{
|
||||
this.fogIntensity = fogIntensity;
|
||||
this.fogColorStartR = fogColorStartR; this.fogColorStartG = fogColorStartG; this.fogColorStartB = fogColorStartB; this.fogColorStartA = fogColorStartA;
|
||||
this.fogColorEndR = fogColorEndR; this.fogColorEndG = fogColorEndG; this.fogColorEndB = fogColorEndB; this.fogColorEndA = fogColorEndA;
|
||||
this.fogColorStart = fogColorStart;
|
||||
this.fogColorEnd = fogColorEnd;
|
||||
this.fogColorStartIntensity = fogColorStartIntensity;
|
||||
this.fogColorEndIntensity = fogColorEndIntensity;
|
||||
this.fogColorDuo = fogColorDuo;
|
||||
this.skyboxFogIntensity = skyboxFogIntensity;
|
||||
this.skyboxFogHeight = skyboxFogHeight;
|
||||
@@ -48,11 +59,17 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
// 向后兼容:如果旧版 float 字段有有效值(>=0),则从旧字段构建 Color(覆盖新字段默认值)
|
||||
if (fogColorStartR >= 0f)
|
||||
fogColorStart = new Color(fogColorStartR, fogColorStartG, fogColorStartB, fogColorStartA);
|
||||
if (fogColorEndR >= 0f)
|
||||
fogColorEnd = new Color(fogColorEndR, fogColorEndG, fogColorEndB, fogColorEndA);
|
||||
|
||||
matchedElement = DTMGlobalFog.GenerateElement(elementName, elementGuid, tags, false,
|
||||
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic,
|
||||
fogIntensity,
|
||||
fogColorStartR, fogColorStartG, fogColorStartB, fogColorStartA,
|
||||
fogColorEndR, fogColorEndG, fogColorEndB, fogColorEndA,
|
||||
fogColorStart, fogColorEnd,
|
||||
fogColorStartIntensity, fogColorEndIntensity,
|
||||
fogColorDuo,
|
||||
skyboxFogIntensity, skyboxFogHeight,
|
||||
skyboxFogFalloff, skyboxFogOffset,
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
public float outerBorderColorA = 1f;
|
||||
public float outerBorderWidth = 0.02f;
|
||||
|
||||
public float fadeFar = 100f;
|
||||
public float fadeNear = 20f;
|
||||
|
||||
public DTMRandomGridFloor_BM()
|
||||
{
|
||||
}
|
||||
@@ -30,7 +33,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
string themeBundleName, string objectName, bool isStatic,
|
||||
float patternSizeX, float patternSizeY, float gridDensity,
|
||||
float timeAngle, float stepA, float stepB,
|
||||
bool enableOuterBorder, Color outerColor, float outerBorderWidth)
|
||||
bool enableOuterBorder, Color outerColor, float outerBorderWidth,
|
||||
float fadeFar = 100f, float fadeNear = 20f)
|
||||
: base(elementName, elementGuid, tags, attachedElement, themeBundleName, objectName, isStatic)
|
||||
{
|
||||
this.patternSizeX = patternSizeX;
|
||||
@@ -47,6 +51,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
this.outerBorderColorA = outerColor.a;
|
||||
|
||||
this.outerBorderWidth = outerBorderWidth;
|
||||
this.fadeFar = fadeFar;
|
||||
this.fadeNear = fadeNear;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
@@ -57,7 +63,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic,
|
||||
patternSizeX, patternSizeY, gridDensity,
|
||||
timeAngle, stepA, stepB,
|
||||
enableOuterBorder, outerColor, outerBorderWidth);
|
||||
enableOuterBorder, outerColor, outerBorderWidth,
|
||||
fadeFar, fadeNear);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
{
|
||||
@@ -10,8 +11,9 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
public FlexibleBool_BM enableTimes;
|
||||
public float enableProcessTime = 0.5f;
|
||||
public float headSize = 1f;
|
||||
|
||||
public FlexibleFloat_BM headRotateSpeed;
|
||||
public AnimationCurve widthCurve;
|
||||
public Gradient trailAlphaGradient;
|
||||
|
||||
public DTMTrail_BM()
|
||||
{
|
||||
@@ -20,7 +22,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
|
||||
public DTMTrail_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM parentElement,
|
||||
string themeBundleName, string objectName, bool isStatic, FlexibleFloat visibleTimeLength,
|
||||
FlexibleBool enableTimes, FlexibleFloat headRotateSpeed, float enableProcessTime, float headSize) :
|
||||
FlexibleBool enableTimes, FlexibleFloat headRotateSpeed, float enableProcessTime, float headSize,
|
||||
AnimationCurve widthCurve, Gradient trailAlphaGradient) :
|
||||
base(elementName, elementGuid, tags, parentElement, themeBundleName, objectName, isStatic)
|
||||
{
|
||||
this.visibleTimeLength = visibleTimeLength?.ConvertToBM();
|
||||
@@ -28,20 +31,23 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
this.headRotateSpeed = headRotateSpeed?.ConvertToBM();
|
||||
this.enableProcessTime = enableProcessTime;
|
||||
this.headSize = headSize;
|
||||
this.widthCurve = widthCurve;
|
||||
this.trailAlphaGradient = trailAlphaGradient;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = DTMTrail.GenerateElement(elementName, elementGuid, tags, false,
|
||||
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic, visibleTimeLength?.ConvertToGameType(),
|
||||
enableTimes?.ConvertToGameType(), headRotateSpeed?.ConvertToGameType(), enableProcessTime, headSize);
|
||||
enableTimes?.ConvertToGameType(), headRotateSpeed?.ConvertToGameType(), enableProcessTime, headSize,
|
||||
widthCurve, trailAlphaGradient);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return DTMTrail.GenerateElement(elementName, Guid.NewGuid(), tags, false,
|
||||
themeBundleName, objectName, parent, isStatic, visibleTimeLength?.ConvertToGameType(), enableTimes?.ConvertToGameType(),
|
||||
headRotateSpeed?.ConvertToGameType(), enableProcessTime, headSize);
|
||||
headRotateSpeed?.ConvertToGameType(), enableProcessTime, headSize, widthCurve, trailAlphaGradient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
matchedBM = new DTMGlobalFog_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
themeBundleName, objectName, isStatic,
|
||||
fogIntensity,
|
||||
fogColorStartR, fogColorStartG, fogColorStartB, fogColorStartA,
|
||||
fogColorEndR, fogColorEndG, fogColorEndB, fogColorEndA,
|
||||
fogColorStart, fogColorEnd,
|
||||
fogColorStartIntensity, fogColorEndIntensity,
|
||||
fogColorDuo,
|
||||
skyboxFogIntensity, skyboxFogHeight,
|
||||
skyboxFogFalloff, skyboxFogOffset,
|
||||
@@ -29,15 +29,14 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
var subcontainer = container.GenerateSubcontainer(3);
|
||||
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Intensity", nameof(fogIntensity)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color Start R", nameof(fogColorStartR)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color Start G", nameof(fogColorStartG)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color Start B", nameof(fogColorStartB)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color Start A", nameof(fogColorStartA)).AddListenerFunction(UpdateFogProperties);
|
||||
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color End R", nameof(fogColorEndR)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color End G", nameof(fogColorEndG)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color End B", nameof(fogColorEndB)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color End A", nameof(fogColorEndA)).AddListenerFunction(UpdateFogProperties);
|
||||
var colorStartContainer = container.GenerateSubcontainer(1);
|
||||
inspector.GenerateEmissionColorPicker(this, colorStartContainer, "Fog Color Start", "NULL", nameof(fogColorStart), nameof(fogColorStartIntensity))
|
||||
.AddListenerFunction(UpdateFogProperties);
|
||||
|
||||
var colorEndContainer = container.GenerateSubcontainer(1);
|
||||
inspector.GenerateEmissionColorPicker(this, colorEndContainer, "Fog Color End", "NULL", nameof(fogColorEnd), nameof(fogColorEndIntensity))
|
||||
.AddListenerFunction(UpdateFogProperties);
|
||||
|
||||
inspector.GenerateInputField(this, subcontainer, "Fog Color Duo", nameof(fogColorDuo)).AddListenerFunction(UpdateFogProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Skybox Fog Intensity", nameof(skyboxFogIntensity)).AddListenerFunction(UpdateFogProperties);
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
themeBundleName, objectName, isStatic,
|
||||
patternSizeX, patternSizeY, gridDensity,
|
||||
timeAngle, stepA, stepB,
|
||||
enableOuterBorder, outerBorderColor, outerBorderWidth);
|
||||
enableOuterBorder, outerBorderColor, outerBorderWidth,
|
||||
fadeFar, fadeNear);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
@@ -34,6 +35,9 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
inspector.GenerateToggle(this, subcontainer, "Enable Outer Border", nameof(enableOuterBorder)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateBaseColorPicker(this, subcontainer, "Outer Border Color", nameof(outerBorderColor)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Outer Border Width", nameof(outerBorderWidth)).AddListenerFunction(UpdateMaterialProperties);
|
||||
|
||||
inspector.GenerateInputField(this, subcontainer, "Fade Far", nameof(fadeFar)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fade Near", nameof(fadeNear)).AddListenerFunction(UpdateMaterialProperties);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
using Ichni.Editor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
{
|
||||
public partial class DTMTrail
|
||||
{
|
||||
#region [Editor] Inspection
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.DTMTrail_BM(elementName, elementGuid, tags, parentElement.matchedBM as Ichni.RhythmGame.Beatmap.GameElement_BM,
|
||||
themeBundleName, objectName, isStatic, visibleTimeLength, enableTimes, headRotateSpeed, enableProcessTime, headSize,
|
||||
widthCurve, trailAlphaGradient);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
base.SetUpInspector();
|
||||
@@ -39,6 +47,28 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
|
||||
var headSizeInputField =
|
||||
inspector.GenerateInputField(this, subcontainer, "Head Size", nameof(headSize));
|
||||
|
||||
var curveSettings = container.GenerateSubcontainer(3);
|
||||
var widthCurveButton = inspector.GenerateButton(this, curveSettings, "Width Curve", () =>
|
||||
{
|
||||
var window = inspector.GenerateCompositeParameterWindow(this, "Width Curve", nameof(widthCurve));
|
||||
window.SetAsCustomCurve();
|
||||
window.closeButton.onClick.AddListener(() => trailRenderer.widthCurve = widthCurve);
|
||||
});
|
||||
|
||||
var colorSettings = container.GenerateSubcontainer(3);
|
||||
var gradientColorKeysButton = inspector.GenerateButton(this, colorSettings, "Gradient Color Keys", () =>
|
||||
{
|
||||
var gradientWindow = inspector.GenerateCompositeParameterWindow(this, "Gradient Color Keys", nameof(trailAlphaGradient));
|
||||
gradientWindow.SetAsGradientColorKeys();
|
||||
gradientWindow.closeButton.onClick.AddListener(() => trailRenderer.colorGradient = trailAlphaGradient);
|
||||
});
|
||||
var gradientAlphaKeysButton = inspector.GenerateButton(this, colorSettings, "Gradient Alpha Keys", () =>
|
||||
{
|
||||
var gradientWindow = inspector.GenerateCompositeParameterWindow(this, "Gradient Alpha Keys", nameof(trailAlphaGradient));
|
||||
gradientWindow.SetAsGradientAlphaKeys();
|
||||
gradientWindow.closeButton.onClick.AddListener(() => trailRenderer.colorGradient = trailAlphaGradient);
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -14,8 +14,16 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
public HeightFogGlobal heightFogGlobal;
|
||||
|
||||
public float fogIntensity;
|
||||
public float fogColorStartR = 0.5f, fogColorStartG = 0.75f, fogColorStartB = 1f, fogColorStartA = 1f;
|
||||
public float fogColorEndR = 0.75f, fogColorEndG = 1f, fogColorEndB = 1.25f, fogColorEndA = 1f;
|
||||
|
||||
// 新字段:使用 Color + 发光强度(HDR)
|
||||
public Color fogColorStart = new Color(0.5f, 0.75f, 1f, 1f);
|
||||
public Color fogColorEnd = new Color(0.75f, 1f, 1.25f, 1f);
|
||||
public float fogColorStartIntensity = 0f;
|
||||
public float fogColorEndIntensity = 0f;
|
||||
|
||||
// 旧字段:保留以兼容旧版存档(由 BM 层 fallback 时使用)
|
||||
[System.NonSerialized] public float fogColorStartR = 0.5f, fogColorStartG = 0.75f, fogColorStartB = 1f, fogColorStartA = 1f;
|
||||
[System.NonSerialized] public float fogColorEndR = 0.75f, fogColorEndG = 1f, fogColorEndB = 1.25f, fogColorEndA = 1f;
|
||||
public float fogColorDuo;
|
||||
|
||||
public float skyboxFogIntensity;
|
||||
@@ -31,8 +39,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
|
||||
bool isStatic,
|
||||
float fogIntensity,
|
||||
float fogColorStartR, float fogColorStartG, float fogColorStartB, float fogColorStartA,
|
||||
float fogColorEndR, float fogColorEndG, float fogColorEndB, float fogColorEndA,
|
||||
Color fogColorStart, Color fogColorEnd,
|
||||
float fogColorStartIntensity, float fogColorEndIntensity,
|
||||
float fogColorDuo,
|
||||
float skyboxFogIntensity, float skyboxFogHeight,
|
||||
float skyboxFogFalloff, float skyboxFogOffset,
|
||||
@@ -42,24 +50,15 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<DTMGlobalFog>();
|
||||
|
||||
globalFog.fogIntensity = fogIntensity;
|
||||
|
||||
globalFog.fogColorStartR = fogColorStartR;
|
||||
globalFog.fogColorStartG = fogColorStartG;
|
||||
globalFog.fogColorStartB = fogColorStartB;
|
||||
globalFog.fogColorStartA = fogColorStartA;
|
||||
|
||||
globalFog.fogColorEndR = fogColorEndR;
|
||||
globalFog.fogColorEndG = fogColorEndG;
|
||||
globalFog.fogColorEndB = fogColorEndB;
|
||||
globalFog.fogColorEndA = fogColorEndA;
|
||||
|
||||
globalFog.fogColorStart = fogColorStart;
|
||||
globalFog.fogColorEnd = fogColorEnd;
|
||||
globalFog.fogColorStartIntensity = fogColorStartIntensity;
|
||||
globalFog.fogColorEndIntensity = fogColorEndIntensity;
|
||||
globalFog.fogColorDuo = fogColorDuo;
|
||||
|
||||
globalFog.skyboxFogIntensity = skyboxFogIntensity;
|
||||
globalFog.skyboxFogHeight = skyboxFogHeight;
|
||||
globalFog.skyboxFogFalloff = skyboxFogFalloff;
|
||||
globalFog.skyboxFogOffset = skyboxFogOffset;
|
||||
|
||||
globalFog.skyboxFogBottom = skyboxFogBottom;
|
||||
globalFog.skyboxFogFill = skyboxFogFill;
|
||||
|
||||
@@ -95,8 +94,9 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
|
||||
heightFogGlobal.fogIntensity = fogIntensity;
|
||||
|
||||
heightFogGlobal.fogColorStart = new Color(fogColorStartR, fogColorStartG, fogColorStartB, fogColorStartA);
|
||||
heightFogGlobal.fogColorEnd = new Color(fogColorEndR, fogColorEndG, fogColorEndB, fogColorEndA);
|
||||
// 使用 HDR 颜色(base color * 2^intensity)
|
||||
heightFogGlobal.fogColorStart = fogColorStart * Mathf.Pow(2, fogColorStartIntensity);
|
||||
heightFogGlobal.fogColorEnd = fogColorEnd * Mathf.Pow(2, fogColorEndIntensity);
|
||||
|
||||
heightFogGlobal.fogColorDuo = fogColorDuo;
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
public Color outerBorderColor;
|
||||
public float outerBorderWidth;
|
||||
|
||||
public float fadeFar = 100f;
|
||||
public float fadeNear = 20f;
|
||||
|
||||
public Renderer meshRenderer;
|
||||
#endregion
|
||||
|
||||
@@ -30,7 +33,9 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
float timeAngle, float stepA, float stepB,
|
||||
bool enableOuterBorder,
|
||||
Color outerBorderColor,
|
||||
float outerBorderWidth)
|
||||
float outerBorderWidth,
|
||||
float fadeFar = 100f,
|
||||
float fadeNear = 20f)
|
||||
{
|
||||
DTMRandomGridFloor randomGridFloor = EnvironmentObject.GenerateElement(elementName, id, tags,
|
||||
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<DTMRandomGridFloor>();
|
||||
@@ -45,6 +50,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
randomGridFloor.enableOuterBorder = enableOuterBorder;
|
||||
randomGridFloor.outerBorderColor = outerBorderColor;
|
||||
randomGridFloor.outerBorderWidth = outerBorderWidth;
|
||||
randomGridFloor.fadeFar = fadeFar;
|
||||
randomGridFloor.fadeNear = fadeNear;
|
||||
|
||||
return randomGridFloor;
|
||||
}
|
||||
@@ -95,6 +102,9 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
mat.SetColor("_OuterBorderColor", outerBorderColor);
|
||||
mat.SetFloat("_OuterBorderWidth", outerBorderWidth);
|
||||
|
||||
mat.SetFloat("_FadeFar", fadeFar);
|
||||
mat.SetFloat("_FadeNear", fadeNear);
|
||||
|
||||
mat.SetColor("_Color0", colorSubmodule.currentBaseColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,20 +14,20 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
public partial class DTMTrail : EnvironmentObject, IHaveTrail, IHaveInteraction
|
||||
{
|
||||
#region [暴露属性字段] Exposed Fields
|
||||
public GameObject headPoint, headCircle;
|
||||
public GameObject headPoint, headCircle, sparks;
|
||||
public GameObject trailBody;
|
||||
public List<Renderer> renderers = new List<Renderer>();
|
||||
public bool isHeadEnabled;
|
||||
|
||||
public List<Renderer> renderers;
|
||||
public ParticleSystem headCircleParticle;
|
||||
|
||||
public TrailRenderer trailRenderer { get; set; }
|
||||
|
||||
public FlexibleFloat visibleTimeLength;
|
||||
public FlexibleBool enableTimes;
|
||||
public float enableProcessTime = 0.5f;
|
||||
public float headSize = 1f;
|
||||
|
||||
public FlexibleFloat headRotateSpeed;
|
||||
public AnimationCurve widthCurve; //trailBody的宽度曲线,默认为常数0.5。
|
||||
public Gradient trailAlphaGradient; //trailBody的渐变,只控制Alpha,默认为1,Color必须为白色。
|
||||
|
||||
public FlexibleFloat visibleTimeLength; //trailBody的可见时间长度,如果没有动画,则默认为1秒。
|
||||
public FlexibleBool enableTimes; // headPoint和headCircle的启用/禁用时间,如果没有动画,则一直禁用。
|
||||
public float enableProcessTime = 0.5f; // headPoint,headCircle的启用/禁用过程时间,默认为0.5秒,启用完成后,sparks开启,禁用开始时,sparks关闭。
|
||||
public float headSize = 1f; // headPoint和headCircle的目标大小,默认为1。
|
||||
public FlexibleFloat headRotateSpeed; // headCircle的旋转速度(Particle.rotationOverLifetime的angular velocity)
|
||||
float IHaveTrail.visibleTimeLength
|
||||
{
|
||||
get => visibleTimeLength.animations.Count > 0 ? visibleTimeLength.value : 5f;
|
||||
@@ -35,13 +35,30 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
}
|
||||
|
||||
public override bool haveEmissionColor => true;
|
||||
|
||||
// 默认值辅助:返回常量宽度曲线(0.5常数)
|
||||
private static AnimationCurve DefaultWidthCurve()
|
||||
{
|
||||
return AnimationCurve.Constant(0f, 1f, 0.5f);
|
||||
}
|
||||
|
||||
// 默认值辅助:返回全不透明白色渐变
|
||||
private static Gradient DefaultTrailGradient()
|
||||
{
|
||||
var g = new Gradient();
|
||||
g.SetKeys(
|
||||
new GradientColorKey[] { new GradientColorKey(UnityEngine.Color.white, 0f), new GradientColorKey(UnityEngine.Color.white, 1f) },
|
||||
new GradientAlphaKey[] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) }
|
||||
);
|
||||
return g;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region [生命周期与工厂] Lifecycle & Factory
|
||||
public static DTMTrail GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
bool isFirstGenerated, string themeBundleName, string objectName, GameElement parentElement,
|
||||
bool isStatic, FlexibleFloat visibleTimeLength, FlexibleBool enableTimes, FlexibleFloat headRotateSpeed, float enableProcessTime,
|
||||
float headSize)
|
||||
float headSize, AnimationCurve widthCurve = null, Gradient trailGradient = null)
|
||||
{
|
||||
DTMTrail dtmTrail = EnvironmentObject.GenerateElement(elementName, id, tags,
|
||||
isFirstGenerated, themeBundleName, objectName, parentElement, isStatic).GetComponent<DTMTrail>();
|
||||
@@ -52,6 +69,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
dtmTrail.headRotateSpeed = headRotateSpeed;
|
||||
dtmTrail.enableProcessTime = enableProcessTime;
|
||||
dtmTrail.headSize = headSize;
|
||||
dtmTrail.widthCurve = widthCurve ?? DefaultWidthCurve();
|
||||
dtmTrail.trailAlphaGradient = trailGradient ?? DefaultTrailGradient();
|
||||
|
||||
return dtmTrail;
|
||||
}
|
||||
@@ -66,59 +85,141 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
|
||||
public override void FirstSetUpObject(bool isFirstGenerated)
|
||||
{
|
||||
if (isFirstGenerated)
|
||||
{
|
||||
/*enableTimes = new FlexibleBool();
|
||||
|
||||
if (parentElement is TrackHeadPoint trackHeadPoint)
|
||||
{
|
||||
enableTimes.Add(new AnimatedBool(0f, false));
|
||||
enableTimes.Add(new AnimatedBool(trackHeadPoint.trackTimeSubmoduleMovable.trackStartTime, true));
|
||||
enableTimes.Add(new AnimatedBool(trackHeadPoint.trackTimeSubmoduleMovable.trackEndTime, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
enableTimes.Add(new AnimatedBool(0f, false));
|
||||
enableTimes.Add(new AnimatedBool(1f, true));
|
||||
}*/
|
||||
}
|
||||
|
||||
//SetUpTweeners();
|
||||
trailRenderer = trailBody.GetComponent<TrailRenderer>();
|
||||
//var rotationBySpeedModule = headCircleParticle.rotationBySpeed;
|
||||
//rotationBySpeedModule.z = 0;
|
||||
//headPoint.transform.localScale = Vector3.zero;
|
||||
//headCircle.transform.localScale = Vector3.zero;
|
||||
|
||||
//renderers.ForEach(rend => rend.InitializeShader());
|
||||
// 初始化默认值(兼容旧存档中未序列化字段)
|
||||
if (widthCurve == null || widthCurve.keys.Length == 0) widthCurve = DefaultWidthCurve();
|
||||
if (trailAlphaGradient == null) trailAlphaGradient = DefaultTrailGradient();
|
||||
|
||||
trailRenderer.widthCurve = widthCurve;
|
||||
|
||||
// 收集所有使用 BlendUnlit 的 Renderer(headPoint, headCircle, sparks 的粒子Renderer + trailBody)
|
||||
renderers.Clear();
|
||||
CollectBlendUnlitRenderer(headPoint);
|
||||
CollectBlendUnlitRenderer(headCircle);
|
||||
CollectBlendUnlitRenderer(sparks);
|
||||
CollectBlendUnlitRenderer(trailBody);
|
||||
|
||||
// 实例化所有材质(避免修改共享材质)
|
||||
foreach (var rend in renderers)
|
||||
{
|
||||
rend.InitializeShader();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归收集 gameObject 及其子物体中所有使用 BlendUnlit (Soullies/BlendUnlit) 的 Renderer
|
||||
/// </summary>
|
||||
private void CollectBlendUnlitRenderer(GameObject root)
|
||||
{
|
||||
if (root == null) return;
|
||||
foreach (var rend in root.GetComponentsInChildren<Renderer>(true))
|
||||
{
|
||||
if (rend.sharedMaterial != null && rend.sharedMaterial.shader.name.Contains("BlendUnlit"))
|
||||
{
|
||||
renderers.Add(rend);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyTimeOffset(float offset)
|
||||
{
|
||||
base.ApplyTimeOffset(offset);
|
||||
foreach (AnimatedBool animBool in enableTimes.animations)
|
||||
{
|
||||
animBool.time += offset;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
|
||||
/*renderers.ForEach(rend =>
|
||||
Color baseColor = colorSubmodule.currentBaseColor;
|
||||
|
||||
// --- 粒子系统颜色 ---
|
||||
// headPoint 和 sparks:S 降至 baseColor 的四分之一
|
||||
Color.RGBToHSV(baseColor, out float h, out float s, out float v);
|
||||
Color desaturatedColor = Color.HSVToRGB(h, s * 0.25f, v);
|
||||
desaturatedColor.a = baseColor.a;
|
||||
|
||||
if (headPoint != null)
|
||||
{
|
||||
var ps = headPoint.GetComponent<ParticleSystem>();
|
||||
if (ps != null)
|
||||
{
|
||||
var main = ps.main;
|
||||
main.startColor = desaturatedColor;
|
||||
}
|
||||
}
|
||||
|
||||
if (sparks != null)
|
||||
{
|
||||
var ps = sparks.GetComponent<ParticleSystem>();
|
||||
if (ps != null)
|
||||
{
|
||||
var main = ps.main;
|
||||
main.startColor = desaturatedColor;
|
||||
}
|
||||
}
|
||||
|
||||
// headCircle:与 baseColor 完全一致
|
||||
if (headCircle != null)
|
||||
{
|
||||
var ps = headCircle.GetComponent<ParticleSystem>();
|
||||
if (ps != null)
|
||||
{
|
||||
var main = ps.main;
|
||||
main.startColor = baseColor;
|
||||
}
|
||||
}
|
||||
|
||||
// --- trailRenderer 颜色 ---
|
||||
// 以 baseColor 为固定颜色,trailAlphaGradient 只取其 Alpha 通道
|
||||
if (trailRenderer != null)
|
||||
{
|
||||
Gradient combinedGradient = BuildTrailColorGradient(baseColor, trailAlphaGradient);
|
||||
trailRenderer.colorGradient = combinedGradient;
|
||||
}
|
||||
|
||||
// --- BlendUnlit Renderer 材质属性(BaseColor + EmissionColor)---
|
||||
Color emissionColor = colorSubmodule.GetCurrentEmissionColor();
|
||||
foreach (var rend in renderers)
|
||||
{
|
||||
if (rend == null) continue;
|
||||
if (colorSubmodule.emissionEnabled)
|
||||
{
|
||||
rend.material.EnableKeyword("_EMISSION_ON");
|
||||
// Debug.Log("Enable emission");
|
||||
rend.material.SetColor("_EmissionColor", emissionColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
rend.material.DisableKeyword("_EMISSION_ON");
|
||||
}
|
||||
rend.material.SetColor("_BaseColor", colorSubmodule.currentBaseColor);
|
||||
rend.material.SetColor("_EmissionColor", colorSubmodule.GetCurrentEmissionColor());
|
||||
});*/
|
||||
}
|
||||
}
|
||||
public override void AfterInitialize()
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用 baseColor 作为固定颜色,从 alphaSource 中提取 Alpha 曲线,合成最终的 TrailRenderer Gradient
|
||||
/// </summary>
|
||||
private static Gradient BuildTrailColorGradient(Color baseColor, Gradient alphaSource)
|
||||
{
|
||||
base.AfterInitialize();
|
||||
/*renderers.ForEach(rend =>
|
||||
GradientAlphaKey[] alphaKeys = alphaSource != null
|
||||
? alphaSource.alphaKeys
|
||||
: new GradientAlphaKey[] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, 1f) };
|
||||
|
||||
// 颜色键:头尾都用 baseColor(RGB),Alpha 忽略(由 alphaKeys 控制)
|
||||
GradientColorKey[] colorKeys = new GradientColorKey[]
|
||||
{
|
||||
rend.material.EnableKeyword("_USEREDASALPHA_ON");
|
||||
});*/
|
||||
new GradientColorKey(baseColor, 0f),
|
||||
new GradientColorKey(baseColor, 1f)
|
||||
};
|
||||
|
||||
var g = new Gradient();
|
||||
g.SetKeys(colorKeys, alphaKeys);
|
||||
return g;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -129,12 +230,12 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
enableTimes.UpdateFlexibleBool(songTime);
|
||||
if (enableTimes.value && !isHeadEnabled)
|
||||
{
|
||||
//EnableHead();
|
||||
EnableHead();
|
||||
isHeadEnabled = true;
|
||||
}
|
||||
else if (!enableTimes.value && isHeadEnabled)
|
||||
{
|
||||
//DisableHead();
|
||||
DisableHead();
|
||||
isHeadEnabled = false;
|
||||
}
|
||||
|
||||
@@ -148,8 +249,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
|
||||
if (isHeadEnabled && headRotateSpeed.animations.Count > 0)
|
||||
{
|
||||
headRotateSpeed.UpdateFlexibleFloat(songTime);
|
||||
/*var rotationBySpeedModule = headCircleParticle.rotationBySpeed;
|
||||
/*headRotateSpeed.UpdateFlexibleFloat(songTime);
|
||||
var rotationBySpeedModule = headCircle.GetComponent<ParticleSystem>().rotationOverLifetime;
|
||||
rotationBySpeedModule.z = headRotateSpeed.value;*/
|
||||
}
|
||||
|
||||
@@ -168,12 +269,14 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
enableHeadSequence = DOTween.Sequence();
|
||||
enableHeadSequence.Append(headPoint.transform.DOScale(headSize, enableProcessTime).SetEase(Ease.OutQuad));
|
||||
enableHeadSequence.Join(headCircle.transform.DOScale(headSize, enableProcessTime).SetEase(Ease.OutQuad));
|
||||
enableHeadSequence.OnComplete(() => sparks.SetActive(true));
|
||||
enableHeadSequence.Play();
|
||||
}
|
||||
|
||||
private void DisableHead()
|
||||
{
|
||||
disableHeadSequence = DOTween.Sequence();
|
||||
disableHeadSequence.OnStart(() => sparks.SetActive(false));
|
||||
disableHeadSequence.Append(headPoint.transform.DOScale(0, enableProcessTime).SetEase(Ease.OutQuad));
|
||||
disableHeadSequence.Join(headCircle.transform.DOScale(0, enableProcessTime).SetEase(Ease.OutQuad));
|
||||
disableHeadSequence.Play();
|
||||
@@ -190,15 +293,4 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public partial class DTMTrail
|
||||
{
|
||||
#region [数据导出与巡检] Export & UI
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new DTMTrail_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
themeBundleName, objectName, isStatic, visibleTimeLength, enableTimes, headRotateSpeed, enableProcessTime, headSize);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user