在C#Unity3D中,是否有其他方法可以在Texture2D的样条线内外进行绘制?

在C#Unity3D中,是否有其他方法可以在Texture2D的样条线内外进行绘制?,c#,unity3d,C#,Unity3d,我想拍这张照片。 为了实现这一点,我配置了这段代码 Texture2D texture2D = new Texture2D(Width, Height); float step = (Width - Min_x) / (float)Height; for (int y=0;y<Height;y++) { //max = The last x coordinate inside the area at

我想拍这张照片。

为了实现这一点,我配置了这段代码

        Texture2D texture2D = new Texture2D(Width, Height);
        float step = (Width - Min_x) / (float)Height;
        for (int y=0;y<Height;y++)
        {
            //max = The last x coordinate inside the area at the current y coordinate
            int max = (int)(Min_x + (step * y));
            for(int x=0;x<Width;x++)
            {
                Color color =
                    x>max? //=Area Outside
                    Color.clear:
                    //=Area Inside. Divide the border and non-border areas.
                    y < border || //Down Border
                    y >= Height - border || //Up Border
                    x < border || //Left Border
                    x > max - border ? //Right Border
                    Color.red : new Color(1, 1, 1, A_Channel/255f);
                texture2D.SetPixel(x, y, color);
            }
        }
        texture2D.Apply();
        Target.texture = texture2D;
Texture2D Texture2D=新的Texture2D(宽度、高度);
浮动台阶=(宽度-最小值x)/(浮动)高度;
对于(int y=0;y=Height-border | |//上边框)
x最大边框?//右边框
颜色。红色:新颜色(1,1,1,A_通道/255f);
纹理2d.SetPixel(x,y,颜色);
}
}
texture2D.Apply();
Target.texture=texture2D;
此代码显示这些结果

这个结果意味着y值为0,而for语句中的x值是宽度日期意图的结果(而不是颜色.Clear,即使它在区域之外)

为了纠正这个问题,我设置了像素的颜色 指定y值时,我将临时颜色设置为color.Clear。

y==0的底部部分仍然是彩色的。y值为负值的部分已自动更改颜色,即使我没有指定它

目标矩形变换的大小 它与您拥有的纹理2D的大小相匹配。 有什么我遗漏了吗?作为显示图像的一部分,RAWMIMAGE或image显示相同的结果