Heya, I have a quick question!
I can add inky stories at runtime, but I haven't yet figured out how to remove them from the database afterward. I ask this question because I need to be able to reset the database or delete/remove a story when necessary (at runtime).
Thanks in advance.
How to remove an inky story that has been added to the database at runtime?
Re: How to remove an inky story that has been added to the database at runtime?
Hi,
No need to remove the story. To reset the data, call the DialogueSystemInkIntegration component's ResetStories() method. Example:
No need to remove the story. To reset the data, call the DialogueSystemInkIntegration component's ResetStories() method. Example:
Code: Select all
DialogueManager.instance.GetComponent<DialogueSystemInkIntegration>().ResetStories();
Re: How to remove an inky story that has been added to the database at runtime?
Hey, thank you for the quick answer! I'm sorry for the misunderstanding. I need to remove the story from the database.
Re: How to remove an inky story that has been added to the database at runtime?
Hi,
In that case, I recommend making a subclass of DialogueSystemInkIntegration and adding a method to remove it. Example:
In that case, I recommend making a subclass of DialogueSystemInkIntegration and adding a method to remove it. Example:
Code: Select all
using Ink.Runtime;
using PixelCrushers.DialogueSystem;
using PixelCrushers.DialogueSystem.InkSupport;
public class DialogueSystemIntegrationSubclass : DialogueSystemInkIntegration
{
public void RemoveStory(string storyTitle)
{
var conversation = database.conversations.Find(x => x.Title == storyTitle);
if (conversation == null) return; // No such story.
Story story;
if (!storyDict.TryGetValue(conversation.id, out story)) return; // Story not in dict.
// Remove database from DS, remove story from database, then re-add database to DS:
DialogueManager.RemoveDatabase(database);
storyDict.Remove(conversation.id);
stories.Remove(story);
DialogueManager.AddDatabase(database);
}
}
Re: How to remove an inky story that has been added to the database at runtime?
Thanks, this helped me to get on the right track!