Hi,
Sorry for this noob question, probably someone will show me the answer is already somwhere there, but I really can’t find it. How can I reference the UI element that script is attached to? Reason is that I want to use IMGUI scipting functionality on an GUI object that is saved as a prefab that I will instantiate later.
And I found it in one of the tutorials, answer is pretty simple just use:
GetComponentInParent();
1 Like
Just to point something out.
GetComponentInParent(); will get components on gameobjects of the parent gameobject in your hierarchy.
If you want components on the SAME gameobject that your script it attached to, then you simply need use:
gameObject.GetComponent();
Hope this helps.