You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: manual/scripting/visual/index.md
+17-17
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3

4
4
5
-
Flax Engine supports fully Visual Scripting with lots of great features such as: hot-reloading, full-API access, debugging, Visject Surface UI, and more. In general, Visual Scriptng offers more **robust development** for rapid prototyping while mainting solid performance.
5
+
Flax Engine supports fully Visual Scripting with lots of great features such as: hot-reloading, full-API access, debugging, Visject Surface UI, and more. In general, Visual Scripting offers more **robust development** for rapid prototyping while maintaining solid performance.
6
6
7
7
Follow this documentation section to learn how to create your own visual scripts and use them in a game. Also, if you see any code examples in the *Flax Documentation* that are written in C# you can similarly use them in visual scripts since the engine uses the same API in all languages.
8
8
@@ -16,15 +16,15 @@ Follow this documentation section to learn how to create your own visual scripts
16
16
17
17
### New Visual Script asset
18
18
19
-
**Visual Script** is an in-build binary asset that contains a graph with visual script nodes, properties and metadata. This graph is processed and executed at runtime by the engine. To create new Visual Script simply navigate to the *Content* directory, *right-click* and select option **New -> Visual Script**. Then specify it's name and confirm with *Enter*.
19
+
**Visual Script** is an in-build binary asset that contains a graph with visual script nodes, properties and metadata. This graph is processed and executed at runtime by the engine. To create a new Visual Script simply navigate to the *Content* directory, *right-click* and select option **New -> Visual Script**. Then specify its name and confirm with *Enter*.
20
20
21
21

22
22
23
-
Now, editor allows you to pick the type of the visual script. You're asset will inherit from the specified base class. The default option is **Script** which fits in the most cases. You can also try extending Actor or any other type. Including custom game C++ and C# types for more robust scripting.
23
+
Now, the editor allows you to pick the type of the visual script. You're asset will inherit from the specified base class. The default option is **Script** which fits in most cases. You can also try extending Actor or any other type. Including custom game C++ and C# types for more robust scripting.
Confirm dialog with **Create** button and *double-click* on the asset icon to open the editor window.
27
+
Confirm the dialog with **Create** button and *double-click* on the asset icon to open the editor window.
28
28
29
29
### Visual Script editor window
30
30
@@ -68,20 +68,20 @@ Controls in the Visual Script Editor generally match the controls of other tools
68
68
|**Arrow keys**| Move selected nodes |
69
69
|**//**| Create comment around selected nodes |
70
70
71
-
### Adding new node
71
+
### Adding a new node
72
72
73
-
In order to add a new node **right click** on a surface background and select a node type from a popup or type its name to find it. Visual Scripts can use engine and game types API just like C++ and C# scripts.
73
+
To add a new node **right click** on a surface background and select a node type from a popup or type its name to find it. Visual Scripts can use engine and game types API just like C++ and C# scripts.
74
74
Also, when hovering the items with a mouse cursor the tooltip will show the documentation comments with details of every node.
75
75
76
76

77
77
78
78
## Visual Scripting with Flax
79
79
80
-
Visual Scripts can override base class methods, have custom properties and methods full of visual code. To understand some basic concepts let's create a simple script that prints the custom message to the log when user clicks the mouse button.
80
+
Visual Scripts can override base class methods, and have custom properties and methods full of visual code. To understand some basic concepts let's create a simple script that prints the custom message to the log when the user clicks the mouse button.
81
81
82
82
Firstly, create a new Visual Script (like in the tutorial above). Then open it and override the **OnUpdate** method - it's called on active scripts during every game update so we can use it to update the game logic.
83
83
84
-
To override method you can use the special button on the script functions list in the *Class Members* panel, or type the function name in the context menu and select the one under *Method Overrides* category. Both ways are correct.
84
+
To override the method you can use the special button on the script functions list in the *Class Members* panel, or type the function name in the context menu and select the one under the*Method Overrides* category. Both ways are correct.
85
85
86
86
| Use button | Use context menu |
87
87
|--------|--------|
@@ -94,36 +94,36 @@ Now, we can use the function output impulse box to run custom script logic.
94
94
> [!Note]
95
95
> See that all functions in the script graph are listed under the *Functions* group inside the *Class Members* panel. You can use it to easily navigate to them or edit them.
96
96
97
-
Next step is to add **If** node that will use **GetMouseButton** method (from **Input** class) result as a *Condition*.
97
+
The next step is to add the **If** node that will use the **GetMouseButton** method (from the**Input** class) result as a *Condition*.
98
98
You can *right-click* on *GetMouseButton* node and press **Convert to pure method**. This will change the method to not use input and output signals, which is useful for typical getter nodes that just return the state value.
99
99
Set button to **Left** as input for *GetMouseButton* to check when that button goes down (is clicked by the user).
100
100
101
101

