Author Topic: Integrating Unity 2D Hud Elements into NGUI  (Read 3416 times)

dmonk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Integrating Unity 2D Hud Elements into NGUI
« on: February 11, 2014, 11:43:41 AM »
So I'm looking for some feedback on the best way to tackle this problem.  What I'm attempting to do is to integrate uWebKit's 2D WebGui elements into NGUI. I've already integrated their WebTexture elements into NGUI by essentially taking the same approach that UITexture does, and just treating the web texture like any other texture.  This works really well, but their (uWebKit's)  3d Texture web view has some limitations.
 
Their 2D Web View hower provides a very nice, crisp, clear web browser interface.  In order to do so though, it uses Unity's native GUI support, which of course doesn't know anything at all about NGUI's nice anchoring and layering architecture.

I know that the HUD element won't respect panel depth, but I can live with that.  (it's always going to be on top anyway).  My first thought is to create a thinly derived UIWidget class that has the 2D Web GUI object attached, and at each update (or if the widgit has been marked dirty) to reset the gui element's location and extents based on the widgit's updated screen location and extents.  This seems like it would at least get the hud element to respect the widgit's boundaries.
 
So has anyone done something simlar, and have any recommendations?  Or is there an existing sample script that integrates a Unity Hud element into an NGUI widgit?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Integrating Unity 2D Hud Elements into NGUI
« Reply #1 on: February 11, 2014, 07:56:39 PM »
Unity's OnGUI and NGUI are two completely different systems, and they have nothing to do with each other. I am not sure why you'd even want to mix the two.

From NGUI's point of view, all it needs to work is some material. It doesn't even have to be a texture. Just a material. As long as the widget uses a material, and feeds vertices in its OnFill function, NGUI will do the rest.