Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Create scrollable List of strings C#

Discussion in 'Scripting' started by Hoskins355, Jun 29, 2015.

  1. Hoskins355

    Hoskins355

    Joined:
    Jan 3, 2013
    Posts:
    142
    I am trying to create a list of strings. I would like to be able to scroll through the list in the inspector.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using System;
    5.  
    6. [System.Serializable]
    7. public class StudentData : MonoBehaviour {
    8.  
    9.     public string studentName;
    10.     public string classNumber;
    11.     public string Cat1Score;
    12.     public string Cat2Score;
    13.     public string Cat3Score;
    14.     public string Cat4Score;
    15.     public string Cat5Score;
    16.     public string Cat6Score;
    17.     public string Cat7Score;
    18.     public string Cat8Score;
    19.     public string Cat9Score;
    20.     public string Cat10Score;
    21.     public string TestScore;
    22.     public string BonusScore;
    23.     public string NumOfTimesUsed;
    24.     public string DateLastUsed;
    25.  
    26.     public List<StudentData> studentdata = new List<StudentData>();
    27.  
    28.  
    29.     public StudentData(string NewstudentName, string NewclassNumber, string NewCat1Score, string NewCat2Score, string NewCat3Score, string NewCat4Score, string NewCat5Score, string NewCat6Score, string NewCat7Score,
    30.                        string NewCat8Score, string NewCat9Score, string NewCat10Score, string NewTestScore, string NewBonusScore, string NewNumOfTimesUsed, string NewDateLastUsed){
    31.        
    32.         studentName = NewstudentName;
    33.         classNumber = NewclassNumber;
    34.         Cat1Score = NewCat1Score;
    35.         Cat2Score = NewCat2Score;
    36.         Cat3Score = NewCat3Score;
    37.         Cat4Score = NewCat4Score;
    38.         Cat5Score = NewCat5Score;
    39.         Cat6Score = NewCat6Score;
    40.         Cat7Score = NewCat7Score;
    41.         Cat8Score = NewCat8Score;
    42.         Cat9Score = NewCat9Score;
    43.         Cat10Score = NewCat10Score;
    44.         TestScore = NewTestScore;
    45.         BonusScore = NewBonusScore;
    46.         NumOfTimesUsed = NewNumOfTimesUsed;
    47.         DateLastUsed = NewDateLastUsed;
    48.        
    49.        
    50.     }
    51.  
    52. //    //This method is required by the IComparable
    53. //    //interface.
    54. //    public int CompareTo(StudentsData other){
    55. //
    56. //    }
    57.  
    58. }
    59.  
    How do I add arrows like below to scroll through the list in the inspector?
    Screen Shot 2015-06-28 at 8.35.05 PM.png

    Thanks
    Brandon
     
  2. ANTARES_XXI

    ANTARES_XXI

    Joined:
    Dec 23, 2014
    Posts:
    141
    You need to write custom Editor for your script, read about Editor class.
     
  3. Hoskins355

    Hoskins355

    Joined:
    Jan 3, 2013
    Posts:
    142
    Thank you that was exactly what I was looking for, but I now think I am going to store the information in a database instead.