March 20, 2023
In this VR Builder tutorial, you will learn about our highly requested new feature Scene Object Tags. What are they and how to use them? In detail, you will learn the following concepts:
Previously in VR Builder, objects had to be handled and referenced one by one. Thinking of easing the development process for our users, tags were conceived as a new way of managing objects. Similar to, but not to be confused with, the Unity tags.
This new system will help you reference categories of objects in conditions and behaviors.
We will explain what you can do with tags and their features with the example of a christmas VR app! In this app, you will be able to decorate a christmas tree in VR. Since we want to use a lot of different ornaments, it would be cumbersome to reference all of them one-by-one, so using tags will come in handy! Let's get started.
The scene will be composed of our christmas tree, some spheres, light bulbs and the centerpiece: The star. In VR, the user can grab and place every ornament in the christmas tree, and the workflow should finish as any christmas tree decoration, by setting the star at the top which will activate blinking christmas lights.
For this scene we already imported VR Builder 2.6.0. If you are a new user to VR Builder, please refer to the tutorial about setting up a Unity project with VR Builder.
Let’s start by classifying the Christmas ornaments by shape, select one of the spheres and in the inspector window add a new component. Inside the Process Scene Object component
Create a spheres tag by writing the name, and clicking on Add New, in this way the tag will be created and added to the object.
To add an existing tag to another sphere, click on the drop down menu, select the desired tag and click on Add Tag.
Do this to the remaining spheres.
To remove a tag you simply have to click on the garbage can positioned to the left of the name of the tag to be removed.
To delete completely or modify an existing tag from the project, go to VR Builder Settings using Tools>VR Builder>Settings
In the “VR Builder” Collapsible menu to the left, you will find the “Scene Object Tags” section.
Here you can rename tags or delete them by using the garbage can next to the name.
This window also provides an overview of how many objects have an existing tag in the current scene. You can click on the triangle on the left to expand a list of the tagged objects, and then click the “Show” button to highlight them in the inspector.
Tags can also be used in conditions and behaviors. This new characteristic will allow the user to reference only the tag while configuring the step instead of referencing unique, existing objects.
Let’s try this by making the spheres grabbable. Select a sphere and add a grabbable component in the inspector.
Create a step called “Decoration” and go to the “Unlocked Objects” tab. We could use the “Grab object” transition, but to allow a freedom of decoration let’s add the spheres to unlocked objects. Now we can unlock all the spheres by selecting the desired tag in the dropdown menu.
And click on “Add tag to unlock list”.
A new menu with the properties to unlock the objects with said tag will appear.
Remember to check the “GrabbableProperty” and “TouchableProperty”.
To end the decoration step, how about we finish off by positioning a star on the top of the tree?
Let’s create a “Snap Object” transition with the star.
By adding this step the spheres will remain grabbable until the star object is positioned.
It’s also possible to add multiple tags to objects, this will allow the user to classify and handle them from a general manner to a particular one.
In this case we could experiment with this by adding an “ornaments” tag, we can add this tag to the spheres and to the star at the top.
The basic Enable/Disable Object behaviors now received tag support: let’s try them out.
Select all the light 3D models, and add in the Process Scene object, add the new scene object tag. In this case it will be lights, in this manner we can add to any number of objects the same tag.
But, what does it mean if you already have some tag marked in italics when you select several objects? Well, that means that a tag is present on some but not all objects.
If you would like to fix this, you can remove the tag, or add the tag to the rest of the items.
We can set the christmas lights in this step, inside the Process Editor create a new step.
In this step, we should create a behavior sequence, this will allow the selected behaviors to repeat themselves after completing
Inside the behavior sequence we create 4 behaviors, which will be triggered consecutively in this order:
And click on the “Repeat” checkbox.
This is how we will simulate the blinking of the lights.
As a final touch, you could have a loop in this demo by connecting both steps.
We still need a transition for the light step to move into the decoration step. Let’s set the “Grab Object with Tag” Transition. And referencing a tag that’s present on the star. In my case, I added the “star” tag to it.
In this VR Builder tutorial you have learned what the tags are and how to make use of them.
You can improve this demo by augmenting the amount of tags and different behaviors to them, attempting to create a spawner for the spheres or adding more different types of ornaments.
If you have any further questions, please join the VR Builder community on discord and get in touch with VR Builder users and developers.