|
|
|
|
@@ -9,15 +9,18 @@ using UnityEngine.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
{
|
|
|
|
|
public partial class ParticleTracker : GameElement, IHaveColorSubmodule
|
|
|
|
|
public partial class ParticleTracker : GameElement, IHaveParticles, IHaveColorSubmodule
|
|
|
|
|
{
|
|
|
|
|
public Track track;
|
|
|
|
|
public ParticleController particleController;
|
|
|
|
|
public ParticleSystem particle;
|
|
|
|
|
private IHaveParticles particlesContainer => this;
|
|
|
|
|
public ParticleSystem particle { get; set; }
|
|
|
|
|
public ColorSubmodule colorSubmodule { get; set; }
|
|
|
|
|
public bool haveBaseColor => true;
|
|
|
|
|
public bool haveEmissionColor => true;
|
|
|
|
|
|
|
|
|
|
private List<string> themeBundleList;
|
|
|
|
|
private List<string> materialNameList;
|
|
|
|
|
public string themeBundleName;
|
|
|
|
|
public string materialName;
|
|
|
|
|
|
|
|
|
|
@@ -45,6 +48,7 @@ namespace Ichni.RhythmGame
|
|
|
|
|
{
|
|
|
|
|
ParticleTracker particleTracker = Instantiate(EditorManager.instance.basePrefabs.particleTracker, track.transform)
|
|
|
|
|
.GetComponent<ParticleTracker>();
|
|
|
|
|
particleTracker.particle = particleTracker.GetComponent<ParticleSystem>();
|
|
|
|
|
particleTracker.Initialize(elementName, id, tags, isFirstGenerated, track);
|
|
|
|
|
particleTracker.track = track;
|
|
|
|
|
particleTracker.particleController.spline = track.trackPathSubmodule.path;
|
|
|
|
|
@@ -54,7 +58,7 @@ namespace Ichni.RhythmGame
|
|
|
|
|
particleTracker.materialNameList = new List<string>();
|
|
|
|
|
particleTracker.themeBundleName = themeBundleName;
|
|
|
|
|
particleTracker.materialName = materialName;
|
|
|
|
|
particleTracker.SetParticleMaterial(themeBundleName, materialName);
|
|
|
|
|
particleTracker.particlesContainer.SetParticleMaterial(themeBundleName, materialName);
|
|
|
|
|
particleTracker.SetParticleSettings(prewarm, is3D, width, extendDirection, density, lifeTime, isAutoOrient, particleRotation);
|
|
|
|
|
return particleTracker;
|
|
|
|
|
}
|
|
|
|
|
@@ -64,25 +68,9 @@ namespace Ichni.RhythmGame
|
|
|
|
|
colorSubmodule = new ColorSubmodule(this, Color.white, true, Color.white, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetParticleMaterial(string themeBundleName, string materialName)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Material material = ThemeBundleManager.instance.GetObject<Material>(themeBundleName, materialName);
|
|
|
|
|
if (material == null)
|
|
|
|
|
{
|
|
|
|
|
print("Material not found: " + themeBundleName + ", " + materialName);
|
|
|
|
|
material = ThemeBundleManager.instance.GetObject<Material>("basic", "Basic_Track_Default");
|
|
|
|
|
}
|
|
|
|
|
Renderer particleRenderer = particle.GetComponent<Renderer>();
|
|
|
|
|
particleRenderer.material = Instantiate(material);
|
|
|
|
|
particleRenderer.InitializeShader();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetParticleSettings(bool prewarm,
|
|
|
|
|
bool is3D, float width, Vector3 extendDirection,
|
|
|
|
|
float density, float lifeTime,
|
|
|
|
|
bool isAutoOrient, Vector3 particleRotation)
|
|
|
|
|
public void SetParticleSettings(bool prewarm, bool is3D, float width, Vector3 extendDirection,
|
|
|
|
|
float density, float lifeTime, bool isAutoOrient, Vector3 particleRotation)
|
|
|
|
|
{
|
|
|
|
|
this.prewarm = prewarm;
|
|
|
|
|
this.is3D = is3D;
|
|
|
|
|
@@ -93,12 +81,9 @@ namespace Ichni.RhythmGame
|
|
|
|
|
this.prewarm = prewarm;
|
|
|
|
|
this.isAutoOrient = isAutoOrient;
|
|
|
|
|
this.particleRotation = particleRotation;
|
|
|
|
|
|
|
|
|
|
SetPrewarm();
|
|
|
|
|
particlesContainer.SetParticleSettings(prewarm, ParticleSystemSimulationSpace.Local, density,
|
|
|
|
|
lifeTime, 0, 1, isAutoOrient, particleRotation);
|
|
|
|
|
SetShape();
|
|
|
|
|
SetDensity();
|
|
|
|
|
SetLifeTime();
|
|
|
|
|
SetAlignment();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -139,9 +124,6 @@ namespace Ichni.RhythmGame
|
|
|
|
|
themeBundleName, materialName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<string> themeBundleList;
|
|
|
|
|
private List<string> materialNameList;
|
|
|
|
|
|
|
|
|
|
public override void SetUpInspector()
|
|
|
|
|
{
|
|
|
|
|
base.SetUpInspector();
|
|
|
|
|
@@ -155,24 +137,32 @@ namespace Ichni.RhythmGame
|
|
|
|
|
themeBundleList = ThemeBundleManager.instance.loadedThemeBundleList.ConvertAll(x => x.themeBundleName);
|
|
|
|
|
|
|
|
|
|
DynamicUISubcontainer particleSettings0 = container.GenerateSubcontainer(3);
|
|
|
|
|
inspector.GenerateToggle(this, particleSettings0, "Prewarm", nameof(prewarm)).AddListenerFunction(SetPrewarm);
|
|
|
|
|
inspector.GenerateToggle(this, particleSettings0, "Prewarm", nameof(prewarm))
|
|
|
|
|
.AddListenerFunction(() => particlesContainer.SetPrewarm(prewarm));
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings0, "Play Time", nameof(playTime));
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings0, "Stop Time", nameof(stopTime));
|
|
|
|
|
|
|
|
|
|
DynamicUISubcontainer particleSettings1_0 = container.GenerateSubcontainer(3);
|
|
|
|
|
inspector.GenerateToggle(this, particleSettings1_0, "Is 3D", nameof(is3D)).AddListenerFunction(SetShape);
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings1_0, "Width", nameof(width)).AddListenerFunction(SetShape);
|
|
|
|
|
inspector.GenerateToggle(this, particleSettings1_0, "Is 3D", nameof(is3D))
|
|
|
|
|
.AddListenerFunction(SetShape);
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings1_0, "Width", nameof(width))
|
|
|
|
|
.AddListenerFunction(SetShape);
|
|
|
|
|
DynamicUISubcontainer particleSettings1_1 = container.GenerateSubcontainer(1);
|
|
|
|
|
inspector.GenerateVector3InputField(this, particleSettings1_1, "Extend Direction", nameof(extendDirection)).AddListenerFunction(SetShape);
|
|
|
|
|
inspector.GenerateVector3InputField(this, particleSettings1_1, "Extend Direction", nameof(extendDirection))
|
|
|
|
|
.AddListenerFunction(SetShape);
|
|
|
|
|
|
|
|
|
|
DynamicUISubcontainer particleSettings2 = container.GenerateSubcontainer(3);
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings2, "Density", nameof(density)).AddListenerFunction(SetDensity);
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings2, "Life Time", nameof(lifeTime)).AddListenerFunction(SetLifeTime);
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings2, "Density", nameof(density))
|
|
|
|
|
.AddListenerFunction(()=>particlesContainer.SetDensity(density));
|
|
|
|
|
inspector.GenerateInputField(this, particleSettings2, "Life Time", nameof(lifeTime))
|
|
|
|
|
.AddListenerFunction(()=>particlesContainer.SetLifeTime(lifeTime));
|
|
|
|
|
|
|
|
|
|
DynamicUISubcontainer particleSettings3_0 = container.GenerateSubcontainer(3);
|
|
|
|
|
inspector.GenerateToggle(this, particleSettings3_0, "Is Auto Orient", nameof(isAutoOrient)).AddListenerFunction(SetAlignment);
|
|
|
|
|
inspector.GenerateToggle(this, particleSettings3_0, "Is Auto Orient", nameof(isAutoOrient))
|
|
|
|
|
.AddListenerFunction(()=>particlesContainer.SetAlignment(isAutoOrient, particleRotation));
|
|
|
|
|
DynamicUISubcontainer particleSettings3_1 = container.GenerateSubcontainer(1);
|
|
|
|
|
inspector.GenerateVector3InputField(this, particleSettings3_1, "Particle Rotation", nameof(particleRotation)).AddListenerFunction(SetParticleRotation);
|
|
|
|
|
inspector.GenerateVector3InputField(this, particleSettings3_1, "Particle Rotation", nameof(particleRotation))
|
|
|
|
|
.AddListenerFunction(()=>particlesContainer.SetParticleRotation(particleRotation));
|
|
|
|
|
|
|
|
|
|
DynamicUISubcontainer materialSettings = container.GenerateSubcontainer(3);
|
|
|
|
|
var themeBundleDropdown =
|
|
|
|
|
@@ -195,7 +185,7 @@ namespace Ichni.RhythmGame
|
|
|
|
|
|
|
|
|
|
var setMaterialButton = inspector.GenerateButton(this, materialSettings, "Set Material", () =>
|
|
|
|
|
{
|
|
|
|
|
SetParticleMaterial(themeBundleName, materialName);
|
|
|
|
|
particlesContainer.SetParticleMaterial(themeBundleName, materialName);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (themeBundleName == String.Empty || materialName == String.Empty)
|
|
|
|
|
@@ -215,50 +205,6 @@ namespace Ichni.RhythmGame
|
|
|
|
|
particleController.Rebuild();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetDensity()
|
|
|
|
|
{
|
|
|
|
|
var emission = particle.emission;
|
|
|
|
|
emission.rateOverTime = density;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetLifeTime()
|
|
|
|
|
{
|
|
|
|
|
var mainModule = particle.main;
|
|
|
|
|
mainModule.startLifetime = lifeTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetPrewarm()
|
|
|
|
|
{
|
|
|
|
|
var mainModule = particle.main;
|
|
|
|
|
mainModule.prewarm = prewarm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetAlignment()
|
|
|
|
|
{
|
|
|
|
|
ParticleSystemRenderer particleSystemRenderer = particle.GetComponent<ParticleSystemRenderer>();
|
|
|
|
|
var mainModule = particle.main;
|
|
|
|
|
if (isAutoOrient)
|
|
|
|
|
{
|
|
|
|
|
particleSystemRenderer.alignment = ParticleSystemRenderSpace.View;
|
|
|
|
|
mainModule.startRotation3D = false; // 禁用3D旋转
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
particleSystemRenderer.alignment = ParticleSystemRenderSpace.Local;
|
|
|
|
|
mainModule.startRotation3D = true; // 启用3D旋转
|
|
|
|
|
SetParticleRotation();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetParticleRotation()
|
|
|
|
|
{
|
|
|
|
|
Vector3 vector3Rotation = particleRotation * Mathf.Deg2Rad;
|
|
|
|
|
var mainModule = particle.main;
|
|
|
|
|
mainModule.startRotationX = vector3Rotation.x;
|
|
|
|
|
mainModule.startRotationY = vector3Rotation.y;
|
|
|
|
|
mainModule.startRotationZ = vector3Rotation.z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Refresh()
|
|
|
|
|
{
|
|
|
|
|
base.Refresh();
|
|
|
|
|
|