UnityEditor.Brush.Load C# (CSharp) Method

Load() public method

public Load ( Texture2D brushTex, int size ) : bool
brushTex UnityEngine.Texture2D
size int
return bool
        public bool Load(Texture2D brushTex, int size)
        {
            if (((this.m_Brush == brushTex) && (size == this.m_Size)) && (this.m_Strength != null))
            {
                return true;
            }
            if (brushTex != null)
            {
                float num = size;
                this.m_Size = size;
                this.m_Strength = new float[this.m_Size * this.m_Size];
                if (this.m_Size > 3)
                {
                    for (int j = 0; j < this.m_Size; j++)
                    {
                        for (int k = 0; k < this.m_Size; k++)
                        {
                            this.m_Strength[(j * this.m_Size) + k] = brushTex.GetPixelBilinear((k + 0.5f) / num, ((float) j) / num).a;
                        }
                    }
                }
                else
                {
                    for (int m = 0; m < this.m_Strength.Length; m++)
                    {
                        this.m_Strength[m] = 1f;
                    }
                }
                Object.DestroyImmediate(this.m_Preview);
                this.m_Preview = new Texture2D(this.m_Size, this.m_Size, TextureFormat.RGBA32, false);
                this.m_Preview.hideFlags = HideFlags.HideAndDontSave;
                this.m_Preview.wrapMode = TextureWrapMode.Repeat;
                this.m_Preview.filterMode = FilterMode.Point;
                Color[] colors = new Color[this.m_Size * this.m_Size];
                for (int i = 0; i < colors.Length; i++)
                {
                    colors[i] = new Color(1f, 1f, 1f, this.m_Strength[i]);
                }
                this.m_Preview.SetPixels(0, 0, this.m_Size, this.m_Size, colors, 0);
                this.m_Preview.Apply();
                if (this.m_BrushProjector == null)
                {
                    this.CreatePreviewBrush();
                }
                this.m_BrushProjector.material.mainTexture = this.m_Preview;
                this.m_Brush = brushTex;
                return true;
            }
            this.m_Strength = new float[] { 1f };
            this.m_Size = 1;
            return false;
        }
    }