Author Topic: auto scroll score board  (Read 8821 times)

laurentl

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 188
    • View Profile
    • McDROID
auto scroll score board
« on: April 10, 2013, 09:06:32 PM »
I'd like to replicate what we have in McDROID : a score list that auto scrolls from the top to where your score is.
I plan on using UIDraggablePanel but I don't know how to move it to the proper line or item.
The Spring thing that was recommended moves the item at position 0, instead moving the drag area to the item so that doesn't work.
Is there an example somewhere I can use as a base?

broknecho

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: auto scroll score board
« Reply #1 on: April 11, 2013, 12:43:53 AM »
Try out this style:  http://www.youtube.com/watch?v=GZy-uPm42T8

If your scoreboard is a dragable panel that is clipped to it's outer panel like in the video, I think you'll have what you're looking for.
It is the SpringPanel that I believe you are talking about but should still be able to take in your current score item and slide down to it from the top score.

laurentl

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 188
    • View Profile
    • McDROID
Re: auto scroll score board
« Reply #2 on: April 11, 2013, 01:29:20 AM »
This is very nice broknecho ! Thanks!

It's doing something weird - it's moving sideways :
https://www.youtube.com/watch?v=XrmpWhE87qI

I'm using this bit of code.
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class CenterOnObject : MonoBehaviour {
  5.  
  6.         public UIDraggablePanel dragPanel;
  7.         void Start ()
  8.         {
  9.                 dragPanel = NGUITools.FindInParents<UIDraggablePanel> (gameObject);
  10.         }
  11.  
  12.         void OnClick ()
  13.         {
  14.                 Vector3 pos = dragPanel.transform.worldToLocalMatrix.MultiplyPoint3x4 (transform.position);
  15.                 SpringPanel.Begin (dragPanel.gameObject, -pos, 8f);
  16.         }
  17. }
  18.  

laurentl

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 188
    • View Profile
    • McDROID
Re: auto scroll score board
« Reply #3 on: April 11, 2013, 01:30:06 AM »
Oh and in the case where the scroll is not dealing with buttons/panels but with a long label, how would I find the coordinates of one line, let's say line 1000 ?

broknecho

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: auto scroll score board
« Reply #4 on: April 11, 2013, 04:44:52 PM »
Hmmm not too sure why the X is change on that dragPanel.  I will have to dive into the SpringPabel.Begin code to look if it's changing the position of that object.  Looks like it's the one changing with all the buttons moving along with it due to the parenting.

In regards of the 1000 lines of a high score, I would probably have a Prefab called HighScoreEntry.  This would have a UILabel under it which would display what you want. 
Also, you would need a HighScoreList that parents each of the Entries.  This list could have a script on it that keeps track of each entry included things like Player ID.  Then if you need to find a specific Player ID, you could get the HighScoreEntry associated with it and slide down to it.

HighScoreList - This would have a HighScoreListScript on it that would have a Dictionary<int, HighScoreEntry> on it where the int would be the player Id. 
   -> HighScoreEntry1
   -> HighScoreEntry2
   -> HighScoreEntry3
   ...
   -> HighScoreEntry1000
      ->UILabel
      ->HighScoreEntryScript.cs - This would references the UILabel and other properties like Player ID, Name, Score, etc.  It would build the UILabel.text


I'm just at work though so I can't test this out till later but i think would be one solution that could work.

~Scott

laurentl

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 188
    • View Profile
    • McDROID
Re: auto scroll score board
« Reply #5 on: April 13, 2013, 12:02:32 AM »
That doesn't work, Scott, that prefabing the score entry.
The reason is panels have a fixed limits of vertices per panel so regardless of how you enter these, it will total the breaking point.
(I just tried)

broknecho

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
    • View Profile
Re: auto scroll score board
« Reply #6 on: April 13, 2013, 12:21:51 AM »
Hmmmm yeah after thinking about it later, I thought that might happen.   I wonder if you need to just show the visible section then.  Like if you are at spot 1000, only show scores 990-1010 (20 scores) or something along that line.  That defeats the ability of scrolling the list but will at least show you and the surrounding scores.

Or maybe have a list of 20 labels that are just recycled as you run and continually rotate them with new text values.  This would kinda simulate a  scrolling list but you are just recycling 20 labels over and over.

So 1-20 -> 2-21 -> 3-22 -> and so on.

I'm just throwing ideas out as I have not built something like this.  I will try to experiment with it though in the next few days to try some of these ideas.

~Scott