public override void Update() { base.Update(); if (_mTime == DateTime.MinValue) { return; } float time = (float)(DateTime.Now - _mTime).TotalSeconds; float nextTime = GetTime(_mCurrentFrame); if (nextTime < time) { ++_mCurrentFrame; if (_mCurrentFrame < _mEffects.Count) { if (!_mIsPaused && ChromaConnectionManager.Instance.Connected) { //Debug.Log("SetEffect."); EffectResponseId effect = _mEffects[_mCurrentFrame]; if (null != effect) { ChromaUtils.SetEffect(effect.Id); } /* * //Silently fail * if (null != effect) * { * EffectIdentifierResponse result = ChromaUtils.SetEffect(effect.Id); * if (null == result || * result.Result != 0) * { * Debug.LogError("Failed to set effect!"); * } * } * else * { * Debug.LogError("Failed to set effect!"); * } */ } } else { //UE_LOG(LogTemp, Log, TEXT("UChromaSDKPluginAnimation2DObject::Tick Animation Complete.")); _mIsPlaying = false; _mTime = DateTime.MinValue; //reset _mCurrentFrame = 0; // execute the complete event if set if (null != _mOnComplete) { _mOnComplete.Invoke(this); } } } }
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); } } } }
/// <summary> /// Play the animation and fire the OnComplete event /// </summary> /// <param name="onComplete"></param> public void PlayWithOnComplete(ChomaOnComplete2D onComplete) { //Debug.Log("PlayWithOnComplete"); if (!_mIsLoaded) { // auto load if not loaded Load(); //Debug.LogError("Animation has not been loaded!"); //return; } _mOnComplete = onComplete; _mTime = DateTime.Now; //Time when animation started _mIsPlaying = true; _mCurrentFrame = 0; if (_mCurrentFrame < _mEffects.Count) { if (!_mIsPaused && ChromaConnectionManager.Instance.Connected) { //Debug.Log("SetEffect."); EffectResponseId effect = _mEffects[_mCurrentFrame]; if (null != effect) { ChromaUtils.SetEffect(effect.Id); } /* * //Silently fail * if (null != effect) * { * EffectIdentifierResponse result = ChromaUtils.SetEffect(effect.Id); * if (null == result || * result.Result != 0) * { * Debug.LogError("Failed to set effect!"); * } * } * else * { * Debug.LogError("Failed to set effect!"); * } */ } } }
/// <summary> /// Play the animation /// </summary> public override void Play() { //Debug.Log("Play"); if (!_mIsLoaded) { Load(); //Debug.LogError("Play Animation has not been loaded!"); //return; } // clear on play to avoid unsetting on a loop _mOnComplete = null; _mTime = DateTime.Now; //Time when animation started _mIsPlaying = true; _mCurrentFrame = 0; if (_mCurrentFrame < _mEffects.Count) { if (!_mIsPaused && ChromaConnectionManager.Instance.Connected) { //Debug.Log("SetEffect."); EffectResponseId effect = _mEffects[_mCurrentFrame]; if (null != effect) { ChromaUtils.SetEffect(effect.Id); } /* * //Silently fail * if (null != effect) * { * EffectIdentifierResponse result = ChromaUtils.SetEffect(effect.Id); * if (null == result || * result.Result != 0) * { * Debug.LogError("Failed to set effect!"); * } * } * else * { * Debug.LogError("Failed to set effect!"); * } */ } } }
public void Play() { if (!this._mIsLoaded) { Debug.LogError("Play Animation has not been loaded!"); return; } this._mOnComplete = null; this._mTime = DateTime.Now; this._mIsPlaying = true; this._mCurrentFrame = 0; if (this._mCurrentFrame < this._mEffects.Count && !this._mIsPaused && ChromaConnectionManager.Instance.Connected) { EffectResponseId effectResponseId = this._mEffects[this._mCurrentFrame]; if (effectResponseId != null) { ChromaUtils.SetEffect(effectResponseId.Id); } } }
public override void Update() { base.Update(); if (this._mTime == DateTime.MinValue) { return; } float num = (float)(DateTime.Now - this._mTime).TotalSeconds; float time = this.GetTime(this._mCurrentFrame); if (time < num) { this._mCurrentFrame++; if (this._mCurrentFrame < this._mEffects.Count) { if (!this._mIsPaused && ChromaConnectionManager.Instance.Connected) { EffectResponseId effectResponseId = this._mEffects[this._mCurrentFrame]; if (effectResponseId != null) { ChromaUtils.SetEffect(effectResponseId.Id); } } } else { this._mIsPlaying = false; this._mTime = DateTime.MinValue; this._mCurrentFrame = 0; if (this._mOnComplete != null) { this._mOnComplete(this); } } } }