Exemplo n.º 1
0
        private void UpdatePreview()
        {
            if (_Clip == null)
            {
                _Data.Reset();
                DestroyPreviewTexture();
            }
            else
            {
                ValidateTime();
                if (_PreviewTexture == null)
                {
                    _PreviewTexture = new Texture2D(_TextureWidth, _TextureHeight, TextureFormat.RGBA32, false);
                }
                _Data.Build(_Clip, _TextureWidth, _StartTime, _EndTime);

                if (_BackgroundColors == null)
                {
                    _BackgroundColors = new Color[_TextureWidth * _TextureHeight];
                    for (int ci = 0; ci < _BackgroundColors.Length; ci++)
                    {
                        _BackgroundColors[ci] = _BackgroundColor;
                    }
                }
                _PreviewTexture.SetPixels(_BackgroundColors);


                _HalfHeight = _TextureHeight / 2;
                int preY = _HalfHeight;
                for (int i = 0; i < _TextureWidth; i++)
                {
                    int min = (int)(_Data.MinCurve.Evaluate(i) * _TextureHeight);
                    int max = (int)(_Data.MaxCurve.Evaluate(i) * _TextureHeight);

                    for (int j = min; j <= max; j++)
                    {
                        _PreviewTexture.SetPixel(i, j, GetColor(j));
                    }
                    if (preY < min)
                    {
                        for (int j = preY; j <= min; j++)
                        {
                            _PreviewTexture.SetPixel(i, j, GetColor(j));
                        }
                        preY = max;
                    }
                    else if (preY > max)
                    {
                        for (int j = max; j <= preY; j++)
                        {
                            _PreviewTexture.SetPixel(i, j, GetColor(j));
                        }
                        preY = min;
                    }
                }
                _PreviewTexture.Apply();
            }
            _Changed = false;
        }
Exemplo n.º 2
0
 private void UpdatePreview()
 {
     if (_Clip == null)
     {
         _Data.Reset();
     }
     else
     {
         ValidateTime();
         _Data.Build(_Clip, _Resolution, _StartTime, _EndTime);
     }
     _Changed = false;
 }