how do i call an image file when clicking an object? it’s like when I click an object (for example, a picture frame) the picture(texture) on the object will appear on the screen as a gui then it has a clickable “close button” …noob here ![]()
Put the image into a Resources folder (create it in Project view if you didn’t already).
Use Resources.Load(image_name_without_extension) to get a hold of that image in code.
Use OnMouseDown() method to determine when the click on object has happened.
Draw that texture with GUI.DrawTexture in OnGui() method.
You will need to define a rectangle inside which it will be drawn. Use these parameters if you want your picture over the whole screen:
Rectangle(0,0, Screen.width, Screen.height)
If you need explanation on any of these steps, try using Script reference to learn more. Just put the right expression (like “Resources”, “OnMouseDown” “GUI”, “OnGUI”, “Rectangle”) in search box: Unity - Scripting API: