Last active
November 21, 2020 13:28
-
-
Save elringus/f21921b9428c5f527b739f5a3cd1ddf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Serializable] | |
public class Item | |
{ | |
private string value = null; | |
public void SetValue (string value) => this.value = value; | |
public string GetValue () => value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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