Skip to content

How to work

Xytabich edited this page Mar 23, 2022 · 8 revisions

Beginning of work

Since Katsudon only compiles assemblies with the UdonAsm attribute, you need to create an Assembly Definition or library. When compiling, it is advisable to specify the checked context, as this will reduce the number of udon operations.

You can create an assembly folder with basic setup via the Create/UDON Assembly Folder menu.

It is not recommended to use the UdonAsm attribute for a standard Unity assembly, as Katsudon will recompile the assembly whenever the scripts in the project are changed.

In general, you can work with scripts as usual, but not all C# functionality is supported, read Difference from regular use of C# as well as the Udon documentation.

Specifics of working with Udon:

  • The order of execution is configured through the standard Unity menu, or through the DefaultExecutionOrder attribute. Note that this order only affects UdonBehaviors.
  • Types from katsudon assemblies can use some methods for UdonBehaviour, for example RequestSerialization and DisableInteractive. They are available through extension methods from AbstractCallsHelper.
  • Variables to be synchronized are marked using the Sync attribute, and you must specify the type of synchronization SyncMode.
  • To listen for a variable change event a method with the OnVariableChanged attribute is used, for which you must specify the field name.

Unlike the usual Udon functionality Katsudon also supports:

  • GetComponent's for your own types
  • All kinds of Instantiate
  • TryGetComponent
  • The print method from MonoBehaviour
  • Calling methods via SendMessage/SendMessageUpwards/BroadcastMessage, but always SendMessageOptions.DontRequireReceiver is used

VRC Events

These events work the same way as Unity events, i.e. you just need to write a method with the appropriate name and parameters anywhere in the code. A list of some events can be found in the VRChat documentation.

Method inlining

Katsudon supports inlining static methods, and private methods marked with the [MethodImpl(MethodImplOptions.AggressiveInlining)] attribute. This can help create more complex structures without high performance overhead.

These methods can also use in/out/ref arguments to access variables directly. By the way, the use of reference arguments, as well as the [ReadOnly(true)] attribute for them, will help to optimize the calls of inline methods a little.

An example of such methods: the List collection replacement.

Clone this wiki locally