UnityEngine.Texture2D.SetPixels C# (CSharp) Method

SetPixels() private method

private SetPixels ( Color colors ) : void
colors Color
return void
        public void SetPixels(Color[] colors)
        {
            int miplevel = 0;
            this.SetPixels(colors, miplevel);
        }

Same methods

Texture2D::SetPixels ( Color colors, [ miplevel ) : void
Texture2D::SetPixels ( int x, int y, int blockWidth, int blockHeight, Color colors ) : void
Texture2D::SetPixels ( int x, int y, int blockWidth, int blockHeight, Color colors, [ miplevel ) : void

Usage Example

コード例 #1
0
    public void CalculateWidget()
    {
        int canvasWidth = FullHeart.width * (_playerHealthSystem.MaxHP / 2);
        int fullHearts = _playerHealthSystem.HP / 2;
        int halfHearts = _playerHealthSystem.HP % 2;
        int deadHearts = (_playerHealthSystem.MaxHP / 2) - (_playerHealthSystem.HP / 2);

        Texture2D tex = new Texture2D(canvasWidth, FullHeart.height);

        int i = 0;

        for(int counter = 0; counter < fullHearts; counter++)
        {
            tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, FullHeart.GetPixels());
            i += FullHeart.width;
        }

        for(int counter = 0; counter < halfHearts; counter++)
        {
            tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, HalfHeart.GetPixels());
            i += FullHeart.width;
        }

        for(int counter = 0; counter < deadHearts; counter++)
        {
            tex.SetPixels(i, 0, FullHeart.width, FullHeart.height, NoHeart.GetPixels());
            i += FullHeart.width;
        }

        tex.Apply();

        _fullUiWidget = tex;
        UiWidget.Image = _fullUiWidget;
    }
All Usage Examples Of UnityEngine.Texture2D::SetPixels