r2mods/ilspy_dump/ror2_csproj/RoR2/DetachTrailOnDestroy.cs

33 lines
662 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
using UnityEngine.Serialization;
namespace RoR2;
public class DetachTrailOnDestroy : MonoBehaviour
{
[FormerlySerializedAs("trail")]
public TrailRenderer[] targetTrailRenderers;
[SerializeField]
[Tooltip("Use this to disable the script from functioning.")]
private bool IgnoreDestroy;
private void OnDestroy()
{
if (IgnoreDestroy)
{
return;
}
for (int i = 0; i < targetTrailRenderers.Length; i++)
{
TrailRenderer trailRenderer = targetTrailRenderers[i];
if ((bool)trailRenderer)
{
trailRenderer.transform.SetParent(null);
trailRenderer.autodestruct = true;
}
}
targetTrailRenderers = null;
}
}