102
102
103
-
Then, let's add a property to the script with a message to print. To do this, press **Add parameter...** button and select the type of the parameter - use **String** in this example. Then *double-click* on the `New parameter` name label to rename it to **Message**.
103
+
Then, let's add a property to the script with a message to print. To do this, press the **Add parameter...** button and select the type of the parameter - use **String** in this example. Then *double-click* on the `New parameter` name label to rename it to **Message**.
Here you can specify the default message text we gonna print. It can be set also on instance of this script after adding it to the actor on the scene.
107
+
Here you can specify the default message text we gonna print. It can be set also on an instance of this script after adding it to the actor on the scene.
108
108
109
-
Finally, let's use **Log** method from *Debug* class that prints the custom message.
109
+
Finally, let's use the **Log** method from the*Debug* class that prints the custom message.
Then, connect it with *True* output of the *If* node that so the *Log* will be executed when user clicks the mouse button. Add **Get Message** node or drag and drop your new parameter into the surface to connect its value with the *message* input in the *Log* method.
113
+
Then, connect it with the *True* output of the *If* node so the *Log* will be executed when the user clicks the mouse button. Add the**Get Message** node or drag and drop your new parameter into the surface to connect its value with the *message* input in the *Log* method.
The last step is to add this script to an actor on the scene, set the Message property, and hit play to see the results! Every time user clicks the given mouse button it prints the custom log message.
117
+
The last step is to add this script to an actor on the scene, set the Message property, and hit play to see the results! Every time the user clicks the given mouse button it prints the custom log message.
118
118
119
119

120
120
121
121
Feel free to start coding your game logic in Visual Scripting language!
122
-
Also, since Visual Scripting uses C# API of the engine you can use this [API reference](https://docs.flaxengine.com/api/FlaxEngine.html).
122
+
Also, since Visual Scripting uses the C# API of the engine you can use this [API reference](https://docs.flaxengine.com/api/FlaxEngine.html).
123
123
124
124
## Events in Visual Scripts
125
125
126
-
When working with physics and gameplay you might want to handle collision or **trigger events** inside VIsual Script. To see how to do it follow this documentation section related to [Events](events.md).
126
+
When working with physics and gameplay you might want to handle collision or **trigger events** inside Visual Script. To see how to do it follow this documentation section related to [Events](events.md).
127
127
128
128
## Interop with C\+\+
129
129
@@ -132,7 +132,7 @@ To call Visual Script from C\+\+ you can do it as in the following example:
132
132
```cpp
133
133
#include"Engine/Content/Assets/VisualScript.h"
134
134
..
135
-
VisualScript* myScript = ..; // Assign it from editor or load asset manually
135
+
VisualScript* myScript = ..; // Assign it from the editor or load the asset manually
136
136
ScriptingObject* instance = nullptr; // Null for static methods, assign to object instance to call member function
137
137
Span<Variant> parameters; // Here you can pass parameters to the function
138
138
Variant result = VisualScripting::Invoke(myScript->FindMethod("My Func"), instance, parameters);
0 commit comments