mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:47:38 +02:00
Space soccer polish and editor preview button
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BezierSolution.Extras
|
||||
{
|
||||
// This class is used for resetting the particle system attached to a ParticlesFollowBezier
|
||||
// component when it is selected. Otherwise, particles move in a chaotic way for a while
|
||||
[CustomEditor( typeof( ParticlesFollowBezier ) )]
|
||||
[CanEditMultipleObjects]
|
||||
public class ParticlesFollowBezierEditor : Editor
|
||||
{
|
||||
private int particlesReset;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
particlesReset = 3;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if( Application.isPlaying )
|
||||
return;
|
||||
|
||||
if( particlesReset > 0 && --particlesReset == 0 )
|
||||
{
|
||||
foreach( Object target in targets )
|
||||
{
|
||||
ResetParticles( ( (ParticlesFollowBezier) target ).GetComponentsInParent<ParticlesFollowBezier>() );
|
||||
ResetParticles( ( (ParticlesFollowBezier) target ).GetComponentsInChildren<ParticlesFollowBezier>() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetParticles( ParticlesFollowBezier[] targets )
|
||||
{
|
||||
foreach( ParticlesFollowBezier target in targets )
|
||||
{
|
||||
ParticleSystem particleSystem = target.GetComponent<ParticleSystem>();
|
||||
if( target.spline != null && particleSystem != null && target.enabled )
|
||||
particleSystem.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user