Skip to content

Instantly share code, notes, and snippets.

@elringus
Last active November 21, 2020 13:28
Show Gist options
  • Save elringus/f21921b9428c5f527b739f5a3cd1ddf0 to your computer and use it in GitHub Desktop.
Save elringus/f21921b9428c5f527b739f5a3cd1ddf0 to your computer and use it in GitHub Desktop.
[System.Serializable]
public class Item
{
private string value = null;
public void SetValue (string value) => this.value = value;
public string GetValue () => value;
}
using UnityEngine;
public class TestBehaviour : MonoBehaviour
{
public Container Container;
private void Start ()
{
// Expected to always log null.
Debug.Log(Container.Items[0].GetValue());
// This assignment should not persist after exiting-entering play mode,
// as the value field has auto initializer set to null.
Container.Items[0].SetValue("ASSIGNED AT PLAY MODE");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment