Page 1 of 1
How to remove an inky story that has been added to the database at runtime?
Posted: Mon Oct 02, 2023 7:54 pm
by sawiyon
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.
Re: How to remove an inky story that has been added to the database at runtime?
Posted: Mon Oct 02, 2023 8:18 pm
by Tony Li
Hi,
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?
Posted: Tue Oct 03, 2023 6:01 am
by sawiyon
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?
Posted: Tue Oct 03, 2023 8:41 am
by Tony Li
Hi,
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?
Posted: Tue Oct 03, 2023 11:40 am
by sawiyon
Thanks, this helped me to get on the right track!
Re: How to remove an inky story that has been added to the database at runtime?
Posted: Tue Oct 03, 2023 12:18 pm
by Tony Li
Glad to help!