Calling ink functions externally
As with variables, functions are also global in ink. This means they can be accessed as part of any ink code that is part of the same story. As part of the Unity API provided by the Story
class, the EvaluateFunction()
method calls a function in the ink code based on the name passed to it. Because functions in ink are global, they can be called from outside the story itself. However, unlike working with the variablesState
property and only accessing a single value, multiple values can be passed to an ink function at one time. Additionally, the EvaluateFunction()
method can be configured to return the text output within the ink function or any returning data, too.
In this section, we will begin by testing whether an ink function exists using the HasFunction()
method. Next, we will examine how the EvaluateFunction()
method is the preferred option for complex data or multiple data values when communicating between Unity and ink. Finally, we will review...