public Receiver(Breathe script, List <string> atoms, int index, bool rightSide)
            {
                this.index = index;

                script.CreateSpacer(rightSide);

                vartrigChooser = new JSONStorableStringChooser("receiver" + index, atoms, "", "Variable Trigger " + index);
                vartrigChooser.setCallbackFunction += (string atomId) => {
                    Atom         atom     = script.GetAtomById(atomId);
                    JSONStorable storable = (atom != null) ? storable = atom.GetStorableByID("Trigger") : null;
                    vartrig = (storable != null) ? storable.GetFloatJSONParam("value") : null;
                };
                script.CreateScrollablePopup(vartrigChooser, rightSide);
                script.RegisterStringChooser(vartrigChooser);

                List <string> modes = new List <string>()
                {
                    "Out+In", "OutHold", "InHold", "OutInSmooth", "OutSmooth", "InSmooth"
                };

                blendModeChooser = new JSONStorableStringChooser("mode" + index, modes, modes[blendMode], "Mode " + index);
                blendModeChooser.setCallbackFunction += (string modeName) => {
                    blendMode = modes.FindIndex((string entry) => { return(entry == modeName); });
                };
                script.CreateScrollablePopup(blendModeChooser, rightSide);
                script.RegisterStringChooser(blendModeChooser);

                offsetStart = script.SetupSlider("Time Offset Start " + index, 0.0f, -0.5f, 0.5f, rightSide);
                offsetEnd   = script.SetupSlider("Time Offset End " + index, 0.0f, -0.5f, 2.0f, rightSide);
                power       = script.SetupSlider("Power " + index, 1.0f, 0.0f, 1.0f, rightSide);
            }
            public void Update(Breathe script)
            {
                if (vartrig == null)
                {
                    return;
                }

                float os = offsetStart.val;
                float oe = offsetEnd.val;
                float t  = 0.0f;

                switch (blendMode)
                {
                case BlendMode_OutIn:
                    t = script.BlendOutIn(os, os, oe, oe);
                    break;

                case BlendMode_OutHold:
                    t = script.BlendOut(os, oe, 0.25f);
                    break;

                case BlendMode_InHold:
                    t = script.BlendIn(os, oe, 0.25f);
                    break;

                case BlendMode_OutInSmooth:
                    t = script.BlendOutInSmooth(os, oe);
                    break;

                case BlendMode_OutSmooth:
                    t = script.BlendOutSmooth(os, oe);
                    break;

                case BlendMode_InSmooth:
                    t = script.BlendInSmooth(os, oe);
                    break;
                }

                float p = (script.breatheIntensity * 0.5f + 0.5f) * script.breathePower * power.val;

                p           = Mathf.Clamp01(p);
                t           = Mathf.SmoothStep(0.0f, p, t);
                vartrig.val = t;
            }