Author Topic: scroll view and spring panel  (Read 9068 times)

AlexeyTsoy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
scroll view and spring panel
« on: February 16, 2016, 01:55:04 PM »
Hello! I have a problem with scroll view or may be spring panel! I have a inventory made by scroll view and grid, once i fill scroll view and go out abroad and then i destroy or setactive false all itmes in scroll view and after if i try to addchild(items) items will visibility abroad! I found out that after destroy of items appears spring panel with incomprehensible coordinates and those coordinates takes scroll view and addchild to these coordinates visibility abroad! If i click on scroll veiew in game window of unity everything falls into place but in my case i can't every time click on it.... Cuz if player will sell all items and appears new items he will in a shock! ^__^ what are the solutions?

AlexeyTsoy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: scroll view and spring panel
« Reply #1 on: February 17, 2016, 02:12:29 AM »
i have bought NGUI for 100$ and no SUPPORT nice!

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: scroll view and spring panel
« Reply #2 on: February 17, 2016, 07:33:58 AM »
Ask a question before expecting a reply.

Are you refreshing your grid and/or scrollview after destroying children?  Posting code might help...

AlexeyTsoy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: scroll view and spring panel
« Reply #3 on: February 17, 2016, 09:07:08 AM »
  1. if(Input.GetKeyDown(KeyCode.A))
  2.                 {
  3.                         GameObject prefab = (GameObject)Resources.Load("Prefabs/EquipmentItem");
  4.                         prefab.GetComponent<EquipmentScript>().index = i;
  5.                         equipmentInventory.AddChild(prefab);
  6.                         equipmentInventory.GetComponent<UIGrid>().repositionNow = true;
  7.                 }

Add items!
  1. if(Input.GetKeyDown(KeyCode.D))
  2.                 {
  3.                         foreach (var item in equipmentInventory.GetComponent<UIGrid>().GetChildList())
  4.                         {
  5.                                 NGUITools.Destroy(item.gameObject);
  6.                         }
  7.                 }

Destroy items!

After destroy i refreshed ui panel, scrollview, uigrid manually


Ask a question before expecting a reply.

Are you refreshing your grid and/or scrollview after destroying children?  Posting code might help...

AlexeyTsoy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 20
    • View Profile
Re: scroll view and spring panel
« Reply #4 on: February 17, 2016, 09:51:44 AM »
I found out that it happens only if there is drag scroll view component on prefab

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: scroll view and spring panel
« Reply #5 on: February 18, 2016, 07:04:52 PM »
I am having a hard time understanding your original post. I am not sure what you're trying to say there.

In your code I see a few things wrong. First, you should never be changing values on a prefab like you do when you set the index. You should be doing this on the instantiated object instead.

You are also getting UIGrid then setting a boolean value. You should be calling UIGrid's Reposition() function instead. UIGrid disables itself after completing its task, so you setting a boolean value will do absolutely nothing.

You are also destroying items while iterating through them... this is wrong, and is bad practice. If you want to destroy child objects, use transform.DestroyChildren();