public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { if (!state.playing || state.deltaTime == 0) { return; } float threshold = vfxValues.GetFloat(velocityThresholdPropertyId); Vector3 pos = vfxValues.GetVector3(positionPropertyId); float dist = Vector3.Magnitude(m_OldPosition - pos); if (threshold <= 0.0f || dist < threshold * state.deltaTime) { float count = dist * vfxValues.GetFloat(ratePerUnitPropertyId); if (vfxValues.GetBool(clampToOnePropertyId)) { count = Mathf.Min(count, 1.0f); } state.spawnCount += count; state.vfxEventAttribute.SetVector3(oldPositionAttributeId, m_OldPosition); state.vfxEventAttribute.SetVector3(positionAttributeId, pos); } m_OldPosition = pos; }
static internal VFXExpressionValues CreateExpressionValuesWrapper(IntPtr ptr) { var expressionValue = new VFXExpressionValues(); expressionValue.m_Ptr = ptr; return(expressionValue); }
public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { // Evaluate Loop Count only when hitting start; // LoopCount < 0 means infinite mode // LoopCount == 0 means no spawn m_LoopMaxCount = vfxValues.GetInt(loopCountPropertyID); m_WaitingForTotalTime = vfxValues.GetFloat(loopDurationPropertyID); m_LoopCurrentIndex = 0; if (m_LoopMaxCount == m_LoopCurrentIndex) { state.playing = false; } }
public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { if (m_LoopCurrentIndex != m_LoopMaxCount && state.totalTime > m_WaitingForTotalTime) { if (state.playing) { m_WaitingForTotalTime = state.totalTime + vfxValues.GetFloat(delayPropertyID); state.playing = false; //We are in playing state, if m_LoopCurrentIndex + 1 == m_LoopMaxCount, we have finished here m_LoopCurrentIndex = m_LoopCurrentIndex + 1 > 0 ? m_LoopCurrentIndex + 1 : 0; //It's possible to count to infinite if m_LoopMaxCount < 0, this ternary avoid stop going back to zero } else { m_WaitingForTotalTime = vfxValues.GetFloat(loopDurationPropertyID); state.totalTime = 0.0f; state.playing = true; //We are in not playing state, we was waiting for the moment when restart will be launch } } }
public sealed override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { }
public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { m_OldPosition = vfxValues.GetVector3(positionPropertyId); }
public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { state.vfxEventAttribute.SetFloat(spawnTimeID, state.totalTime); }
public abstract void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent);
public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { }
public override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { m_Index = (m_Index + 1) % Math.Max(1, vfxValues.GetUInt(stripMaxCountID)); state.vfxEventAttribute.SetUint(stripIndexID, m_Index); }
public sealed override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { m_LoopCurrentIndex = m_LoopMaxCount; }