Author Topic: Add Widgets On Runtime that are complex GameObjects  (Read 3086 times)

_joe_

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Add Widgets On Runtime that are complex GameObjects
« on: October 08, 2012, 07:56:52 AM »
Hello,
I'm currently instantiating GameObjects (that include Buttons, Grids,...) on runtime using a database. and i'm placing them in a Panel following the Draggable panel example,
Now everything works perfectly, except that the panel has 0 widgets, that's not a problem, except for now, when i want to clip that specific panel,
Should i create a widget variable, add some ui script on my prefab, and use panel.AddWidget on every prefab i add (also knowing that the prefab is not specifically a widget).

Any advice would be greatly appreciated.

Joe

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Add Widgets On Runtime that are complex GameObjects
« Reply #1 on: October 08, 2012, 08:21:50 AM »
Clipping only works if:
- Shaders are enabled
- The panel has a uniform scale (1, 1, 1), and so do all of its parents
- The objects inside the panel are using a material that has a shader that has alternate versions that support clipping. Unlit/Transparent Colored is one such shader.
- The "alternate" shaders can be loaded via Resources.Load -- they must be in the Resources folder.

So... if you want to display some clipped object, make sure that its shader supports clipping.

_joe_

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: Add Widgets On Runtime that are complex GameObjects
« Reply #2 on: October 08, 2012, 08:40:43 AM »
Actually, it's because im adding custom gameobjects that have widgets inside of them, and are not widgets themselves is what is causing the problem.
My panel shows 0 widgets, hence it can't clip what is inside of it.
I want my parent objects to hold multiple objects inside of them, and they don't have any ui widget script.
I for instance added a uisprite script on one of the objects, and the Panel immediately showed : Widgets : 1

Is there any workaround, to make the panel consider a uigrid as a widget? (since i have a panel, with 4 ui grid children, each grid has uigrids which include draggable buttons (like the draggable example).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Add Widgets On Runtime that are complex GameObjects
« Reply #3 on: October 08, 2012, 04:30:55 PM »
Sounds like you have more panels than you think. Delete the extra ones.

_joe_

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: Add Widgets On Runtime that are complex GameObjects
« Reply #4 on: October 10, 2012, 03:48:45 AM »
I just logged in to say the exact same thing:
My draggable elements had panels on them, just had to remove them and everything is working great!

Joe