Author Topic: NGUI scroll list issue  (Read 7920 times)

Abe_ForkTech

  • Guest
NGUI scroll list issue
« on: January 10, 2013, 04:08:35 AM »
Hi all,

Firstly I am sorry if I am posting it in the wrong forum.

Actually we are creating a game for iPhone and iPad and we are using NGUI, which is great btw. So, I created a scroll list, each row in the scroll list has 3 labels in it and a button. The scroll list works fine until I delete a row. I am using that button in the row to delete it. When I delete a row the button in the deleted row is still visible but all the labels are gone and also the space for the deleted row is still visible. When I move the scroll list up or down some how it updates its self and the remaining objects rearrange them selves. (the button for deleted row and blank space is gone)

I am already using "grid.Reposition();" which works fine when I add an item to the scroll list or if I start deleting the items from the bottom of the list. I think I am missing some sort of UI update call but I am not sure.

Please let me know what might be the issue and what can I do fix it.

Thanks,
Abe

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI scroll list issue
« Reply #1 on: January 10, 2013, 01:24:11 PM »
Destroy calls in Unity are delayed. They don't happen right away. So if you destroy a child object, then check its parent to see if the child is still there, it will report 'true'.

TLDR version: use NGUITools.Destroy instead.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: NGUI scroll list issue
« Reply #2 on: January 10, 2013, 05:52:51 PM »
Alternatively, disable the child first, then destroy.

Abe_ForkTech

  • Guest
Re: NGUI scroll list issue
« Reply #3 on: January 11, 2013, 01:53:58 AM »
Hi ArenMook and Nicki,

Thanks for the tips, and sorry I didn't posted back that I was able to fix the issue. Well the checkbox "Hide Inactive" in the Grid <UIGrid script> did the trick. I just unchecked it and the magic happened.  :P  I am not sure why it worked as it was a total fluke.  ;D

But rite now I have another problem if you could help me with, please. The thing is I am using "NGUITools.SetActive()" to enable and disable allot of my panels. Which works fine but the thing is when a panel is activated all the children are activated as well but I want some of them to be disabled. :)

I was wondering if there is any message sent to the activated panel by the NGUITools.SetActive() when can received and then can be used to activate the specific children? I am already handling that state of the children but it to much hassle cauz I have allot of panels enabling and disabling them selves and others as well.

Thanks,
Abe

Cripple

  • TNP Alpha
  • Full Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: NGUI scroll list issue
« Reply #4 on: January 11, 2013, 03:11:14 AM »
You can use those messages :

void OnEnable()
{
   // This is called when an object is enabled
}

void OnDisable()
{
   // This is called when the object is disabled.
}
Graphicstream Dev.

Abe_ForkTech

  • Guest
Re: NGUI scroll list issue
« Reply #5 on: January 11, 2013, 05:32:21 AM »
Thanks Cripple that worked, awesome. And I have a suggestion to ask. :-[

I have a game scene consisting of a Main Camera (Perspective Camera - NON-NGUI Camera) and other objects, which works fine. Now I want to add a 2D NGUI camera so that I could display some in-game UI (I am not sure if its called HUD  :-[ ). In-game UI like start fight button, and other text like player score etc while the player is playing.

What do you suggest:

1) Add the 2D NGUI camera in the same scene and set the depth so that the main camera is rendered first and then the in-game UI camera?

OR

2) Add a separate scene in the project which contains the in-game UI and add it to the game scene at run time through some script using alternative of "Application.LoadLevel" which doesn't destroy that current level?

OR

3) Is there any other preferred way I should do it? :P

Thanks for your answers, they were very help full and I hope to get a good suggestion for this too. :p
Abe