Skip to content

Exporting to UdonSharp

This exports a Behaviour written in TsukimiSharp as C# that UdonSharp reads. Use it when you hand the code to an UdonSharp project, or when you submit to a place that specifies which compiler to use.

  1. In the Project view, select the .cs of the Behaviour you want to export
  2. Choose Export as UdonSharp from the right-click menu
  3. Decide where to save it
What to selectThe .cs of the Behaviour. If you select the paired program asset instead, the menu stays grayed out
What gets exportedOnly the one you selected
Resolving type namesThis uses the same range as compiling that program does. A Behaviour that refers to a type placed in another file can be exported as it is
Where you can save itOutside the Unity project. The save window opens on the folder one level outside the project
If you pick somewhere inside the projectThe export stops and the reason is shown
Why it cannot go insideThe exported .cs is compiled by that project too, and it declares a class with the same name as the original script. The project then holds two classes of that name, and neither of them compiles
How the class name is decidedIt comes from the file name of the original .cs, not from the name you save it under. Changing the name you save it under leaves the class name as it was
CompilerThe exported .cs is compiled by UdonSharp. The optimization the TsukimiSharp compiler performs does not apply to the code after it is exported
The order of synced variablesA program built from the exported code can end up with a different order of synced variables. If the order differs, it cannot connect to instances that are still running the original program
CommentsThe comments you wrote on declarations, and the namespace declaration, remain in the exported code
Temporary variablesTemporary variables the compiler created are declared together at the top of each method. The line count grows compared with the original code
Method namesMethods that cannot be told apart by name alone, such as those implementing an interface, get a name that includes the argument types
CaseWhat is shown
The original code does not compileYou are told to fix the errors in the console and try again
The code contains something that cannot be expressed as UdonSharpYou are told which way of writing is the reason

In neither case is a file created.