Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want DialogueRunner.AddScript(string text) back! #43

Open
Gumoumou opened this issue Oct 12, 2020 · 3 comments
Open

I want DialogueRunner.AddScript(string text) back! #43

Gumoumou opened this issue Oct 12, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Gumoumou
Copy link

Is your feature request related to a problem? Please describe.
For older version of Yarnspinner I could use AddScript(string text) to add dialogue in game,that is very flexible and easy to use.
But now I have to use Add(YarnProgram scriptToLoad) , it require a YarnProgram(Is there a way to create YarnProgram at runtime?)
I want add dialogue at runtime !
Describe the solution you'd like
I want DialogueRunner.AddScript(string text) back!
Or a method that allow me to create YarnProgram at runtime!

@Moxie-Cat
Copy link

You don't need to "create" a YarnProgram at runtime, you can just reference a pre-existing one.
For example, I have a "level properties" object that holds a public YarnProgram variable/reference. When the object is loaded, it calls DialogueRunner.Add(reference).

@radiatoryang
Copy link
Contributor

I won't speak for Secret Lab folks but I imagine we won't be implementing this in Yarn Spinner Unity since it goes against a lot of the tool design, which is about pre-compiling the bytecode to do static analysis and other nice things etc.

But if you (or anyone who googles this later) want to hack this in yourself, the code in /Editor/YarnImporter.cs looks pretty straightforward to copy+paste and modify for your own C# script. YarnImporter.ImportYarn() basically just reads all the text from a .yarn file and feeds it into Yarn.Compiler.Compiler.Compile()... make sure you include using Yarn.Compiler;

https://github.com/YarnSpinnerTool/YarnSpinner-Unity/blob/develop/Editor/YarnImporter.cs#L221-L245

@desplesda
Copy link
Contributor

Support for runtime compilation is actually a use case I'm seeing quite often, and it's highly likely that we'll include support for it in a future release. Not 2.0, but probably not too far after that. I'll leave this issue open for now, but it may get closed as a duplicate if we end up creating a main "we should allow runtime compilation" ticket.

@desplesda desplesda added the enhancement New feature or request label Jul 9, 2021
@parisba parisba added this to the v2.1 milestone Oct 27, 2021
@desplesda desplesda self-assigned this Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants