Is it possible to copy one texture into a particular location within another texture? I see there is a Blit function, but it doesn’t have a source/dest rect parameter.
Basically, I have one texture that is a blank paper and I need to draw symbols on it. So I need to be able to copy the entire (small) symbol texture into a specified rect of the paper texture. Can that be done with a script?
Thanks, but that’s not exactly what I had in mind. That is for setting one pixel at a time. I’m talking about copying a section of one bitmap into another. I guess I could write something that used GetPixel and SetPixel to do the copying, but it seems like a roundabout way of doing it.
I would also like to be able to draw primitives in a texture bitmap, like lines or ovals, which would be very difficult (for me) doing it one pixel at a time.
That worked like a charm, sort of. If I select the texture in the Project window and look at it in the Inspector, I can see that it was drawn on as it should be. But if I select the object that the texture is applied to and view that texture in the Inspector, I see the original, unmodified texture. And I can’t see any change in the texture in the scene.
I did an Apply after modifiying the texture, but do I need to somehow reapply the texture to the object? It seems there is one more step I am missing, but can’t figure out what that might be.
This is the gist of it (without the part that calculates the coordinates):
var pMember: Texture2D;
var tMember: Texture2D;
var dotColors: Color[];
var halfWidth: float;
var halfHeight: float;
var xx: int;
var yy: int;
dotColors = tMember.GetPixels(0);
pMember.SetPixels(xx - halfWidth, yy - halfHeight, tMember.width, tMember.height, dotColors, 0);
pMember.Apply( );
renderer.material.mainTexture = pMember;
It is basically a graph, plotting small symbols on a large white background.
I’ve also tried using renderer.material.mainTexture instead of defining pMember as the texture, and that doesn’t work either. I can see the texture changed in the project window, but the texture attached to the object does not change.
I just realized that I can do what I need to with a GUI Texture object. Only thing I can’t figure out is how to hide and show it. There’s a check box at the top of the inspector for the GUI Texture that does this, but I don’t know what that corresponds to or how to script it. I tried setting the object’s renderer enabled to false, but it says the GUI Texture does not have a renderer. How can I hide and show a GUI Texture with a script?
“enabled = true/false” The box at the top would be “active = true/false”, but that activates/deactivates the entire object, not just whether it’s visible or not. (In some cases this may be a difference that makes no difference.)