How to control GUITextures within a single C# script?

Hello guys, the thing is, I placed GUITexture in editor manually, not via code, because it’s easy that way to keep them appearing on the same position even if resolution changes…

Now I can assign a simple C# to it, and there is a function void OnMouseDown() and that’s cool, that’s what I need…

Now the thing is, if I create like an empty game object, and assign a new C# script to it, and load GUITexture in it via code like… → public GUITexture button;

Then how can I access the same function, OnMouseDown for that particular GUITexture, namely button? Because I plan to have single C# where I would keep many GUITextures, and do different things depending on what GUITexture the user has clicked on.

Thanks =)

What you want to do is make ONE of these GameObjects that has a GUITexture and your script on it, and make it a Prefab by dragging it to your Hierarchy window. Then you can drag those prefabs out into your scene and set the texture to whatever you want. They will all behave exactly the same. Call it a GUITextureButton, or something like that, so you don’t get confused later when you want to have a different kind of GUITexture Prefab.