Hello Guest

Author Topic: Tips on passing content to hover window?  (Read 1721 times)

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Tips on passing content to hover window?
« on: August 12, 2014, 04:58:24 am »
Hi all

I am using the OnHoverOverUIItem to initiate a new popup/tooltip window for my game (it's for hovering over items and skills and seeing the information). The popup window is a prefab with a blank content area.

I'm trying to figure out how I can pass content to the popup window. For now I have the popup window hardcoded to look at certain components in the 'tk2dUIItem' parameter that gets passed through. But since I want the popup window to be versatile I don't always know what components to look back to 'tk2dUIItem' for.

Does anyone have any advice on how to pass content to a window when using 'OnHoverOverUIItem'?

Cheers



unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9708
    • View Profile
Re: Tips on passing content to hover window?
« Reply #1 on: August 12, 2014, 10:31:44 am »
You get a tk2dUIItem - simply attach any of your own behaviours to it. In your handler, you can deal with it by uiItem.GetComponent<YourBehaviour>() and if not null you can deal with it in any way you like.

You can also use tags for a quick way to store data.

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Tips on passing content to hover window?
« Reply #2 on: August 12, 2014, 11:41:58 pm »
Thanks for the feedback, I think that's the way I'll go then.

Coming from a web background I think I'm too used to just injecting HTML into modal windows. I keep trying to figure out how in Unity to serialize all the content and push it into the window. I guess the best way of handling it is to just make several popup window prefabs, one for each usage and content type. That works fine with the tk2dUIItem parameter then.

Cheers!