1

I am trying to load a list of structs from a ScriptableObject which I load with Resources.Load. The Resources.Load call is not returning null, and appears to "load" the scriptable object. I then attempt to retrieve a List of struct from the loaded SO like so :

void LoadCheckpoints(string sceneName){

    CheckpointData attemptLoad = Resources.Load<CheckpointData>("CHECKPOINTDATA/checkpointData" + sceneName);

    if(attemptLoad != null){
        
        data = attemptLoad;
        sceneEntries = data.sceneEntries;

however this list data.sceneEntries will raise a null reference exception. Am I missing something about the use of scriptable objects? Can I not save a list to a scriptableobject and then load it later with resources.load?

1 Answer 1

1

I figured this out, for anyone that stumbles on this issue, the struct being stored in the list needs to serializable.

The definition of the struct should look like :

[System.Serializable]
public struct MyStruct {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.