Hi, I have a problem with this code, I'm a student, so, maybe it´s so simple, I don't now, I try maker simply, this is an example of my error:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Example : MonoBehaviour {
public struct StringContainer
{
public string value;
public void SetValue(string otherValue)
{
value = otherValue;
}
}
void Method()
{
List stringContainers = new List();
stringContainers.Add(new StringContainer());
stringContainers[0].SetValue("gato");
Debug.Log (stringContainers [0].value.Length);
}
// Use this for initialization
void Start () {
Method ();
}
// Update is called once per frame
void Update () {
}
}
the error is " Object reference not set to an instance of an object"
I don´t really understand
↧