TemplateTools Does Not Exist in the Current Context?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Unrighteous
Posts: 36
Joined: Thu Mar 17, 2022 5:32 pm

TemplateTools Does Not Exist in the Current Context?

Post by Unrighteous »

Hello again,

I've been trying to figure this out on my own, but I'm afraid I don't know enough about scripting to make any further progress. I'm trying to to add variables to my dialogue database at edit time, and I'm following your instructions in this post: https://www.pixelcrushers.com/phpbb/vie ... 3&t=5556&p - However, I'm getting the error that "TemplateTools does not exist in the current context." This error is in both visual studio and in Unity.

Tested on 2020.3.48f1 and 2022.3.14f1 with Dialogue System 2.2.41.1

I was also wondering how to use the line EditorTools.FindInitialDatabase() - EditorTools exists (deprecated in 2022, is now ToolManager), but vs/unity can't find FindInitialDatabase().

I checked and I do have the script TemplateTools, and it's a public static class in the PixelCrushers.Dialogue namespace (I am using the namespace), but I still can't reference it in other scripts. I'm very lost.

I would appreciate any help, thank you!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: TemplateTools Does Not Exist in the Current Context?

Post by Tony Li »

Hi,

Your script should be in a folder named 'Editor' or a subfolder.

Put this line at the top of your script:

Code: Select all

using PixelCrushers.DialogueSystem;
This will give you access to the TemplateTools class, so you can create a template object like this:

Code: Select all

Template template = TemplateTools.LoadFromEditorPrefs();
API reference: TemplateTools

EditorTools is a Dialogue System class. If your script is in an Editor folder and you've added that using line above, you should be able to access it.
Unrighteous
Posts: 36
Joined: Thu Mar 17, 2022 5:32 pm

Re: TemplateTools Does Not Exist in the Current Context?

Post by Unrighteous »

Ah... I should've been able to figure that out, I'll try a bit harder next time.

Thank you!
Post Reply