Scriptable Objects and dialog systems

I’m building a dialog system using scriptable objects, and there are times that I’d like to link dialog results to in-game objects. For example, in talking with an NPC, he asks “Which door should I open?”, and each answer is tied to one of three doors (ie. "Please open door #1). Since I can’t store a link to a runtime object (hierarchy object) in the scriptable object, I’ve been storing the NAME of the object to activate (in this case, which door).

I really don’t like this solution. I’m looking for recommendations for a better way to model this.

Hi @Jinxology, an optional way (thats easy to implement) could be to use a unique tag for the item, and set that unique tag in the scriptable object.

Me personally, I would probably set up a manager object, which manages interactives like this. Each interactive object would have a script attached that registers itself (maybe in Awake) with that manager, who stores the object and a unique name for that object internally. Then, the scriptable object would store that unique name. And when needed to highlight the object in question, it would make a call to the manager using that unique name, who uses it to do whatever it needed to highlight the linked object. Here’s a quick example:

<pre>public class HighlightManager : MonoBehaviour { private Dictionary<string, Transform> _List = new Dictionary<string, Transform>(); public void register(string uniqueName, Transform linkedObject) { this._List.Add(uniqueName, linkedObject); } public void highlightObject(string uniqueName) { if(!this._List.ContainsKey(uniqueName)) { throw new System.Exception("Invalid name"); } Transform linkedObject = this._List[uniqueName]; // do something with linked object } } </pre>
<pre>public class HighlightLink : MonoBehaviour { public string uniqueName = ""; private void Awake() { highlightManager.register(this.uniqueName, this.transform); Destroy(this, 0.02f); } }</pre>