Author Topic: How to add existing game object to clip panel at runtime  (Read 2519 times)

Leveler

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
How to add existing game object to clip panel at runtime
« on: August 15, 2014, 01:13:37 PM »
I am having an issue with adding an existing game object that's already in the scene to a clip panel during runtime. I have just a plain game object that has multiple sprites as its children. These children and the game object that hold them all are children to the main root panel before I try to add them to the clip panel. If I do this in the editor it will clip them properly but I need to be able to do this during runtime. I've seen other posts where people are having issues with the same thing but they are trying to create new widgets and add them to the panels. I want to keep the original ones and just move them from a normal panel to a clip panel. 

I've been stuck on this for a while now and I can't seem to figure it out. It seems like the widget component of the children need to be added to the panel explicitly and then removed from the panel they were in because that's the only way I can get them to clip during runtime. The problem is that I now cannot move the widget with the gameobject's transform.

Any help with this would be appreciated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to add existing game object to clip panel at runtime
« Reply #1 on: August 16, 2014, 09:06:23 AM »
You can reparent widgets just fine, provided you are doing so from one panel to another. You can't randomly unparent widgets and leave them in the middle of nowhere. All widgets need a panel on a parent object somewhere. Also, after changing the parent, call NGUITools.MarkParentAsChanged(objectYouReparented);