Skip to content

Commit

Permalink
important notes about ui and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Sep 25, 2023
1 parent a42c37b commit 1a7f9c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/fyrox/scripting/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Script - is a container for game data and logic that can be assigned to a scene node. Fyrox uses Rust for scripting,
so scripts are as fast as native code.

## When to Use Scripts and When Not

Scripts are meant to be used to add data and some logic to scene nodes. That being said, you should not use scripts
to hold some global state of your game (use your game plugin for that). For example, use scripts for your game items,
bots, player, level, etc. On the other hand **do not** use scripts for leader boards, game menus, progress information,
etc.

Also, scripts cannot be assigned to UI widgets due to intentional Game <-> UI decoupling reasons. All user interface
components should be created and handled in the game plugin of your game.

## Script Structure

Typical script structure is something like this:
Expand Down
11 changes: 10 additions & 1 deletion src/fyrox/ui/basic_concepts/basic_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,13 @@ complex layout. Layout pass has two _recursive_ sub-passes:
2. Arrangement - the sub-pass is used to set final position and size of each node in hierarchy.

Such split is required because we need to know desired size of each node in hierarchy before we can actually do an
arrangement.
arrangement.

## Limitations

1) UI system is fully decoupled from engine scenes, this means that you can't incorporate UI widgets in a scene graph. As
a consequence, you don't have an ability to attach scripts to widgets. This limitation is intentional, and it is here
only for one reason - decoupling of UI code from game logic. Currently, there's only one right approach to make UIs -
to create widgets in your game plugin and sync the state of the widgets with game entities manually.
2) Also, FyroxEd does not have a UI editor yet, which means that you need to create UI only from code. This limitation
will be fixed in the future versions.

0 comments on commit 1a7f9c9

Please sign in to comment.