Author Topic: ****[Suspected Bug on UITexture Re-parent]****  (Read 3952 times)

fgame

  • Guest
****[Suspected Bug on UITexture Re-parent]****
« on: November 08, 2012, 09:18:32 PM »
Steps
1. Place a UITexture and parent it to Panel A
2. Then parent it to a Panel B and BroadcastMessage "CheckParent"
3. Then parent it back to Panel A and BroadcastMessage "CheckParent"

Panel B will still has the material reference and it being rendered. Thus the UITexture is appeared 2 different positions on screen. The only way to fix it is to destroy UIPanel on B, and create a new one on it, then it will be refleshed. But it will result a blink of UI.

Please investigate
« Last Edit: November 08, 2012, 09:37:19 PM by fgame »

fgame

  • Guest
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #1 on: November 08, 2012, 09:53:03 PM »
To let anyone reading this thread understand quickly about the issue, I created a tutorial for it. You can do it in 5 mins.

1. Find and copy "example 11 Drag Drop" in NGUI folder
2. Open the copied scene create a UITexture parent it to "Item 3".
3. Create a collier behind the box and make it able to drag the UIPanel holds the items.
4. Drag "Item 3" to a blank space and drop. It will back to original
5. Drag the UIPanel this item, you will see that UITexture will render 2 times.

This is because UIPanel on DragDropRoot still keep the material of UITexture.

Also attached the screenshot with descriptions.

Please FIX this

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #2 on: November 09, 2012, 04:57:41 AM »
I will look into this when I get home.

fgame

  • Guest
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #3 on: November 10, 2012, 08:33:24 PM »
I will look into this when I get home.

Any update?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #4 on: November 11, 2012, 11:07:36 AM »
I followed your instructions and I just can't reproduce this with NGUI 2.2.3 on Unity 3.5.6.

The easiest case is simply adding a UITexture to one of the items (and bringing its Z forward to -1 so it's visible), then trying to drag it. Works fine. Even adding the draggable panel stuff had no effect (not sure why you had to do this to begin with?)

fgame

  • Guest
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #5 on: November 11, 2012, 09:32:19 PM »
I am also using 2.2.3 on Unity 3.5.6.
I guess maybe some of your steps are not correct. Have you added the UIDragPanelContents on a collider behind (Not on the item itself)?

I have exported the example to a package. To reproduce:
1. Create a new project, important the package
2. Drag the item to an empty space
3. Drag the collider behind to move the panel holding the items. Then you will see.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #6 on: November 12, 2012, 11:02:13 AM »
UIDragPanelContents went on the background object, yes.

"Drag the collider behind to move the panel holding the items" <-- I  have no idea what you mean by that.

fgame

  • Guest
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #7 on: November 12, 2012, 09:18:24 PM »
UIDragPanelContents went on the background object, yes.

"Drag the collider behind to move the panel holding the items" <-- I  have no idea what you mean by that.

It means to drag the background object (which has a collider and UIDragPanelContents). Have you try the package I exported for you?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #9 on: November 12, 2012, 10:33:18 PM »
I think I figured out what issue you were having. I had to move the DragDropRoot object instead.

Open up UIWidget class, around line 250:
  1. // This widget is no longer parented to the same panel. Remove it and re-add it to a new one.
  2. if (!valid)
  3. {
  4.         if (!keepMaterial) material = null;
  5.         mPanel = null;
  6.         CreatePanel();
  7. }
Change it to:
  1. // This widget is no longer parented to the same panel. Remove it and re-add it to a new one.
  2. if (!valid)
  3. {
  4.         if (!keepMaterial || Application.isPlaying) material = null;
  5.         mPanel = null;
  6.         CreatePanel();
  7. }

fgame

  • Guest
Re: ****[Suspected Bug on UITexture Re-parent]****
« Reply #10 on: November 13, 2012, 04:37:26 AM »
It's solved, thank you!