Multiple guiTextures which is being clicked?

I have been stuck on a rather trivial circumstance that is etching into my brain. So I am rather new to unity programming but I have been programming in both C# and Java for two - three years. I feel rather stupid for asking this but I can’t seem to find an answer

So I am not sure what the main coding convention with unity is whether you should centralize code to avoid duplication or have a script across several components that is duplicated (obviously seems incorrect).

At the moment I have 8 guiTextures that make up a players navigation. Instead of creating a script for each individual guiTexture I want a centralized script that is an empty game object that holds the script. This script will check which one is being clicked and act accordingly. I have tried function OnMouseUp(), Raycasting. I just can’t find a solid conclusion.

On another note, for one of my others scripts I have if(hit.collider.tag == “fence”) else if … and there are 27 of these. Is there an easier way of executing this, I know python has a dictionary function that allows a reference to variable format, although I am not familiar with boo.

Because of the component system in unity, it is only possible to use sent messages such as ‘OnMouseUp’ if you have a script that is instantiated as a component on every object that you want to use it with.

For the other thing, have you considered using a switch statement?

switch(hit.collider.tag)
{
    case "fence":
    {
        // do fency stuff;
        break;
    }
    case "wall":
    {
        // do wally stuff;
        break;
    }
    default:
    {
        // do stuff you should do if it's none of the above
    }
}

That seems much more straightforward, to me.

I was not aware case statements would work in unity. Although that is a relief. Regarding to the first part it seems rather tedious to create 8 separate scripts just for each button instead of having some form of action listener to which guiTexture is being clicked. Sorry if my terminology of actionListener is incorrect.