GameObjects and Components
In the world, it is very common to create objects or modify or add specific components to objects.
ZEPETOScript supports the same interface as that used in the Unity script.
Creating and removing game objects:
To get GameObjects components or add new ones, use GetComponent or AddComponent.

Check the full code example for the GameObject Component.
Here's an example that covers the creation and property modification of GameObject, addition of components, and destruction.

The Find related methods also support the same interface style in ZEPETOScript as in Unity script.
Methods | Description |
---|---|
GameObject.Find() | - It finds and returns an active GameObject object based on the name in the current Scene. - Returns null if not found. |
GameObject.FindGameObjectWithTag() | - It finds and returns an active GameObject object based on the tag in the current Scene. - Finds and returns the first object matching the specified tag among the active objects, returns null if not found. |
GameObject.FindGameObjectsWithTag() | - Finds all active GameObject objects with a specific tag in the current Scene and returns them as an array. - Returns an empty array if none are found. |
For the example, set up the Scene as follows:
- Add several 3D objects and specify all their Tags as 3D.
- Create an Empty Object to attach the script to, and rename it to FindSample.


- The inspector is empty when you add a script in the FindSample object.

- Press the Play button to run it, and you can confirm in the Inspector window that each object has been assigned and check the success of finding objects through the console window.
Let's explore how to create prefabs during runtime.
- First, add a 3D object > Cube to the Scene.

- Press Add Component in the inspector of Cube, and add Rigidbody.

- Then drag the Cube to the project area to make it a prefab.

Since we will utilize the Prefab, delete the Cube in the Scene.
- Please write the script below.
- Then return to the Unity editor, drag the prefab to the script inspector to add it.

- Press the play button to check that a 3D Object is created and falls from above every second.
Click the links below to learn more about the Unity GameObjects and Components offered by ZEPETOScript.

📘 Creating GameObjects https://docs.unity3d.com/2020.3/Documentation/ScriptReference/Object.Instantiate.html
📘 Destroying GameObjects https://docs.unity3d.com/2020.3/Documentation/ScriptReference/Object.Destroy.html
📘 Using components https://docs.unity3d.com/kr/current/Manual/UsingComponents.html