Question by
KamiSama00 · Oct 13, 2016 at 03:11 AM ·
scripting problemerrorscripting beginnerscriptingbasicsscript error
Getting weird error message!?!?!?
So im trying to generate a random 10 digit number everytime the left mouse button is click but when i click it the numbers are replaced with this "system.collection.generic.list 1[system int32]" can someone help me or guide me to the right place to fix this
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
public class GenerateNum : MonoBehaviour {
public Text numGen;
private int maxNumbers = 20;
private List<int> uniqueNumbers;
private List<int> finishedList;
void Start ()
{
uniqueNumbers = new List<int>();
finishedList = new List<int>();
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButtonDown (0))
{
Generate ();
}
}
public void Generate ()
{
for(int i = 0; i < maxNumbers; i++)
{
uniqueNumbers.Add (i);
}
for(int i = 0; i< maxNumbers; i ++)
{
numGen.text = "" + finishedList.ToString ();
int ranNum = uniqueNumbers[Random.Range(0,uniqueNumbers.Count)];
finishedList.Add(ranNum);
uniqueNumbers.Remove(ranNum);
}
}
}
Comment
Answer by Chiroculon · Apr 06, 2017 at 02:53 PM
@KamiSama00 The trouble is in:
finishedList.ToString ();
This code turns the list object to a string, rather than turning the content of the list to a string. You will have to write a function to do that for you.