UnityEngine.Gradient.Evaluate C# (CSharp) Method

Evaluate() public method

Calculate color at a given time.

public Evaluate ( float time ) : Color
time float Time of the key (0 - 1).
return Color
        public Color Evaluate(float time)
        {
            Color color;
            INTERNAL_CALL_Evaluate(this, time, out color);
            return color;
        }

Usage Example

コード例 #1
1
ファイル: TextureE.cs プロジェクト: rickoskam/ShepherdGame
        /// <summary>
        /// Draws gradient rectangle on texture
        /// </summary>t
        public static void DrawGradientRect(this Texture2D texture, int x, int y, int blockWidth, int blockHeight,
            Gradient gradient, Directions progressionDirection)
        {
            Func<int, int, Color> getColor;
            switch (progressionDirection)
            {
                case Directions.Left:
                    getColor = (_x, _y) => gradient.Evaluate(1 - (float) _x/(float) blockWidth);
                    break;
                case Directions.Right:
                    getColor = (_x, _y) => gradient.Evaluate((float) _x/(float) blockWidth);
                    break;
                case Directions.Down:
                    getColor = (_x, _y) => gradient.Evaluate(1 - (float) _y/(float) blockHeight);
                    break;
                case Directions.Up:
                    getColor = (_x, _y) => gradient.Evaluate((float) _y/(float) blockHeight);
                    break;
                default:
                    Debug.LogError("Not supported direction: " + progressionDirection);
                    return;
            }

            var colors = new Color[blockWidth*blockHeight];
            for (int _y = 0; _y < blockHeight; _y++)
            {
                for (int _x = 0; _x < blockWidth; _x++)
                {
                    colors[_x + _y*blockWidth] = getColor(_x, _y);
                }
            }
            texture.SetPixels(x, y, blockWidth, blockHeight, colors);
        }
All Usage Examples Of UnityEngine.Gradient::Evaluate