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.
63 lines
2.3 KiB
63 lines
2.3 KiB
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;";
|
|
}
|
|
}
|
|
}
|
|
}
|