2026-06-12 각종 에셋 포함
This commit is contained in:
93
Assets/Piloto Studio/Scripts/ParticleHandler.cs
Normal file
93
Assets/Piloto Studio/Scripts/ParticleHandler.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace PilotoStudio
|
||||
{
|
||||
[ExecuteAlways]
|
||||
public class ParticleHandler : MonoBehaviour
|
||||
{
|
||||
public GameObject castParticle;
|
||||
public float castFXDuration;
|
||||
public GameObject loopingParticle;
|
||||
public float loopDuration;
|
||||
public GameObject endParticle;
|
||||
|
||||
private ParticleSystem castParticleSystem;
|
||||
private ParticleSystem loopingParticleSystem;
|
||||
private ParticleSystem endParticleSystem;
|
||||
|
||||
float startEmission;
|
||||
private void OnEnable()
|
||||
{
|
||||
castParticleSystem = castParticle.GetComponent<ParticleSystem>();
|
||||
loopingParticleSystem = loopingParticle.GetComponent<ParticleSystem>();
|
||||
endParticleSystem = endParticle.GetComponent<ParticleSystem>();
|
||||
if (!castParticleSystem || !loopingParticleSystem || !endParticleSystem)
|
||||
{
|
||||
Debug.LogError("ParticleHandler: Missing particle systems. Ensure they are referenced correctly.");
|
||||
return;
|
||||
}
|
||||
|
||||
Cast();
|
||||
}
|
||||
|
||||
public void Cast()
|
||||
{
|
||||
StartCoroutine(Flow());
|
||||
}
|
||||
|
||||
IEnumerator Flow()
|
||||
{
|
||||
PlayParticles(castParticleSystem, castFXDuration);
|
||||
yield return new WaitForSeconds(castFXDuration);
|
||||
|
||||
PlayParticles(loopingParticleSystem, loopDuration);
|
||||
yield return new WaitForSeconds(loopDuration);
|
||||
|
||||
PlayParticles(endParticleSystem);
|
||||
yield return WaitUntilParticleSystemStops(endParticleSystem);
|
||||
}
|
||||
private IEnumerator WaitUntilParticleSystemStops(ParticleSystem particleSystem)
|
||||
{
|
||||
while (particleSystem.IsAlive(true))
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
private void PlayParticles(ParticleSystem particleSystem, float duration = 0f)
|
||||
{
|
||||
particleSystem.gameObject.SetActive(true);
|
||||
var particleSystemMain = particleSystem.emission;
|
||||
|
||||
if (startEmission == 0)
|
||||
startEmission = particleSystemMain.rateOverTimeMultiplier;
|
||||
|
||||
if (particleSystem.main.startLifetime.constantMax == Mathf.Infinity)
|
||||
StartCoroutine(WaitUntilParticleSystemStops(particleSystem));
|
||||
else
|
||||
particleSystemMain.rateOverTimeMultiplier = startEmission;
|
||||
|
||||
particleSystem.Play();
|
||||
|
||||
if (duration > 0f && particleSystem.main.startLifetime.constantMax != Mathf.Infinity)
|
||||
{
|
||||
StartCoroutine(StopParticleAfterTime(particleSystem, duration));
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator StopParticleAfterTime(ParticleSystem particleSystem, float duration)
|
||||
{
|
||||
yield return new WaitForSeconds(duration);
|
||||
var particleSystemMain = particleSystem.emission;
|
||||
particleSystemMain.rateOverTimeMultiplier = 0;
|
||||
// particleSystem.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
18
Assets/Piloto Studio/Scripts/ParticleHandler.cs.meta
Normal file
18
Assets/Piloto Studio/Scripts/ParticleHandler.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3965e2f8bb9f2694db78e024fb08860d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: fb699b540497d184d955ea64cf02db66, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 349430
|
||||
packageName: Ultimate Loot VFX Pack - 199 Effects
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/Piloto Studio/Scripts/ParticleHandler.cs
|
||||
uploadId: 846416
|
||||
99
Assets/Piloto Studio/Scripts/ParticleShowcase.cs
Normal file
99
Assets/Piloto Studio/Scripts/ParticleShowcase.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace PilotoStudio
|
||||
{
|
||||
public class ParticleShowcase : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private List<GameObject> particles = new List<GameObject>();
|
||||
[SerializeField]
|
||||
private int currentlyActive = 0;
|
||||
[SerializeField]
|
||||
private Text displayName;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
foreach (Transform t in this.transform)
|
||||
{
|
||||
particles.Add(t.gameObject);
|
||||
}
|
||||
PostUpdateLogic();
|
||||
particles[currentlyActive].SetActive(true);
|
||||
}
|
||||
|
||||
void PostUpdateLogic()
|
||||
{
|
||||
if (displayName != null)
|
||||
displayName.text = particles[currentlyActive].name;
|
||||
if (particles[currentlyActive].TryGetComponent<ParticleHandler>(out ParticleHandler handler))
|
||||
{
|
||||
handler.Cast();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ActivateNext()
|
||||
{
|
||||
if (currentlyActive + 1 >= particles.Count)
|
||||
{
|
||||
particles[currentlyActive].SetActive(false);
|
||||
currentlyActive = 0;
|
||||
particles[currentlyActive].SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
particles[currentlyActive].SetActive(false);
|
||||
currentlyActive++;
|
||||
particles[currentlyActive].SetActive(true);
|
||||
}
|
||||
|
||||
PostUpdateLogic();
|
||||
}
|
||||
|
||||
public void ActivatePrevious()
|
||||
{
|
||||
if (currentlyActive - 1 < 0)
|
||||
{
|
||||
particles[currentlyActive].SetActive(false);
|
||||
currentlyActive = (particles.Count - 1);
|
||||
particles[currentlyActive].SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
particles[currentlyActive].SetActive(false);
|
||||
currentlyActive--;
|
||||
particles[currentlyActive].SetActive(true);
|
||||
}
|
||||
|
||||
PostUpdateLogic();
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
{
|
||||
ActivatePrevious();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.W))
|
||||
{
|
||||
ActivateNext();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
|
||||
if (particles[currentlyActive].TryGetComponent<ParticleSystem>(out ParticleSystem ps))
|
||||
{
|
||||
ps.Play();
|
||||
}
|
||||
PostUpdateLogic() ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
18
Assets/Piloto Studio/Scripts/ParticleShowcase.cs.meta
Normal file
18
Assets/Piloto Studio/Scripts/ParticleShowcase.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: effabd88fdbf01745babd2bcc8bebf68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 349430
|
||||
packageName: Ultimate Loot VFX Pack - 199 Effects
|
||||
packageVersion: 1.0
|
||||
assetPath: Assets/Piloto Studio/Scripts/ParticleShowcase.cs
|
||||
uploadId: 846416
|
||||
Reference in New Issue
Block a user