Compile using Script Generator - WIGUx/WIGUx-Samples GitHub Wiki
This guide provides instructions on setting up a Unity project for creating UGC (User-Generated Content) compatible with EmuVR and using the EmuVR Scripter tool.
- Creating a New Unity Project
- Setting Up the Scene
- Creating Materials
- Adding a Capsule Object
- Adding a Script
- Exporting UGC
- Using the EmuVR Scripter
- Final Step with WIGUx Manager
-
Open Unity and create a new project using Unity editor version 2018.4.12f1.
-
In your project, go to:
Assets -> Import Package -> Custom Package...

- Select the
UGC_Kit_0.12
package from your download location.

- With everything selected by default, click on
[Import]
.

- After the import, the
UGC KIT
folder (and possibly other folders) will appear in your project.
Do not edit anything inside the UGC KIT folder or its contents.

- Save the project:
File -> Save
and thenFile -> Save Project
.
Tip: Save regularly to avoid losing changes.

- In the hierarchy, right-click on
SampleScene -> GameObject -> 3D Object -> Plane
to add a plane.

- This plane will serve as the floor for testing, so objects don't fall endlessly.
- Note: This plane will not be exported as UGC.
- Go to
Assets -> Create -> Material
and create two materials.

- Rename the materials with descriptive names:
- Example:
Floor
for the plane. - Example:
CuboLoco
for an object to be added later.
- Example:

- To customize a material:
- Select the material and click the white color box in the Inspector.

- Choose a color, and the material will update in the scene.

- Repeat the process for the second material.

- Drag the
Floor
material onto the plane in the scene to apply the color.
The plane’s color will change, and the material will appear in the Inspector.


- In the hierarchy, right-click:
GameObject -> 3D Object -> Capsule
.

- Adjust the scale and position to fit the scene.

- Apply the
CuboLoco
material to the capsule the same way you did for the plane.

- Select the capsule and click on
[Add Component]
. - Search for
UGC Info
and add it. This will:

- Add a
RigidBody
component, allowing the object to interact with physics.

- Press
PLAY
to test:
We see that the object falls to the ground (thanks to the newly added RigidBody) and is stopped by our ground plane.
Now, we edit the top 3 fields: Click on Create prefab asset.
Then, choose the folder where we want to export the UGC.
We highly recommend using C:\EmuVR\Custom\UGC\
(or wherever your installation is located).
Now, click "Export UGC" and your UGC will be created with the name you gave it (e.g., Cucumber) along with an additional value (_5c751a26).
We shouldn’t make any changes.
If we now open EmuVR on our headset, we will see a nice green cucumber available to select in our room.
Now let's get to the interesting part, the scripts, which broadly speaking are what gives life to the objects.
Suppose we want to make this cucumber change color every second...
- Select the capsule and click
[Add Component]
. - In the search box, type the script name (e.g.,
CambiaColor
). Since it doesn't exist, Unity will prompt you to create a new script.
- Click
New Script
, thenCreate and Add
.
- The script will be added to the Inspector, and a new file will be created in the
Assets
folder.
- Double click on the script to open it and edit it (recommended with Visual Studio) and this is the structure of the newly created script:
- Double-click the script to open it in Visual Studio. The initial structure of the script will be:
using System.Collections;
using UnityEngine;
public class CambiaColor : MonoBehaviour
{
// Reference to the Renderer of the object to change the color
private Renderer objectRenderer;
// Start is called before the first frame update
void Start()
{
// Gets the Renderer of the object
objectRenderer = GetComponent<Renderer>();
// Start the coroutine that changes the color
StartCoroutine(ChangeColorEverySecond());
}
// Coroutine that changes the color once every second
IEnumerator ChangeColorEverySecond()
{
while (true) // Infinite loop to change color continuously
{
// Wait 1 second
yield return new WaitForSeconds(1f);
// Generate a random color
Color newColor = new Color(Random.value, Random.value, Random.value);
// Assign the new color to the object's material
objectRenderer.material.color = newColor;
}
}
}
Once we save the changes to our code and press PLAY
in Unity, we can observe that the script works perfectly, and the object's color changes every second.
Ahora tenemos nuestro código funcionando en Unity, pero este proyecto no es compatible con WIGUx, para facilitar el proceso hemos creado una herramienta que utilizará el script que hayamos creado y generará un ensamblado (.dll) en la carpeta de EMUVR\WIGUx\modules que WIGUx sabrá interpretar en la carga inicial.
It’s important to understand that this method has a significant advantage in its ease of testing, as it works just like developing a game directly in Unity. However, the downside is that you won’t have access to EmuVR or WIGUx APIs, which could be a limitation in more advanced module scenarios. If this applies to your case, we recommend checking out the section on Building with Visual Studio.
Additionally, note that before generating the UGC, you must remove any custom scripts associated with it. Including scripts will cause the UGC to malfunction and fail to load properly in EmuVR.
Once you've tested the script and confirmed that it works:
-
Right-click on the "Change Color (Script)" component in the Inspector.
-
Select
Remove Component
. This ensures that the UGC will be exportable without any issues.Note: Although the script is removed from the object (e.g., the cucumber), the file
CambiaColor.cs
will still exist in yourAssets
folder for future use.
- Extract the EmuVR Scripter tool to any location on your computer.
- Run
EmuVR_Scripter.exe
.
From left to right, follow these steps by clicking on each button:
-
Select Unity Script:
- Navigate to your Unity project folder and choose the script you created (e.g.,
CambiaColor.cs
).
- Navigate to your Unity project folder and choose the script you created (e.g.,
-
Select UGC Object:
- Choose the UGC object you previously exported (e.g., the cucumber).
-
Generate EmuVR Script:
- This will convert the Unity script into a format compatible with EmuVR. However, this script alone is not enough for EmuVR yet.
-
Generate DLL:
- This step compiles the script from the previous step, mixes it with other required files, and generates a descriptive
.dll
file (e.g.,Pepino_CambiaColor.dll
). - The
.dll
file will be exported to the WIGUx Modules folder. The name of the file helps identify which object the script is associated with and its functionality.
- This step compiles the script from the previous step, mixes it with other required files, and generates a descriptive
While scripts can usually be associated with different objects, it is clearer to generate a separate DLL for each script when managing multiple objects. This helps in maintaining a clear structure when handling multiple scripts and UGC items.
-
Open the
WIGUx.Manager.exe
located in the Content Manager folder. -
In the manager, you'll see all the UGC objects you’ve exported (or that were pre-installed).
-
Click on the gear icon (configuration) to open the settings window.
- If your object (e.g., the cucumber) is not listed, navigate to the folder where it's stored and drag it into the UGC box.
-
Once the object appears, select it and click
[Add Module to UGC]
.- A list of modules will appear. Select the one you just generated, which will have a descriptive name like
WIGU.ModulesPepino.CambiaColor
. - Click
OK
.
- A list of modules will appear. Select the one you just generated, which will have a descriptive name like
-
Finally, click
[Save Configuration]
and close the Content Manager.
Now, open EmuVR and enjoy your custom object (like your disco cucumber) with the custom script applied! The object should now function according to the script you created.
- Start with simple scripts to get comfortable with the process.
- Some features that are simple in Unity (like referencing objects directly from the editor) may not yet be fully supported in EmuVR.
- If you have any questions, don’t hesitate to ask on the project’s Telegram group for more help.