根据我的理解应该是读取材质的颜色数组,并根据数组中的透明度一值对颜色数组进行筛选
List
{
//读取材质
Texture2D lTex = lines.renderer.sharedMaterial.mainTexture as Texture2D;
Color[] texColors = lTex.GetPixels();
//使用初始化,即,将颜色调节位白色+100%透明
if (clear)
colors32.Clear();
for (int y = 0; y < lTex.height; ++y)
for (int x = 0; x < lTex.width; ++x)
{
if (clear)
{
//如果clear为true,添加背景颜色
colors32.Add(backgroundColor);
//如果材质的颜色透明度大于0.5(半透明),则添加到color32数组中,即根据筛选材质颜色透明度大于0.5的值
if (texColors[y * texWidth + x].a > 0.5f)
colors32[colors32.Count - 1] = texColors[y * texWidth + x];
}
else
{
同上
if (texColors[y * texWidth + x].a > 0.5f)
colors32[y * texWidth + x] = texColors[y * texWidth + x];
}
}
//返回根据透明度筛选过后的像素颜色数组
return colors32;
}