该项目的目的是同时测试和演示来自 Unity DOTS 技术堆栈的多个新包。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

46 行
1.7 KiB

using UnityEngine;
using UnityEngine.VFX;
public class CancelByDistance : VFXSpawnerCallbacks
{
public class InputProperties
{
[Tooltip("Position that will be compared to the \"position\" EventAttribute")]
public Vector3 CheckPosition = Vector3.zero;
[Tooltip("Distance from which the spawn will be canceled")]
public float MaxDistance = 32.0f;
[Tooltip("Invert Check : if true will cancel particles that are closer than the MaxDistance instead of those farther")]
public bool InvertCheck = false;
}
static readonly int AttribPositionID = Shader.PropertyToID("position");
static readonly int CheckPositionID = Shader.PropertyToID("CheckPosition");
static readonly int MaxDistanceID = Shader.PropertyToID("MaxDistance");
static readonly int InvertCheckID = Shader.PropertyToID("InvertCheck");
public override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
{
}
public override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
{
}
public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
{
Vector3 checkPosition = vfxValues.GetVector3(CheckPositionID);
float maxDistance = vfxValues.GetFloat(MaxDistanceID);
bool InvertCheck = vfxValues.GetBool(InvertCheckID);
Vector3 position = state.vfxEventAttribute.GetVector3(AttribPositionID);
bool test = (checkPosition - position).sqrMagnitude > (maxDistance*maxDistance);
if (test != InvertCheck)
{
state.spawnCount = 0;
}
}
}