Files
CartoonRPG/Library/PackageCache/com.unity.visualeffectgraph@2973a8ac1070/Editor/Models/Deprecated/GPUEventOnDie.cs
Caleb Sandford deQuincey 02c4b5ab66 Adding in new packages
2025-06-05 22:59:18 +01:00

64 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEditor.VFX.Block
{
class GPUEventOnDie : VFXBlock
{
public override void Sanitize(int version)
{
base.Sanitize(version);
var newBlock = ScriptableObject.CreateInstance<TriggerEvent>();
newBlock.SetSettingValue("mode", TriggerEvent.Mode.OnDie);
VFXSlot.CopyLinksAndValue(newBlock.GetInputSlot(0), GetInputSlot(0));
VFXSlot.CopyLinksAndValue(newBlock.GetOutputSlot(0), GetOutputSlot(0));
ReplaceModel(newBlock, this);
}
public override string name { get { return "Trigger Event On Die"; } }
public override VFXContextType compatibleContexts { get { return VFXContextType.Update; } }
public override VFXDataType compatibleData { get { return VFXDataType.Particle; } }
public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(VFXAttribute.Lifetime, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Age, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.Alive, VFXAttributeMode.Read);
yield return new VFXAttributeInfo(VFXAttribute.EventCount, VFXAttributeMode.Write);
}
}
public override IEnumerable<VFXNamedExpression> parameters
{
get
{
foreach (var param in base.parameters)
yield return param;
yield return new VFXNamedExpression(VFXBuiltInExpression.DeltaTime, "deltaTime");
}
}
public class InputProperties
{
[Tooltip("Sets the number of particles spawned via a GPU event when this block is triggered.")]
public uint count = 1u;
}
public class OutputProperties
{
[Tooltip("Outputs a GPU event which can connect to another system via a GPUEvent context. Attributes from the current system can be inherited in the new system.")]
public GPUEvent evt = new GPUEvent();
}
public override string source
{
get
{
return "eventCount = (age + deltaTime > lifetime || !alive) ? count : 0;";
}
}
}
}