You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
1 year ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.VFX;
|
||
|
|
||
|
[RequireComponent(typeof(VisualEffect))]
|
||
|
|
||
|
public class ToggleFireVFXGraph : MonoBehaviour
|
||
|
{
|
||
|
|
||
|
public KeyCode toggleKey = KeyCode.Space;
|
||
|
private bool isPlaying = true;
|
||
|
|
||
|
private VisualEffect fireVFX;
|
||
|
public VisualEffect igniteVFX;
|
||
|
public VisualEffect extinguishVFX;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
fireVFX = GetComponent<VisualEffect>();
|
||
|
if (igniteVFX != null)
|
||
|
igniteVFX.Stop();
|
||
|
if (extinguishVFX != null)
|
||
|
extinguishVFX.Stop();
|
||
|
}
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
if (Input.GetKeyDown(toggleKey))
|
||
|
{
|
||
|
if(isPlaying)
|
||
|
{
|
||
|
isPlaying = !isPlaying;
|
||
|
fireVFX.Stop();
|
||
|
if (extinguishVFX != null)
|
||
|
extinguishVFX.Play();
|
||
|
} else
|
||
|
{
|
||
|
isPlaying = !isPlaying;
|
||
|
fireVFX.Play();
|
||
|
if (igniteVFX != null)
|
||
|
igniteVFX.Play();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|