- Home /
Is a texture visible
I have some code which automatically updates a texture by modifying its pixels. For performance reasons, I don't want to do this if the texture is not actually visible on any game objects.
Is there any way to determine this programatically without explicitly notifying my update script of each item that uses the texture?
Answer by BiG · Apr 23, 2012 at 05:49 PM
Could OnBecameVisible be useful to your purpose? I've never used that, so it's just an advice.
That's what I'll have to do if there's no way to get it directly from the texture. I have 1 texture which gets updated in 1 script, and then another script which displays that texture on different game objects. I could just make a visible instance counter, and whenever any of the display scripts become visible I increment the counter, and then decrement when it's no longer visible. Then I can avoid updating the texture if the visible count == 0. But I was hoping for a more straight-forward approach.
Your answer
Follow this Question
Related Questions
How to get a Texture asset that is in the project and pass it to a function? 3 Answers
PackTextures Horizontally? (1 Row) or Alternative Method 1 Answer
How can I combine 4 textures into one bigger texture at runtime? 1 Answer
Procedurally combine (merge) two Texture2D 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers