Author Topic: UIDrag Panel Contents won't render after being enabled in scene  (Read 7331 times)

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
I am disabling my UIDrag Panel Contents before the scene starts, but when I enabled them, they will not draw in the scene.  However, if I enabled while the scene is not playing, they appear just fine.  Any idea why?
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #1 on: July 12, 2012, 04:41:48 AM »
This makes no sense. UIDragPanelContents is a script. It's not a visible component. How would it be drawn?

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #2 on: July 12, 2012, 02:39:22 PM »
What I meant was everything that is a child under the Panel contents, so any sprites or labels do not visually appear if enabled while the scene is running.
Creator of Soul Saga.
http://www.disastercake.com

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #3 on: July 12, 2012, 03:05:41 PM »
I've made a short video showing you a similar bug that happens after using NGUITools.AddChild:

http://youtu.be/UjzLMl0vYRM

You can see that the labels and sprites won't display, though I can click reposition now and they will be recognized by the panel to be repositioned.

If I drag one of these prefabs out while the scene is running it won't display either.  However, if I drag it out while the scene is NOT running, it appears just fine.

My code looks like this:
  1. GameObject newItem = NGUITools.AddChild(myParent, myPrefab);
« Last Edit: July 12, 2012, 04:24:44 PM by Disastercake »
Creator of Soul Saga.
http://www.disastercake.com

cfj

  • Guest
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #4 on: July 12, 2012, 04:25:33 PM »
This appears to be similar to the issue that I am currently having.  How are you adding the objects to the UIGrid?

Checkout the thread here: http://www.tasharen.com/forum/index.php?topic=1000.0

Are you doing something similar?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #5 on: July 12, 2012, 04:53:07 PM »
Are you copy/pasting them at run-time? I'm pretty sure that won't work as some critical functions (like Start) don't get called. You need to instantiate their prefabs or call CheckParent() on the widgets.

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #6 on: July 12, 2012, 05:21:43 PM »
@ArenMook: the myPrefab is a prefab from the Project Panel, not just copying one that is already on the scene.


@cfj: I think we are having similar issues. 


I hate to sound pessimistic, but this is completely bottle-necking my development and frustrating me completely for the past week.  Every time I try to do something new with NGUI that's beyond basic functionality it seems like I have problem after problem.  I bought NGUI to save me time, but I could have rolled my own solution within a day using Unity's base GUI elements.  NGUI seems successful, so have you considered hiring someone to make some good video tutorials on advanced functionality and pitfalls to avoid?  Having solid training videos could really help people understand your product better.  You currently have 2, but they are the most basic tutorials possible.
« Last Edit: July 12, 2012, 05:44:36 PM by Disastercake »
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #7 on: July 12, 2012, 07:24:25 PM »
You seriously overestimate the amount of money NGUI makes if you think I can just hire people freely. I already hired one guy, and he's a dev, and last week the profits were in the negatives, for example.

There are six video tutorials, not two: http://www.tasharen.com/?page_id=197, and quite a few examples as well that cover everything from dynamic instantiation to moving objects from one panel to another. I instantiate prefabs frequently in Windward. The news, player names, player summary page contents, all the HUD elements, and more are all added dynamically at run-time using NGUITools.AddChild, without any issues. What version of Unity are you using?

All I can suggest is what I've mentioned already -- when re-parenting a widget, Broadcast CheckParent to that instance. If you can't figure it out, you can send a reproduceable example to support at tasharen.com and I'll have a look at it.

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #8 on: July 12, 2012, 07:40:52 PM »
You seriously overestimate the amount of money NGUI makes if you think I can just hire people freely. I already hired one guy, and he's a dev, and last week the profits were in the negatives, for example.

You could be more clever about it and start striking deals with other tutorial makers.  I noticed that you put a like to burgzerger, which is good, but try advertising it more, and maybe try working directly with him to get specific content out.  This sort of networking flows traffic in both directions:  it's advertising for you and advertising for him.  Reach out to other tutorial makers like the guy who worked on the awesome Playmaker tutorials.


What version of Unity are you using?
3.5.3f Pro


All I can suggest is what I've mentioned already -- when re-parenting a widget, Broadcast CheckParent to that instance. If you can't figure it out, you can send a reproduceable example to support at tasharen.com and I'll have a look at it.

Where can I find example code for this?
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #9 on: July 12, 2012, 07:45:10 PM »
As mentioned in another thread, line 87 of DragDropItem.cs

Drag & Drop example uses it.

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #10 on: July 12, 2012, 07:56:30 PM »
This is my current code and it is not changing anything:

  1. GameObject newItemEntry = NGUITools.AddChild(myParent, myPrefab);
  2. newItemEntry.transform.BroadcastMessage("CheckParent", SendMessageOptions.DontRequireReceiver);
  3.  

I will send you a link to the project tonight so you can take a look.
Creator of Soul Saga.
http://www.disastercake.com

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: UIDrag Panel Contents won't render after being enabled in scene
« Reply #11 on: July 13, 2012, 02:59:44 PM »
In case anyone finds themselves with the same problem, the solution was to turn static off on the panels.  Not the normal unity static, but there is a boolean setting in the script via the inspector on all panels called static as well.
Creator of Soul Saga.
http://www.disastercake.com