Skip to content

Setup and generation

Covers what happens from writing .mochi.xml, through Unity generating the prefab, to uploading the world.

A part is the named set of objects that one .mochi.xml file represents. In this example, an entry point in Assets/Hall/ uses the part Sign from Assets/Parts/.

Assets/Hall/Hall.mochi.xml
<Hall prefab="true">
<Sign position="0 2 0"/>
</Hall>
<!-- file: Assets/Parts/Sign.mochi.xml -->
<Sign>
<Object name="Board" scale="2 1 0.1">
<MeshFilter mesh="builtin:Cube"/>
</Object>
</Sign>
File name<part name>.mochi.xml. Only the lowercase .mochi.xml extension is treated as a part
Root elementThe same name as the part, case-sensitive
Creating a fileIn the Project window, Assets > Create > MoCHI File creates an entry point template in the selected folder. The name you type becomes the file name and the root element’s name, with spaces turned into _. A name that can’t be a part name isn’t created, and the reason appears in the Console
Using a partWrite the part’s name as a tag (<Sign/>)
Where parts are searched forEverything under the project’s Assets/ and Packages/ folders (packages that Unity keeps only in its package cache are not searched). There are no imports
Duplicate part namesIf two parts share a name, using that name is an error. It’s not an error if nothing uses it
Names that can’t be usedObject, Prefab, Props, Prop, For, If, Else, Slot, At, Row, Grid and Transform cannot be used as part names (the names of the built-in elements, and Transform, which is not an element)
A part inside a partThis is allowed, but it’s an error for a part to use itself
SyntaxNumberExample
A root element whose case differs from the file nameMOCHI1003root-name-mismatch
Two parts with the same name in different foldersMOCHI3002duplicate-part-name
A file named after a built-in elementMOCHI3003builtin-part-name
A part that uses itselfMOCHI3004part-cycle

An entry point is a file whose root element has prefab="true". On save, MoCHI generates one prefab from this file.

