NullReferenceException when adding items to nonempty list
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 540
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to add an item to an `InkList` through C#. It already has values in it, and the item I'm adding is from the same origin as those values, so I believe this should be supported. I'm guessing this is because the items added to the list were added via loading saved data, and no items have been added since loading that data.
Minimal repro:
Ink:
```
LIST fruit = Apple, Orange
~ fruit += Apple
```
C# (Unity):
```csharp
var story = new Ink.Runtime.Story(json);
story.ContinueMaximally();
var save = story.state.ToJson();
story = new Ink.Runtime.Story(json);
story.state.LoadJson(save);
var fruitList = story.variablesState["fruit"] as Ink.Runtime.InkList;
Debug.Log(fruitList.Count); // 1
fruitList.AddItem("Apple"); // NullReferenceException
```
Stack:
```
NullReferenceException: Object reference not set to an instance of an object
Ink.Runtime.InkList.AddItem (System.String itemName) (at Assets/Plugins/Ink/InkRuntime/InkList.cs:179)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.