Author Topic: [UNSOLVED] Dynamically Generated Scroll list not scrolling  (Read 5882 times)

CoderBear

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
[UNSOLVED] Dynamically Generated Scroll list not scrolling
« on: April 19, 2013, 02:49:25 PM »
Ok so here is a doozy of a conundrum.  I create my list via code and it all gets created fine.  However, when I try to go and scroll the list it does not scroll.  I've attached a picture of what the editor looks like at run-time.  Below is the code.

Why would it be doing this when it it works perfectly fine when I just setup it up in the editor?  As I did when I made a simple Stat page (I rather not have to make 45 of these by hand.)

Would be especially nice if one of the devs might offer their suggestions.

  1.     public Achievement[] Achievements;
  2.     public AudioClip EarnedSound;
  3.        
  4.         /*--- NGUI Elements ---*/
  5.         public UIDraggablePanel MasterDragPanel;
  6.         UIGrid MasterGrid;
  7.         UIDragPanelContents dragPanelContents;
  8.         public Transform achievePrefab;
  9.         GameObject newAchievementObj = null;
  10.  
  11.     private int currentRewardPoints = 0;
  12.     private int potentialRewardPoints = 0;
  13.     private Vector2 achievementScrollviewLocation = Vector2.zero;
  14.        
  15.         void Start()
  16.         {      
  17.                 MasterGrid = this.transform.GetComponent<UIGrid>();
  18.                 AchievementDisplay display = achievePrefab.gameObject.GetComponent<AchievementDisplay>();
  19.                
  20.                 for (int j = 0; j < Achievements.Length-1; j++) {
  21.                         // Get UI Label for name in child obj and set it to Achievments[j].name
  22.                         // Do this for description, points, and target
  23.                         display.nameLabel.text = Achievements[j].Name;
  24.                         display.descriptionLabel.text = Achievements[j].Description;
  25.                         display.pointsLabel.text = Achievements[j].RewardPoints.ToString();
  26.                         display.targetLabel.text = Achievements[j].getProgress().ToString() + " / " + Achievements[j].TargetProgress.ToString();
  27.                         dragPanelContents = achievePrefab.GetComponent<UIDragPanelContents>();
  28.                         dragPanelContents.draggablePanel = MasterDragPanel;
  29.                        
  30.                         newAchievementObj = NGUITools.AddChild(MasterGrid.gameObject, achievePrefab.gameObject);
  31. //                      dragPanelContents = newAchievementObj.GetComponent<UIDragPanelContents>();
  32. //                      dragPanelContents.draggablePanel = MasterDragPanel;
  33.                 }
  34.                
  35.                 MasterGrid.Reposition();
  36.                 MasterGrid.transform.position.Set(-195,245,0);
  37.                                
  38.             ValidateAchievements();
  39.         UpdateRewardPointTotals();
  40.         }
« Last Edit: April 20, 2013, 11:19:00 PM by CoderBear »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Dynamically Generated Scroll list not scrolling
« Reply #1 on: April 19, 2013, 08:40:30 PM »
Not sure exactly what's going on. Maybe the scale on the draggable panel is set wrong? (Not the localscale, the drag scale).

It seems strange to me to setup all the data in the prefab and then instantiate, instead of instantiating first and then setup the data - don't you get that prefab modified in version control every time you run the editor?

Try to make a screenshot with the UIPanel /draggablepanel in the inspector.

CoderBear

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: Dynamically Generated Scroll list not scrolling
« Reply #2 on: April 20, 2013, 12:41:33 PM »
I am not sure what you mean.  Once it is parented how would I get access to it to change it with the use of the expensive Find commmand?

Version Control has nothing to do with it and currently it is not under Version Control.

Here is picture you asked for.

It is urgent that I get this problem resolved ASAP.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: [UNSOLVED] Dynamically Generated Scroll list not scrolling
« Reply #3 on: April 21, 2013, 07:49:11 AM »
Try turning off Static and disable drag if fits. It shouldn't need the last one, but if the panel doesn't register that the sizes have changed, it might get stuck. :S

CoderBear

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: [UNSOLVED] Dynamically Generated Scroll list not scrolling
« Reply #4 on: April 21, 2013, 09:24:42 PM »
I did as you suggested and it still stays in one spot.  Not sure why this is happening in a dynamically generated list.  It would be easier if there was a tutorial or an actually write up on doing this dynamically via code.  I know a novel concept for a product that cost almost a $100 instead of just some examples with not a clear understanding of how the elements came together.

Though I am not the developer.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [UNSOLVED] Dynamically Generated Scroll list not scrolling
« Reply #5 on: April 22, 2013, 01:50:00 PM »
What I did in Starlink and Windward is create the entire setup for the draggable panel, with columns (if needed), background, draggable scripts etc. I then created a single entry (row) for what a single instantiated item would look like. I also created a script on this entry referencing all the required components (labels, background) that I know I will need to modify -- such as player name and score. This makes it easy to find them later. I then save this row entry as a prefab.

There is another script attached to the actual draggable list referencing this row entry prefab that has the actual logic for instantiation -- for eample getting data from the server for 10 rows. 10 rows get instantiated, data gets filled in. Everything is scrollable perfectly fine because all I do is create entries within an existing draggable list.

CoderBear

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: [UNSOLVED] Dynamically Generated Scroll list not scrolling
« Reply #6 on: April 22, 2013, 03:47:30 PM »
OK.

I don't have access to the code to see exactly what you are talking about.  I have it generating the entire list fine.  The problem is getting the generated grid to scroll on a device or via unity remote.  I understand what you are getting at, but I am a visual person and would need to actually see this to really get the understanding.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [UNSOLVED] Dynamically Generated Scroll list not scrolling
« Reply #7 on: April 22, 2013, 04:46:23 PM »
Never ever use Unity remote. It's a buggy piece of software that sends events twice. A single interaction with the mouse results in both touch and mouse events being sent out.

CoderBear

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: [UNSOLVED] Dynamically Generated Scroll list not scrolling
« Reply #8 on: April 22, 2013, 06:19:19 PM »
OK.  But even if I do a build and run.  I still can't scroll.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [UNSOLVED] Dynamically Generated Scroll list not scrolling
« Reply #9 on: April 22, 2013, 09:29:28 PM »
Yes, and I don't know what's wrong with your setup as I can't see it. I advised a better approach.

Btw, make sure that the draggable panel has depth of -1 so that it's actually in front of everything else.