UnityEngine.Graphics.DrawTexture C# (CSharp) 메소드

DrawTexture() 공개 정적인 메소드

public static DrawTexture ( Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, [ mat, [ pass ) : void
screenRect Rect
texture Texture
sourceRect Rect
leftBorder int
rightBorder int
topBorder int
bottomBorder int
mat [
pass [
리턴 void
        public static void DrawTexture(Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, [UnityEngine.Internal.DefaultValue("null")] Material mat, [UnityEngine.Internal.DefaultValue("-1")] int pass)
        {
            InternalDrawTextureArguments arguments = new InternalDrawTextureArguments {
                screenRect = screenRect,
                texture = texture,
                sourceRect = sourceRect,
                leftBorder = leftBorder,
                rightBorder = rightBorder,
                topBorder = topBorder,
                bottomBorder = bottomBorder
            };
            Color32 color = new Color32();
            color.r = color.g = color.b = (byte) (color.a = 0x80);
            arguments.color = color;
            arguments.mat = mat;
            arguments.pass = pass;
            DrawTexture(ref arguments);
        }

Same methods

Graphics::DrawTexture ( InternalDrawTextureArguments &arguments ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, Material mat ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, Material mat ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Color color, [ mat, [ pass ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, Rect sourceRect, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, [ mat, [ pass ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, Material mat ) : void
Graphics::DrawTexture ( Rect screenRect, Texture texture, int leftBorder, int rightBorder, int topBorder, int bottomBorder, [ mat, [ pass ) : void

Usage Example

        private static void SaveResized(Texture2D tex, int width, int height, int x, int y)
        {
            var target     = new Texture2D(width, height, TextureFormat.RGBA32, false);
            var targetData = target.GetRawTextureData <Color32>();
            var clearColor = Color.clear;

            for (int l = 0; l < height; ++l)
            {
                for (int k = 0; k < x; ++k) //left border
                {
                    targetData[l * width + k] = clearColor;
                }
                for (int k = tex.width - x; k < width; ++k) //right border
                {
                    targetData[l * width + k] = clearColor;
                }
            }
            for (int k = x; k < width - x; ++k)
            {
                for (int l = 0; l < y; ++l) //bottom border
                {
                    targetData[l * width + k] = clearColor;
                }
                for (int l = tex.height - y; l < height; ++l) //top border
                {
                    targetData[l * width + k] = clearColor;
                }
            }
            var rt  = RenderTexture.GetTemporary(tex.width, tex.height);
            var rta = RenderTexture.active;

            RenderTexture.active = rt;
            GL.Clear(false, true, Color.clear);
            GL.LoadPixelMatrix(0, 1, 1, 0);
            UnityGraphics.DrawTexture(new Rect(0, 0, 1, 1), tex, MatCopy, 0);//point copy
            target.ReadPixels(new Rect(0, 0, tex.width, tex.height), x, y);
            RenderTexture.active = rta;
            RenderTexture.ReleaseTemporary(rt);
            string projectPath = Application.dataPath.Replace("/Assets", "/");
            string path        = AssetDatabase.GetAssetPath(tex);

            File.WriteAllBytes(projectPath + path, target.EncodeToPNG());
            AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
        }
All Usage Examples Of UnityEngine.Graphics::DrawTexture