Example #1
0
    protected override void OnClickPreviewButton()
    {
        ChromaSDKAnimation1D animation = GetAnimation();

        EditorUtility.SetDirty(animation);
        var frames = animation.Frames; //copy

        Unload();

        if (ChromaConnectionManager.Instance.Connected)
        {
            if (_mCurrentFrame >= 0 &&
                _mCurrentFrame < frames.Count)
            {
                ChromaDevice1DEnum device = animation.Device;
                EffectArray1dInput colors = frames[_mCurrentFrame];
                EffectResponseId   effect = ChromaUtils.CreateEffectCustom1D(device, colors);
                if (null != effect &&
                    effect.Result == 0)
                {
                    ChromaUtils.SetEffect(effect.Id);
                    ChromaUtils.RemoveEffect(effect.Id);
                }
            }
        }
    }
 public void Unload()
 {
     if (!this._mIsLoaded)
     {
         Debug.LogError("Animation has already been unloaded!");
         return;
     }
     for (int i = 0; i < this._mEffects.Count; i++)
     {
         EffectResponseId effectResponseId = this._mEffects[i];
         if (effectResponseId != null)
         {
             ChromaUtils.RemoveEffect(effectResponseId.Id);
         }
     }
     this._mEffects.Clear();
     this._mIsLoaded = false;
 }
    /// <summary>
    /// Unload the effects
    /// </summary>
    public override void Unload()
    {
        //Debug.Log("Unload:");

        if (!_mIsLoaded)
        {
            //Debug.LogError("Animation has already been unloaded!");
            return;
        }

        for (int i = 0; i < _mEffects.Count; ++i)
        {
            EffectResponseId effect = _mEffects[i];
            if (null != effect)
            {
                ChromaUtils.RemoveEffect(effect.Id);
            }

            /*
             * //Silently fail
             * if (null != effect)
             * {
             *  //Debug.Log("RemoveEffect.");
             *  EffectIdentifierResponse result = ChromaUtils.RemoveEffect(effect.Id);
             *  if (null == result ||
             *      result.Result != 0)
             *  {
             *      Debug.LogError("Failed to delete effect!");
             *  }
             * }
             * else
             * {
             *  Debug.LogError("Failed to delete effect!");
             * }
             */
        }
        _mEffects.Clear();
        _mIsLoaded = false;
    }