I am trying to build a scrolling advertisements line contains image links (like what we see in many websites), when users click on a link, we will need to handle corresponding action. Also, the advertisements line should be clipped (not running through the whole screen).
I could make the text scroll and clipped using this simple code:
float x = -5;
Texture adImage;
void OnGUI()
{
GUI.BeginGroup(new Rect((Screen.width - width)/ 2, 50, width, height), backgroundImage);
GUI.DrawTexture(new Rect(x, 10, 20, 20), adImage);
GUI.EndGroup();
if (x < width)
x += 1;
else
x = -5;
}
But I cannot find way to assign OnClick event for the texture…
I tried to use GUITexture and I could make it scroll and clickable, however I have a problem with clipping with this solution as I couldn’t combine the scrolling code with GUI.BeginGroup / EndGroup…
Any suggestion?