For each element, this page gives the syntax and the same fields: category, where it can be placed, allowed children, attributes, what it creates, the name when name is omitted, and what is an error. What the categories mean and the order in which elements are expanded are in Syntax overview.
<Object>, <Prefab>, <Row>, <Grid>, and part tags (hosts) accept the following 14 attributes.
Attributes
Value
Meaning
Default value
name
string
GameObject’s name
“Name when name is omitted” in each element’s section
key
string
A value that distinguishes this GameObject among its siblings (Identity and key). Not written into the prefab
Same as name
position
x y z
Position relative to the parent, in meters. Can’t be written on a GameObject under a Canvas (use anchoredPosition or anchoredPosition3D)
0 0 0
rotation
x y z
Euler angles, in degrees. Applied in the same order as Unity’s Quaternion.Euler
0 0 0. On a <Prefab>, the value of the prefab’s root
scale
x y z
Scale factor
1 1 1. On <Prefab>, the prefab root’s value is kept
active
true or false
The GameObject’s active state
true. On <Prefab>, the prefab root’s value is kept
static
Space-separated words
Static flags (static). Set on that GameObject only, not on the GameObjects under it
None. On <Prefab>, the prefab root’s value is kept
size
w h d
Size (meters, 0 or more). Used only for layout and inspect’s counts, and not written to the prefab (Layout). Cannot be written on <Row> or <Grid> (their size is the box their children are laid out in). Cannot be written on a GameObject with a RectTransform (use sizeDelta)
None
pivot
x y z (each 0 to 1)
Where the origin sits inside the size box, as fractions. 0.5 0 0.5 is the bottom center. On a GameObject with a RectTransform, it is the RectTransform’s pivot (x y)
The center of the box. 0.5 0.5 on a RectTransform
anchorMin
x y
The RectTransform’s anchorMin (only on a GameObject with a RectTransform)
0.5 0.5
anchorMax
x y
The RectTransform’s anchorMax (only on a GameObject with a RectTransform)
0.5 0.5
anchoredPosition
x y
The RectTransform’s anchoredPosition (only on a GameObject under a Canvas)
0 0. On a <Prefab> under a Canvas whose root is a RectTransform, the value of the prefab’s root
anchoredPosition3D
x y z
The RectTransform’s anchoredPosition3D. x y is anchoredPosition and z is the z of the position (in the parent Canvas’s units). Can be written only on a GameObject under a Canvas (including a <Prefab> whose root is a RectTransform). Can’t be written together with anchoredPosition, nor on the root of a Canvas (use position)
0 0 0
sizeDelta
x y
The RectTransform’s sizeDelta (only on a GameObject with a RectTransform)
100 100
Assets/Example/Plaza.mochi.xml
<Plazaprefab="true">
<!-- The fountain is static for lighting and batching. -->
A GameObject with a UI component (one that needs a RectTransform, such as Image or Button), and every GameObject under a GameObject with a Canvas. This is the same shape as objects made with GameObject > UI in Unity
Position and size
Written with anchorMin, anchorMax, anchoredPosition, sizeDelta, and pivot (each x y). The values mean the same as on Unity’s RectTransform
A GameObject whose parent has no RectTransform
Such as the root of a Canvas. Place it with position (x y z); anchoredPosition and anchoredPosition3D can’t be written
Depth
The z of a GameObject under a Canvas is the third number of anchoredPosition3D, and 0 when it is not written
Size of a Canvas root
Write sizeDelta on the root of a World Space Canvas. Without it, the root keeps Unity’s default 100 × 100 (0.1 m square at a scale of 0.001), and the warning MOCHI7001 appears. If that size is what you want, write sizeDelta="100 100" and the warning goes away
Arranging
Write HorizontalLayoutGroup, VerticalLayoutGroup, or GridLayoutGroup. <Row> and <Grid> can’t be written under a Canvas
<Prefab> under a Canvas
Placed with the type of the prefab’s root: the RectTransform attributes when the root has a RectTransform, position, rotation and scale when it has a Transform (objects under it get no RectTransform)
<Props> (at most one), hosts, component tags, <For>, <If> and <Slot>. <At> cannot be written. Component tags go on the object where the part is placed (the root of the prefab for an entry point)
Attributes
Only the 5 in the table below. The 4 other than prefab set how inspect walks, and can be written only on the root element of an entry point. They are not written into the prefab
What it creates
When generated as an entry point, one GameObject at the root of the prefab (at the origin). When the file is used as a part, the part tag where it’s used creates the GameObject
Name when name is omitted
The part’s name (name can’t be written on the root element)
What is an error
A name different from the file name (MOCHI1003, root-name-mismatch), the same name as a built-in element (MOCHI3003, builtin-part-name), an attribute not in the table below (MOCHI1005, root-attribute), walkFrom, playerRadius, playerHeight or minPassageWidth on the root element of a part that is not an entry point (MOCHI1005), a value out of range or a binding in walkFrom, playerRadius, playerHeight or minPassageWidth (MOCHI1009), a second <Props> (MOCHI1004, two-props)
One GameObject (with a Transform; with a RectTransform when it has a UI component or is under a Canvas)
Name when name is omitted
GameObject
What is an error
An attribute that isn’t a common attribute (MOCHI1005, tag-attribute), a <Transform> child (MOCHI1004, transform-element), an <At> child (MOCHI1004, at-outside-prefab), a <Props> or <Prop> child (MOCHI1004)
<Prefab src="path.prefab or model.fbx" fill="pattern" overflow="repeat" gap="x y z" …>
children
</Prefab>
Field
Description
Category
Host
Where it can live
Directly inside the root element, a host, <For>, <If>, or <At>
Allowed children
Children that change the inside of the prefab (<At>, component tags, <Slot> with path; only in a part’s file, Changes inside a prefab) and children added under the prefab’s root (hosts, <For>, <If>, <Slot> without path)
One instance of the prefab (Placing a prefab). src can also be a model file (such as .fbx), placed in the same way as a prefab. Paths also reach into prefabs nested inside the prefab (and prefab variants), using the names shown in Unity’s Hierarchy
Name when name is omitted
The name of the prefab’s root GameObject. Instances added by overflow="repeat" are named original name (1), original name (2), and so on
What is an error
No src (MOCHI1008), a src that is neither a .prefab nor a model (MOCHI2008), a model Unity has not read yet, outside Unity (MOCHI2017), changing the inside of a prefab in the entry point’s file (MOCHI3013, override-in-entry), a fill with a binding (MOCHI1009, fill-binding), overflow="repeat" without gap when there are more children than mount points (MOCHI1008, repeat-without-gap), more children than mount points (MOCHI3012, too-many-to-fill)
The mount points the children are attached to (Mount points)
None
overflow
repeat
Adds instances when there aren’t enough mount points (Repeated placement). Written together with fill
None
gap
x y z
The offset between added instances. It goes in the direction turned by the placed prefab’s rotation (the rotation written, or the rotation of the prefab’s root). Written together with overflow="repeat"
None
sizeDelta・anchorMin・anchorMax・pivot
x y
Only for a prefab whose root has a RectTransform. It overrides the value of the prefab’s root (place it with position). On a prefab whose root has a Transform it gives MOCHI1005
<PartName propName="value" … name="…" position="x y z" …>
content
</PartName>
Field
Description
Category
Host. Read as a part tag when a part with that name exists, even if a component has the same name (a MOCHI3017 warning is reported for each part at the first place it is used)
Where it can live
Directly inside the root element, a host, <For>, <If>, or <At>
Allowed children
Content from the caller (hosts, <For>, <If>, <Slot>). The content goes to a <Slot> inside the part (<Slot>). Component tags can’t be written here
One GameObject. The contents of the part’s file (except <Props>) become its children
Name when name is omitted
The part’s name
What is an error
An undeclared prop (MOCHI3005, prop-undeclared), not passing a prop that has no default (MOCHI3008, prop-missing), a prop value that doesn’t fit its type (MOCHI3006, prop-wrong-type), content with no <Slot> to go to (MOCHI2012, slot-unknown), a part that uses itself (MOCHI3004, part-cycle), two parts with the same name (MOCHI3002, duplicate-part-name), a name that is neither an element nor a part (MOCHI3001)
Directly inside <Object>, <Row> or <Grid> (adds a component), directly inside <Prefab> or <At> (changes an existing component, only in a part file), and directly inside the root element (adds it to the object where the part is placed; in a part with a T# script, the same object as the script’s UdonBehaviour). To add one under a condition, put an <Object> inside <If> and write it there
Allowed children
Only the elements of arrays of structs (<ConstraintSource>, <LOD>, <OptionData>, <Burst>; Arrays of structs)
Attributes
Written with C# property names. The attributes and values you can write are in Component list. Attributes you don’t write keep the default values Unity’s AddComponent gives. Inside a part with a T# script, values that change at runtime can be written too (Parts with a T# script). With key (a simple name of letters, digits and _, read as written), the component’s ID comes from its type and key (Identity and key). On one GameObject, each key is used once across all its components, <UdonBehaviour> included. A #key in a path names an <UdonBehaviour> only
What it creates
One component on the parent GameObject. Directly inside <Prefab> or <At>, nothing is added; existing components of the same type are changed in the order written, first, second, and so on. With add="true", a new one is added even if one of that type is there (other references can point to it)
Name when name is omitted
None
What is an error
Directly inside <For> or <If> (MOCHI1004, component-in-for), child elements (MOCHI1004), an attribute not in the list (MOCHI1005, component-attribute), changing a component the prefab doesn’t have (MOCHI3010, override-missing-component), a binding in key (MOCHI1009), a key used twice on one GameObject (MOCHI4001, component-key-twice), a key on a tag directly inside <Prefab> or <At> that changes a component already there (it can be written on a tag that adds one with add="true") (MOCHI1005), a value that changes at runtime in a list, UnityEvent or object reference attribute or in material (MOCHI9001)
Directly inside the root element, a host, <For>, <If>, or <At> (it can also be content of a part tag)
Allowed children
Hosts, <For>, <If>, <Else>, <Slot>. Component tags can’t be written here
Attributes
Only the 2 in the table below
What it creates
None. It expands its content under the parent of <For>, once per data row
Name when name is omitted
None
What is an error
No each or in (MOCHI1008), a binding in in (MOCHI2007, for-in-from-prop), a double-quoted folder("…") (MOCHI2007, data-source-double-quote), a component tag directly inside it (MOCHI1004, component-in-for), any attribute other than each and in, including slot (MOCHI1005)
Directly inside the root element, a host, <For>, <If>, or <At> (it can also be content of a part tag)
Allowed children
Hosts, <For>, <If>, <Else>, <Slot>. Component tags can’t be written here
Attributes
Only test. Write a bool value fixed at generation time
What it creates
None. When test is true, it expands its content under the parent of <If>; when false, it creates nothing
Name when name is omitted
None
What is an error
No test (MOCHI1008), a test that isn’t a bool (MOCHI5003, if-not-bool), a test whose value changes at runtime (MOCHI5003), any attribute other than test (MOCHI1005)
In a part’s file, directly inside the root element, a host, <For>, <If>, or <At>. A <Slot> with path only directly inside <Prefab>
Allowed children
None
Attributes
The 3 in the table below
What it creates
None. Of the content written as children of the part tag, it expands the content addressed to this <Slot> under the parent of <Slot>. When the file is generated as an entry point, there is no caller to pass content, so it creates nothing (Passing content with <Slot>)
Name when name is omitted
None
What is an error
Placing the same <Slot> in two places (MOCHI3011, slot-twice), a slot name the part doesn’t have (MOCHI2012, slot-unknown), a slot with a binding (MOCHI1009, slot-binding), path anywhere other than directly inside <Prefab> (MOCHI1005), child elements (MOCHI1004)
Can be written only directly inside <Prefab>. Adds the content under that GameObject inside the prefab
None
slot (written on the caller’s content)
Name
Written on a content element to choose the name of the <Slot> it goes to. Without it, the content goes to the default <Slot/>. Write it on the children inside <For> and <If>, not on <For> or <If> themselves
Component tags (change existing components on the GameObject it points to) and hosts, <For>, <If>, <Slot> (children added under the GameObject it points to)
Anywhere other than directly inside <Prefab> (MOCHI1004, at-outside-prefab), the entry point’s file (MOCHI3013, override-in-entry), no path (MOCHI1008), a path not in the prefab (MOCHI2010, at-path-not-found), any attribute other than path and active (MOCHI1005)
A second <Props> (MOCHI1004, two-props), anywhere other than directly inside the root element, a child that isn’t <Prop> (MOCHI1004), attributes (MOCHI1005, props-attribute)
No name or type (MOCHI1008), a type name not in the list (MOCHI3006, prop-type-case), child elements (MOCHI1004, prop-child), the same name as a host attribute (MOCHI3007, prop-reserved), the same name twice (MOCHI3009), a default with a binding (MOCHI5001, default-with-binding), a runtime that isn’t true or false (MOCHI1009), a default on an Object (MOCHI1005, prop-object-default), runtime="true" on an Object (MOCHI1009), an Object on a part with a T# script (MOCHI9001)
Attributes
Value
Meaning
Default value
name
Text
The prop’s name. Host attribute names (name, key, position, rotation, scale, active, static, size, pivot, anchorMin, anchorMax, anchoredPosition, anchoredPosition3D, sizeDelta) and slot can’t be used. To read it through a binding, use the form of a name
Required
type
Type name
One of bool, int, float, string, Vector3, Color, Texture, Material, GameObject, Object, matching case exactly
Required
default
A value of the type’s type
The value used when the caller doesn’t pass one. A binding can’t be written here. An Object can’t have one