Properties {
        _R("Radius", Range(0,100)) = 1.0
     _ColorTex("ColorTex (RGB)", 2D) = "red" {}
}
SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 200
        Cull off
。。。。

        half _R;
    sampler2D _ColorTex;

Texture2D colorTxt = new Texture2D(size, size);
Color[] colors = new Color[10]{
Color.black, Color.white,
Color.yellow , Color.gray ,
Color.green , Color.grey ,
Color.blue,Color.red,
Color.magenta,Color.cyan};
for (int j = 0; j != size; j++)
{
for (int i = 0; i != size; ++i)
{
colorTxt.SetPixel(i, j, colors[j]);
}
}
colorTxt.Apply();
gameObject.GetComponent<MeshRenderer>().material.SetFloat("_R", R);
gameObject.GetComponent<MeshRenderer>().material.SetTexture("_ColorTex", colorTxt);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2021-03-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2021-05-25
  • 2022-12-23
  • 2021-04-21
  • 2021-04-10
  • 2022-12-23
相关资源
相似解决方案