after realizing can't use unityevents
in scriptable objects (they don't read global variable values correctly). had move solution store dialogs.
the best solution find store them in corresponding npc-prefab. convenient. leaves bad taste in mouth, feels wrong store data in prefab this. bad practice? example if refactor in dialogobject
, lost.
since can't seem store unityevents anywhere (can't serialize them json , mentioned scriptable objects don't seem handle them well) feel solution if want able use editor create dialogs.
just checking here first, stupid? there way?
i trying save list
of this:
[system.serializable] public class dialogobject { public list<pagedata> conversations = new list<pagedata>(); public unityevent postevent; //invoked on last page of dialog }
i yes, prefabs meant template create new items of type. trying save data states.
even though cannot serialize unityevent, serialize content.
if assign via inspector, can use https://docs.unity3d.com/scriptreference/events.unityeventbase.getpersistentmethodname.html
but not have problem of storage if know start goes.
second solution when assign method unityevent, store it.
void addlistener (unityaction ev) { methodinfo mi = ev.method; // use mi postevent.addlistener(ev); }
with mi reference, have name of method, type, object belongs , need.
Comments
Post a Comment