Assets/Example/Stage.mochi.xml
<Stage prefab="true" position="0 1 0">
<Object name="Floor"/>
</Stage>
Root element attributesprefab. The value is true or false. The root element of an entry point also takes the inspect walking settings walkFrom, playerRadius, playerHeight and minPassageWidth (Root element)
An entry point’s propsThere’s no caller to pass values, so every prop needs a default
The prefab’s rootThe GameObject’s name is the part’s name. Its position is the origin and can’t be changed
What generation on save coversOnly entry points under Assets/. Files under Packages/ are not generated on save, even with prefab="true"
SyntaxNumberExample
A position written on the root elementMOCHI1005root-attribute
An entry point prop without a defaultMOCHI3008entry-prop-without-default
What triggers generationAfter the entry point, or a file it reads (a part, prefab, image, table, or material), is saved and Unity has imported it
Saving during Play modeGeneration happens after returning to Edit mode
Where generated files goOne folder per entry point, under Assets/MoCHI Generated/. The folder is named after the entry point’s path with the leading Assets/ and trailing .mochi.xml removed
ExampleAssets/Gallery/Gallery.mochi.xml generates Assets/MoCHI Generated/Gallery/Gallery/Gallery.prefab
What’s in the folderThe prefab (<part name>.prefab), material copies (Material copies), and a generation record (.mochi-record)
Files it writesOnly files whose contents change
On errorThe prefab and materials are not written; the previous output is kept (the generation record, and the <Name>.Mochi.cs of parts with a T# script, are written). The error appears in the Console as [MoCHI] <file>(<line>,<column>): error MOCHInnnn: <message>
On warningShown in the Console as [MoCHI] <file>(<line>,<column>): warning MOCHInnnn: <message>, only when generation writes or deletes a file. A save that changes nothing shows no warnings
On successThe Console shows [MoCHI] Generated <prefab path> from <entry point>.
After a package updateEvery entry point is regenerated once
Editing a generated file by handGeneration for that entry point pauses, and the Console shows an error. Uploading the world is also stopped
Discarding changesUse Regenerate (discard changes) in the generated file’s Inspector, or TsukimiCode > MoCHI > Regenerate, to discard the changes and regenerate
To change what’s generatedChange the .mochi.xml, or use a prefab override placed in the scene
A prefab saved without changesOpening a generated prefab in Unity and saving it without changing anything is not treated as a hand edit
Deleting a generated prefabThat entry point stops generating. Use Regenerate to resume it, or remove prefab="true" if generation is no longer needed
Deleting the .mochi.xmlThe generated files remain, and the Console shows a warning. If they’re no longer needed, delete them with TsukimiCode > MoCHI > Clean Up Outputs Without a Source (Deleting generated files whose source is gone)
Moving or renaming inside UnityThe generated folder moves along with it. The prefab’s GUID doesn’t change, so references from the scene are preserved

Opening a generated prefab in the Inspector shows one of these 5 messages at the top.

What is shownMeaning
Generated by MoCHI from <source file>. Edit the source file; changes made here stop the next generation.Always shown for a generated file. Select source selects the original file
This prefab was changed after it was generated, so generation is paused.Paused due to a hand edit. A Regenerate (discard changes) button appears
The last generation failed (see the Console).The last generation failed
Generation from the source is stopped.Generation is stopped
Waiting for T# to compile the T# scripts of its parts. The prefab is updated after that.Waiting for the T# scripts to compile (Two-stage generation)
MenuTsukimiCode > MoCHI > Regenerate. MoCHI > Regenerate in the Project window’s right-click menu does the same
What to selectA .mochi.xml, or an asset inside a generated folder
BehaviorDiscards hand edits and regenerates. Also resumes an entry point that had stopped generating
A file without prefab="true"Nothing is generated, and the Console shows a warning
Regenerating everythingTsukimiCode > MoCHI > Regenerate All (also under MoCHI in the right-click menu). With nothing selected, it regenerates every entry point under Assets/ in the same way

Deleting generated files whose source is gone

Section titled “Deleting generated files whose source is gone”
MenuTsukimiCode > MoCHI > Clean Up Outputs Without a Source. It is not in the Project window’s right-click menu
What it runsEntry points whose generation record is still under Assets/MoCHI Generated/ but whose .mochi.xml no longer exists. Nothing needs to be selected. As long as the .mochi.xml exists, an entry point is not a target even if prefab="true" was removed
When there is nothing to deleteNothing is deleted, and the Console shows [MoCHI] Every output generated by MoCHI still has its .mochi.xml. Nothing to clean up.
Confirmation windowAppears before anything is deleted. For each entry point it lists the source path, and the number of generated files and their folder (from the 11th on, only the count is shown). Delete deletes them; Cancel deletes nothing
What is deletedThe generated files listed in the generation record that are still in the folder, and the generation record itself. Files that MoCHI did not generate are not deleted
Deleting foldersOnly folders that end up empty are deleted, working upward under Assets/MoCHI Generated/. A folder that still holds other files (including the generated files of another entry point) is kept
Effect on scenes and prefabsInstances of a deleted prefab become Missing Prefab in the scenes and prefabs that placed them
What is shown when it finishesThe Console shows [MoCHI] Deleted the files generated from n MoCHI source(s) that no longer exist: <source paths>. Any folders that were kept are named in Kept <folder>: … on the same line. Anything that could not be deleted is named in the warning [MoCHI] Could not delete <path>.
Before PlayWhen leaving Edit mode, every entry point is checked. Anything out of date gets a Console warning after entering Play mode. Play is not stopped
Before uploading the worldWhen the world is built with the VRChat SDK, every entry point under Assets/ is checked. If an entry point whose generated prefab the uploaded scene uses has an error, is out of date, was changed by hand, or is waiting for a compile, the build stops
Entry points the scene does not useThey are checked, and a problem is reported as a warning in the Console. The build does not stop
What doesn’t stop the uploadAn entry point that has stopped generating, and an entry point whose source file was deleted
The message when it stops[MoCHI] Build stopped: n generated prefab(s) do not match their source. followed by how to fix it