Tag & Layer
You can use the Tag and Layer functions from Unity for developing a World.
Tag
You can use the Tag function the same way you used it in Unity.
Caution
You can use up to 64 Tags.

Tag Settings Location
Below is an example code for using the Tag function.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { GameObject } from 'UnityEngine';
export default class TagExample extends ZepetoScriptBehaviour {
Start() {
let findObj = GameObject.FindGameObjectWithTag("customTag");
if (findObj != null) {
console.log(`name : ${findObj.name}`);
}
}
}

Tag Example Code Execution Screen
Unity Tag information
Layer
You can use the Layer function the same way you used it in Unity.
Caution
You can use Layers number 20 to 27.

Layer Settings Location

The following is an example code for using the Layer function.
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { Camera, Input, Physics, RaycastHit } from 'UnityEngine';
export default class LayerExample extends ZepetoScriptBehaviour {
Update() {
if (Input.GetMouseButtonDown(0)) {
let ray = Camera.main.ScreenPointToRay(Input.mousePosition);
let ref = $ref<RaycastHit>();
let layerMask = 1 << 20;
if (Physics.Raycast(ray, ref, 100, layerMask)) {
let hitInfo = $unref(ref);
console.log(`name : ${hitInfo.collider.gameObject.name}`);
}
}
}
}

Layer Example Code Execution Screen
Unity Layer information
Updated 3 months ago