Skip to content
Xytabich edited this page Feb 24, 2022 · 12 revisions

Katsudon basics

Compilation

Katsudon searches for all MonoBehaviour's assemblies marked with the UdonAsm attribute. This will also include MonoBehaviour'y located in ready-made libraries (dll files). Then these scripts are compiled and files with a compiled program for udon are created next to the script or library file.

All Katsudon types are marked with Guid, and these Guid's are unique to each pc. Therefore, when transferring scripts to another PC, the Guid's will be different for the same types.

All classes are compiled and stored directly in SerializedUdonProgramAsset, bypassing UdonAssemblyProgramAsset. This creates less garbage in the project, and the program is used to link the script and the UdonBehaviour on scene. Therefore, be careful not to delete this asset, otherwise the links on the scene will be broken.

Note: if you have problems with the build or you want to rebuild all assemblies, use the Katsudon/Force Rebuild menu.

Project

Katsudon caches Udon-supported functions in advance, and there is a file named Katsudon/Editor/Cache/UdonPartsCache.cs for this. Sometimes an error can occur in this file - this can happen when updating the version of Udon, for example. In this case, you can simply delete the file and it will be recreated. If, for some reason, Katsudon did not rebuild this file, and you get errors about unsupported functions, you can manually rebuild it using the Katsudon/Refresh Udon Cache menu.

To quickly create an environment for Katsudon scripts, there is a command Create/UDON Assembly Folder in the project menu. Basic files are created inside this folder:

  • Assembly Definition - is a unit file for defining a custom library. You can assign links to required assemblies or libraries through this file.
  • AssemblyInfo.cs - meta file, it contains the assembly label [assembly: UdonAsm].
  • csc.rsp - instructions to the compiler for an optimal build: release build and using the checked context.

Inspector and Scene

After compilation, the script can be added to any object on the stage (in the usual ways - by dragging and dropping or through the Add Component menu), then it is automatically converted to UdonBehaviour. For each UdonBehaviour using a program compiled by Katsudon, a proxy is created from the source script. This proxy is used to display the editor, so any custom editor is supported. In the inspector - UdonBehaviour with a proxy is marked with an orange line on the side.

The proxy is also used to display gizmos. Gizmos drawing events are ignored by the compiler, so any code can be executed there. You can also mark helper methods with [Conditional("UNITY_EDITOR")] so that they are not included in the build list. Note, however, that this code should only read the state and not modify or delete the proxy, as this may lead to unexpected behavior.

In the playmode, all changes that occur to the variables in the UdonBehaviour are copied to the proxy, so the value of these variables is always up to date. However, only changes registered by the unity editor are passed to the UdonBehaviour.

Clone this wiki locally