// Update is called once per frame
    void Update()
    {
        if (!CoreReTime)
        {
            CoreReTime = GetComponent <ReTime> ();
        }

        //if the PS is looping, trigger the LOOP TRACKER
        if (Particles.main.loop)
        {
            ParticleSystemLoopTracker();
        }

        //if stopped emitting and not rewinding, count the delta time
        if (!CoreReTime.isRewinding)
        {
            init = true;
            //if particle system is dead, start counting
            if (!Particles.IsAlive())
            {
                PassedTime += Time.deltaTime;
            }

            //if particle system is looping, then count along side
            if (Particles.main.loop)
            {
                LoopingTime += Time.deltaTime;
            }
        }
        else
        {
            //if rewinding, minus the passed delta time with current delta time
            PlaybackTime = Particles.time;
            PassedTime  -= Time.deltaTime;
            Particles.Stop();
            init = false;

            //the PS is in loop or not
            if (Particles.main.loop)
            {
                if (PSLoops > 0)
                {
                    if (PlaybackTime <= ResettingPoint)
                    {
                        PlaybackTime = MaxTime;
                        PSLoops--;
                    }
                }
                Particles.Simulate(PlaybackTime - Time.deltaTime);
            }
            else
            {
                //when the passed time is zero, play the simulation in reverse
                if (PassedTime <= 0.0f)
                {
                    Particles.Simulate(PlaybackTime - Time.deltaTime);
                }
            }
        }
    }
    public override void OnInspectorGUI()
    {
        GUILayout.Box(Resources.Load("ReTime Cover") as Texture, GUILayout.Width(375), GUILayout.Height(200));
        ReTime script = (ReTime)target;

        GUILayout.Label("You can [ StartTimeRewind() ] and [ StopTimeRewind() ] manually in code");

        //vars
        script.RewindSeconds   = EditorGUILayout.FloatField(new GUIContent("Rewind Seconds", "The amount of time to rewind in seconds"), script.RewindSeconds);
        script.RewindSpeed     = EditorGUILayout.Slider(new GUIContent("Rewind Speed", "The speed scale float in which the rewind will play at. From 0.1 - 5.0"), script.RewindSpeed, 0.1f, 5f);
        script.UseInputTrigger = EditorGUILayout.Toggle(new GUIContent("Use Input Trigger", "Enabling this will let you use a key trigger. If disabled, then you can use the StartRewind() and StopRewind() methods"), script.UseInputTrigger);

        EditorGUI.BeginDisabledGroup(script.UseInputTrigger == false);
        script.KeyTrigger = EditorGUILayout.TextField(new GUIContent("Key Trigger", "Type the key name of trigger. Check the PDF for more info"), script.KeyTrigger);
        EditorGUI.EndDisabledGroup();

        script.PauseEnd = EditorGUILayout.Toggle(new GUIContent("Pause on End", "Enabling this will pause everything at the end of the rewind"), script.PauseEnd);
    }