Answers for "unity string array"

C#
1

unity string array

// String array in Unity C#
string[] names = new string[] {"red", "green", "blue"};

// To use lists, make sure to have this at the beginning of your program
using System.Collections.Generic;

// To declare a new list
public List<string> listOfColours = new List<string>();

// To add elements to your list
void Start()
{
	listOfColours.Add("Red");
    listOfColours.Add("Green");
    listOfColours.Add("Blue");
}
Posted by: Guest on February-26-2022

C# Answers by Framework

Browse Popular Code Answers by Language