Hi guys, I’ve got some problems using GUI Buttons

I need to do this kind of scripting :

A scroll view that has images, within

An Image has an inner -image within that is clickable.

Both the image an inner image should be clickable.

I use GUI.Button to show the images. Usually I create the inner image within a separated window. While in this situation is I can’t make the inner image within another window since I have to do it in a scroll view.

for example :

	GUI.BeginGroup(Rect(15, 40, 380, 575));
	button *= GUI.Button( Rect( 5, topButton , 305, 138), "", Panel);*

_ if(GUI.RepeatButton ( Rect( 120, topButton + 75, 40, 40), “”, script*.SkillIcon))*_
GUI.EndGroup();
in short : I want to able to click the panel and skill icon. but the skill icon is in the panel itself, while the panel is in a scroll view.
Any ideas on solving this problem?

You can use a repeat button and render the second button within it with a pressed style, like so:

function OnGUI()
{
    if (TextureToShow == null)
        return;
	
    var tLargeButton:Rect = Rect(0, 0, TextureToShow.width, TextureToShow.height);
    var tSmallButton:Rect = Rect(0, 0, TextureToShow.width / 2, TextureToShow.height / 2);
	
    if (GUI.RepeatButton(tLargeButton, TextureToShow))
    {
        // Put code for large or small button here (both will hit it)
        
        if (tSmallButton.Contains(Event.current.mousePosition))
        {
            // Put code for only the small button here

            var tPressedStyle:GUIStyle = GUIStyle(GUI.skin.button);
            tPressedStyle.normal = tPressedStyle.active;
	        
            GUI.Button(tSmallButton, TextureToShow, tPressedStyle);
        }
	    else
        {
            // Put code for only the large button here

            GUI.Button(tSmallButton, TextureToShow);
        }
    }
    else
        GUI.Button(tSmallButton, TextureToShow);
}

You could disable the outer button, or draw it as a Label in a Button style, whenever the mouse is inside the Rect of the inner button.