Call method of a behaviour from a scripotableobject
Hi,
I have multiple objects in my scene with an NPC behaviour. That behaviour contains a reference to a ScriptableObject Dialogue. All NPCs have the same Dialogue but needs to call a method from the NPC when the dialogue ends, knowing that the method called can vary from). For some reasons I need that method to be known by the Dialogue object. The problem is that we can't expose UnityEvent as it does not inherit from Object.
The solution I came up with is I created another ScriptableObject DialogueEvent which contains a UnityEvent. Each NPC references a DialogueEvent to which it adds the appropriate method The dialogue too references a DialogueEvent which is exposed so I can specify a different DialogueEvent per NPC. That way when a dialogue ends, the Dialogue invokes the GameEvent which call the method of the NPC who plays the dialogue.
But I'm not fully satisfied as I need the create an asset (the GameEvent) for each NPC just to reference one method. So I wonder if someone has a better idea on how to solve this problem.
Your answer
Follow this Question
Related Questions
Adventure interactionSystem Structure (ScriptableObject,MonoBehavior,POO?) 0 Answers
ScriptableObject ExecuteInEditMode issue 1 Answer
Custom Editor for embedded ScriptableObjects list 2 Answers
Instantiating a GameObject from a ScriptableObject 1 Answer
Public jagged array not showing up in scriptable object inspector 0 Answers