My Dynamically create Textures are showing up white until i play with the inspector
Asked Answered
J

3

0

Hello I have an odd problem,

I am creating players for a soccer game with dynamically created textures for jumpers

When they get created the Texture shows as white, but if i tick and untick the "enable Detail texture" flag it renders fine showing that the texture was created properly, (Pictures below to explain further)

I assume a redraw call gets made when you fiddle with the inspector but i'm unsure how to leverage that.

Thanks for reading, any advice is greatly appreciated :D

![132955-dyn2.png|1500x1024](upload://19V6pcNJIHBPbx8XV1ZhHpg2VDw.png)
Jongjongleur answered 7/11, 2023 at 18:50 Comment(0)
A
0

I’m not very familiar with the shader you’re using, but an initial look around online suggests that it is multi-compiled to use two variants with the Detail Texture enabled or disabled.

Based on that, because you’re toggling that shader flag back to “on” it updates which variant of the shader it’s using.

With all of this in mind, you should be able to solve your problem at the same time you assign the procedural Texture to the Material by enabling the Keyword in the shader.

// When you assign the Texture to the Material...
// I don't know what yours looks like, so here's an
// approximate guess.
myMaterial.mainTexture = myNewTexture;

// Then, to tell the Material that you want to use it,
// assuming you're using the shader I came across...
myMaterial.EnableKeyword("_TEX_ON");
Antares answered 11/2, 2019 at 5:7 Comment(1)

Thank you so much for your quick reply, Worked perfectly!!! i have added the snippet below just in case anyone else has the issue i had. Debug.Log("Create a jumper"); GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = new Vector3(0,0, 0); cube.GetComponentInChildren<Renderer>().material = makeMat(pname,number); cube.GetComponentInChildren<MeshRenderer>().material.EnableKeyword("_TEX_ON"); Thanks again!!

Jongjongleur
O
0

Hello this is happening when we change the texture of the 2d raw image it is displaying white, if anything changing then it is displaying. what should be going when this happens in 2d Raw image texture change?
Thanks

Osiris answered 28/1, 2022 at 10:4 Comment(0)
S
0

I was having the exact same issue. I was missing a texture.Apply() call after making changes to the texture.

Sitwell answered 7/11, 2023 at 18:5 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.