Issue with Saving/Loading Unity Events

Discussion and help for Easy Save 3
Post Reply
sbmhome
Posts: 9
Joined: Thu Oct 29, 2020 9:24 pm

Issue with Saving/Loading Unity Events

Post by sbmhome »

Hi,
I just purchased Easy Save and I'm trying to use it serialize UnityEvents in one of my scripts. The Unity Events are wired up to call a method in a child gameObject.

Whats the proper way to ensure this gets repopulated correctly?

The below class below is an example of what I'm trying to save an array of....and I need to make sure the persistent calls for onActive and onInactive are correctly populated.

[System.Serializable]
public class ItemUpgrade {
public string title;
public string name;
public string description;
public int filament;
public bool isActive;
public bool purchased;


[Header("Events")]
public UnityEvent onActive;
public UnityEvent onInactive;

}


Should I just be saving the gameObject? (Its a complicated gameObject and I was trying to only save what I need.)

Please let me know whats the proper way to save them...thanks.
Attachments
EasySave3.png
EasySave3.png (262.47 KiB) Viewed 668 times
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Issue with Saving/Loading Unity Events

Post by Joel »

Hi there,

Unity provides no way of serialising UnityEvents at runtime.

If you show me the code you're using to change your UnityEvent at runtime I may be able to provide a workaround, though this depends on what changes you're making.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply