- Home /
Assign Texture2D at runtime
Is it possible to assign a Texture2D that's taken from a screenshot at runtime? When I try this, the assigned texture2d reads "missing" in the inspector...
The texture2d screenshot worked because it successfully arrives at serverside
Brief outline of code:
var tex = new Texture2D( .... ); tex.ReadPixel( ... ); tex.Apply(); assignedTexture2D=tex;
assignedTexture2D shows "missing" in inspector.
Answer by chtngtr · Jun 08, 2011 at 12:58 PM
go through this link it might help you. http://unity3d.com/support/resources/example-projects/texture-plugins.html
It would be a horrible miss on Unity's part if plugin's are required to assign texture2d at runtime.
Answer by jahroy · Jun 09, 2011 at 11:07 PM
I'm not sure what you would expect to see in the inspector...
You're not assigning a named texture to the variable. You're assinging a texture that you built. It has no handle to the file system or the unity editor.
Also, when you make changes to your scene while playing your game, they are typically erased when you come out of play mode.
the inspector shows a missing tag, and the texture displayed shows a question mark.
Ok. I would suggest that showing the actual code will give you the best chance of getting the right answer. Of course I probably won't be the one who will be able to provide it!