- Home /
How can i access the Image renderer?
I am trying to access the new -4.6- UI.Image renderer, but with no luck, is there anyway to do so? i don't need the renderer i just need the renderer.bounds so if there is an alternative way i'll be thankful, thank you.
Answer by ninjanoel · Dec 30, 2014 at 08:06 PM
In a monobehaviour, you can declare a public variable of the type you need to access, then in the editor, drag the object with the renderer you want to access, over the exposed variable (declaring it public in c# exposes the var as settable in the unity editor when you add that component to a game object)
If it's the current game object's renderer, just drag it all the same.
Example.
add this to C# :
public UnityEngine.Renderer theRenderer;
then this will appear in the inspector in the unity editor (except default value is 'none')
and then drag the highlight object (in my example this is what I dragged onto it)