架构大更

This commit is contained in:
SoulliesOfficial
2026-03-20 11:56:50 -04:00
parent e60ef64d01
commit d09b58fd80
3663 changed files with 15232012 additions and 105579 deletions

View File

@@ -1,74 +1,61 @@
using UnityEngine;
using System.Collections;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to a ParticleSystem so it auto destroys once it has stopped emitting.
/// Make sure your ParticleSystem isn't looping, otherwise this script will be useless
/// Add this class to a ParticleSystem so it auto destroys once it has stopped emitting.
/// Make sure your ParticleSystem isn't looping, otherwise this script will be useless
/// </summary>
[AddComponentMenu("More Mountains/Tools/Particles/MM Auto Destroy Particle System")]
public class MMAutoDestroyParticleSystem : MonoBehaviour
{
/// True if the ParticleSystem should also destroy its parent
public bool DestroyParent = false;
public class MMAutoDestroyParticleSystem : MonoBehaviour
{
/// True if the ParticleSystem should also destroy its parent
public bool DestroyParent;
/// If for some reason your particles don't get destroyed automatically at the end of the emission, you can force a destroy after a delay. Leave it at zero otherwise.
public float DestroyDelay = 0f;
protected ParticleSystem _particleSystem;
protected float _startTime;
protected bool _started = false;
/// <summary>
/// Initialization, we get the ParticleSystem component
/// </summary>
protected virtual void Start()
{
_started = false;
_particleSystem = GetComponent<ParticleSystem>();
if (DestroyDelay != 0)
{
_startTime = Time.time;
}
}
/// <summary>
/// When the ParticleSystem stops playing, we destroy it.
/// </summary>
protected virtual void Update()
{
if ( (DestroyDelay != 0) && (Time.time - _startTime > DestroyDelay) )
{
DestroyParticleSystem();
}
/// If for some reason your particles don't get destroyed automatically at the end of the emission, you can force a destroy after a delay. Leave it at zero otherwise.
public float DestroyDelay;
if (_particleSystem.isPlaying)
{
_started = true;
return;
}
protected ParticleSystem _particleSystem;
protected bool _started;
protected float _startTime;
DestroyParticleSystem();
}
/// <summary>
/// Initialization, we get the ParticleSystem component
/// </summary>
protected virtual void Start()
{
_started = false;
_particleSystem = GetComponent<ParticleSystem>();
if (DestroyDelay != 0) _startTime = Time.time;
}
/// <summary>
/// Destroys the particle system.
/// </summary>
protected virtual void DestroyParticleSystem()
{
if (!_started)
{
return;
}
if (transform.parent!=null)
{
if(DestroyParent)
{
Destroy(transform.parent.gameObject);
}
}
Destroy (gameObject);
}
}
/// <summary>
/// When the ParticleSystem stops playing, we destroy it.
/// </summary>
protected virtual void Update()
{
if (DestroyDelay != 0 && Time.time - _startTime > DestroyDelay) DestroyParticleSystem();
if (_particleSystem.isPlaying)
{
_started = true;
return;
}
DestroyParticleSystem();
}
/// <summary>
/// Destroys the particle system.
/// </summary>
protected virtual void DestroyParticleSystem()
{
if (!_started) return;
if (transform.parent != null)
if (DestroyParent)
Destroy(transform.parent.gameObject);
Destroy(gameObject);
}
}
}

View File

@@ -1,52 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
namespace MoreMountains.Tools
{
[ExecuteAlways]
/// <summary>
/// MM delay particles.
/// </summary>
[AddComponentMenu("More Mountains/Tools/Particles/MM Delay Particles")]
public class MMDelayParticles : MonoBehaviour
{
[Header("Delay")]
/// the duration of the delay, in seconds
public float Delay;
/// if this is true, this will delay by the same amount all children particle systems of this object
public bool DelayChildren = true;
/// if this is true, the delay will be applied on Start
public bool ApplyDelayOnStart = false;
[ExecuteAlways]
/// <summary>
/// MM delay particles.
/// </summary>
[AddComponentMenu("More Mountains/Tools/Particles/MM Delay Particles")]
public class MMDelayParticles : MonoBehaviour
{
[Header("Delay")]
/// the duration of the delay, in seconds
public float Delay;
[MMInspectorButtonAttribute("ApplyDelay")]
public bool ApplyDelayButton;
/// if this is true, this will delay by the same amount all children particle systems of this object
public bool DelayChildren = true;
protected Component[] particleSystems;
/// if this is true, the delay will be applied on Start
public bool ApplyDelayOnStart;
protected virtual void Start()
{
if (ApplyDelayOnStart)
{
ApplyDelay();
}
}
[MMInspectorButtonAttribute("ApplyDelay")]
public bool ApplyDelayButton;
protected virtual void ApplyDelay()
{
if (this.gameObject.GetComponent<ParticleSystem>() != null)
{
ParticleSystem.MainModule main = this.gameObject.GetComponent<ParticleSystem>().main;
main.startDelay = main.startDelay.constant + Delay;
}
protected Component[] particleSystems;
particleSystems = GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem system in particleSystems)
{
ParticleSystem.MainModule main = system.main;
main.startDelay = main.startDelay.constant + Delay;
}
protected virtual void Start()
{
if (ApplyDelayOnStart) ApplyDelay();
}
}
}
protected virtual void ApplyDelay()
{
if (gameObject.GetComponent<ParticleSystem>() != null)
{
var main = gameObject.GetComponent<ParticleSystem>().main;
main.startDelay = main.startDelay.constant + Delay;
}
particleSystems = GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem system in particleSystems)
{
var main = system.main;
main.startDelay = main.startDelay.constant + Delay;
}
}
}
}