Hello,
I currently do inhouse tool that heavily relies on Scriptable Objects. I’ve made many tests that create temporary scriptable objects, and it used to work in Unity 2020.1.
Yesterday I upgraded to Unity 2020.3 and those tests don’t work correctly anymore. Unity destroys those temp SOs. When debugging data passed to tests those SO present themselves as null, but methods can be called on them.
I tried setting HideFlags.DontUnloadUnusedAsset, storing them in static list, storing them in container asset, but it doesn’t help.
Is there workaround to keep using temp SOs (as it simplifies code)? Should I create assets and delete them after tests?
Thank you in advance
Example of tests
public static IEnumerable InvertedSize
{
get
{
for (int z = 1; z <= 5; z++)
{
for (int y = 1; y <= 5; y++)
{
for (int x = 1; x <= 5; x++)
{
var element = DesignerLevelElement.Create(new Vector3Int(x, y, z), Vector3Int.zero);
var invertedSize = new Vector3(1f/x, 1f/y, 1f/z);
yield return new TestCaseData(element).Returns(invertedSize)
.SetName("Inverted size of element of size " + element.Size + ". Automated");
}
}
}
}
}
[TestCaseSource(nameof(InvertedSize))]
public Vector3 TestInvertedSize(DesignerLevelElement element)
{
return element.InvertedSize;
}
DesignerLevelElement.Create
calls CreateInstance<DesignerLevelElement>()