I created a billboardAsset using the code below, gave it a material with an image on it, and then placed a billboardRenderer in the world to make the image appear, but the billboard remains invisible. I think that I might be assigning the texture coordinates incorrectly, but I'm not sure.
Code: Select all
BillboardAsset billboard = new BillboardAsset();
billboard.height = height;
billboard.width = width;
Vector2[] vec = new Vector2[4];
vec[0] = new Vector2(0,0);
vec[1] = new Vector2(1, 0);
vec[2] = new Vector2(0, 1);
vec[3] = new Vector2(1, 1);
billboard.SetVertices(vec);
ushort[] ind = new ushort[6];
ind[0] = 0;
ind[1] = 1;
ind[2] = 2;
ind[3] = 1;
ind[4] = 2;
ind[5] = 3;
billboard.SetIndices(ind);
Vector4[] texCoord = new Vector4[1];
texCoord[0] = new Vector4(1, 1, 1, 1);
billboard.SetImageTexCoords(texCoord);
AssetDatabase.CreateAsset(billboard, "Assets/Scripts/Game/Entities_2/Bill.asset");