void Awake()
 {
     if (_vfxGraph == null)
     {
         _vfxGraph = GetComponent <UnityEngine.VFX.VisualEffect>();
     }
 }
 public override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
 }
 public abstract void OnStop(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 override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     m_Index = 0;
 }
 public sealed override void OnStop(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent)
 {
     m_LoopCurrentIndex = m_LoopMaxCount;
 }
 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 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;
     }
 }
        private static void InvokeOutputEventReceived_Internal(VisualEffect source, int eventNameId)
        {
            var evt = new VFXOutputEventArgs(eventNameId, source.m_cachedEventAttribute);

            source.outputEventReceived.Invoke(evt);
        }
        private static VFXEventAttribute InvokeGetCachedEventAttributeForOutputEvent_Internal(VisualEffect source)
        {
            //If outputEventReceived is null, skip this behavior, InvokeOutputEventReceived_Internal will be not triggered
            if (source.outputEventReceived == null)
            {
                return(null);
            }

            if (source.m_cachedEventAttribute == null)
            {
                source.m_cachedEventAttribute = source.CreateVFXEventAttribute();
            }
            return(source.m_cachedEventAttribute);
        }