Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Enhancing Virtual Reality Experiences with Unity 2022

You're reading from  Enhancing Virtual Reality Experiences with Unity 2022

Product type Book
Published in Nov 2023
Publisher Packt
ISBN-13 9781804619537
Pages 566 pages
Edition 1st Edition
Languages
Author (1):
Steven Antonio Christian Steven Antonio Christian
Profile icon Steven Antonio Christian

Table of Contents (25) Chapters

Preface 1. Part 1: Philosophy and Basics of Understanding Virtual Reality
2. Chapter 1: Philosophy of Building Immersive Experiences 3. Part 2: Technical Skills for Building VR Experiences in Unity (Assets, GameObjects, Scripts, and Components)
4. Chapter 2: Building VR Scenes in Unity 5. Chapter 3: Working with Inputs and Interactions 6. Chapter 4: Using Game Objects, Materials, and Prefabs 7. Chapter 5: Implementing Animation – Physics and Colliders 8. Chapter 6: Lighting Your Worlds and Experiences 9. Chapter 7: Creating Immersion with Sound 10. Chapter 8: Working with C#, Unity Events, and Input Actions 11. Chapter 9: Unlocking the Power of Render Pipelines 12. Part 3: Projects: Putting Skills Together
13. Chapter 10: Design Thinking for Virtual Reality Experiences 14. Chapter 11: Adding Audio to a Virtual Reality World 15. Chapter 12: Building an Art Gallery 16. Chapter 13: Animating a Virtual Reality Experience 17. Chapter 14: Recording Virtual Reality Videos 18. Chapter 15: Enhancing Virtual Reality Rigs 19. Chapter 16: Triggering Actions in Virtual Reality 20. Chapter 17: Destroying Objects in Virtual Reality 21. Part 4: Final Touches
22. Chapter 18: Optimizing Your Virtual Reality Experiences 23. Index 24. Other Books You May Enjoy

Using Game Objects, Materials, and Prefabs

In this chapter, we will delve deeper into the world of GOs in Unity and explore how they can be utilized to enhance the visual quality of VR experiences. We will cover a variety of essential topics, including creating a custom grid with primitive GOs, assigning custom materials to GOs, and replacing VR hands and objects with custom game objects. Additionally, we will delve into the use of ProBuilder and Polybrush to create custom 3D shapes and environments, as well as the use of Unity packages and FBX Exporter for project organization and asset management.

Throughout the chapter, we will work on several projects that will help solidify your understanding of these concepts. These projects will include creating a custom grid of primitive GOs with custom materials, replacing VR hands with custom game objects from the Unity Asset Store, and creating a custom VR demo room to test advanced VR features. By the end of this chapter, you will have...

Creating a grid with Primitive GOs

GOs are the building blocks of Unity scenes. They can be anything from simple shapes to complex characters and vehicles. Each GO has a Transform component that defines its position, rotation, and scale in the scene. It also has one or more other components that determine its behavior and appearance. GOs can be organized into hierarchies for the easy management of complex scenes. They are important because they form the foundation of Unity scenes and are the primary way to represent and manipulate objects within the engine. They provide organization, reusability, modularity, and improved performance.

To learn more about GOs, visit the Unity documentation here: https://docs.unity3d.com/Manual/GameObjects.html.

In this section, we will create a scene consisting of four different primitive shapes arranged in a 3 x 4 object grid. Each shape will be placed 2 meters (m) apart from one another. The shapes will include small (0.5 m), medium (1 m), and...

Creating a materials library

We will be creating a grid of spheres that we can use to assign custom materials to. We call this a materials library. This grid of spheres will serve as our materials library for future projects. By creating a materials library, we will be able to easily access and apply different materials to our 3D models without having to create new materials each time. Additionally, having a materials library will make it easier to maintain consistency in our projects.

We will begin by creating a grid of spheres in a 3D modeling software of your choice. Then, we will assign different materials to each sphere. These materials can be textures, colors, or even patterns. Once we have assigned materials to each sphere, we will be able to easily select and apply them to other 3D models in our project.

Creating a grid of spheres

We will be building a materials grid in Unity. This grid will serve as a library of different materials that we can use in future projects...

Assigning custom materials and assets to GOs

One important aspect of a VR rig is the visual representation of the hands, as this allows the user to see and interact with virtual objects in a realistic way.

To enhance the visual experience, we can add custom visuals for the hands on our VR rig. This can be done by exploring options available on the Unity Asset Store, which is a marketplace that offers a wide range of assets and tools for Unity developers. For our example, we will be downloading custom VR hand assets and a custom transparent ghost shader.

Custom VR hand assets are pre-made 3D models of hands that can be imported and used in Unity to replace the default primitive cubes or spheres that are often used to represent hands in VR. These assets can be more detailed and realistic, providing a more immersive experience for the user.

A custom transparent ghost shader is a type of shader that controls how light interacts with a 3D object. It is responsible for adding transparency...

Creating a custom VR demo room with ProBuilder

In this section, we will be creating a VR demo room, starting from the ground up. We will begin by using Google Drawings to design the floor plan for our demo room, visualizing the layout and dimensions of the space. This floor plan will serve as the blueprint for our 3D model, which will be created using ProBuilder. ProBuilder is a powerful tool in Unity that allows us to create and modify 3D models quickly and easily. With ProBuilder, we will convert the floor plan into a fully realized 3D space, complete with walls, flooring, and ceilings.

Once the basic structure of the demo room is in place, we will then turn our attention to decorating the space. Using Polybrush and custom assets from the Unity Asset Store, we will add furniture, artwork, and other decorative elements to the room, giving it a unique and personalized feel. Polybrush allows us to paint and sculpt on 3D models, giving us complete control over the look and feel of...

Designing a demo room floor plan with Google Drawings

We will now take a break from Unity and work in Google Drawings to create a floor plan for our 3D demo room. Designing a floor plan for a 3D room in Google Drawings is a good idea because it allows you to plan out the layout and dimensions of the room before creating it in 3D software. This allows you to make changes and adjustments to the layout more easily and quickly, as well as visualize the space in a clear and easy-to-understand manner. Additionally, using Google Drawings allows you to easily share and collaborate on the design with others, making it a great option for team projects. Using a floor plan can also help you ensure that the room is functional and efficient and that all necessary elements are included in the design. It also helps you to save time and avoid errors while modeling a 3D room. Overall, creating a floor plan in Google Drawings can help you to create a well-designed and functional 3D room.

To create...

Converting the floor plan into a 3D room with ProBuilder

Now that we have our custom shapes and are able to replace different things with 3D objects from the asset store, it’s time to beef up our demo scene by creating a custom container environment for us to navigate. We will do that using ProBuilder.

ProBuilder is a Unity extension that allows you to create and edit 3D geometry directly within the Unity Editor. It provides a set of tools to easily create and manipulate 3D shapes, such as spheres, cubes, and cylinders, as well as more complex meshes. ProBuilder also includes tools for editing and optimizing meshes, such as welding vertices and extruding faces. It allows you to create and edit 3D geometry in Unity without the need for external 3D modeling software, making it an efficient and powerful tool for prototyping and production. It also allows you to export your meshes to other 3D modeling software if needed.

To use ProBuilder in Unity, you will first need to download...

Decorating the VR demo room with Polybrush and vertex painting

Our demo room is complete and it’s time to decorate it. We will change the colors of the floor and walls to different materials we have already created and add some furniture by downloading it from the asset store.

Polybrush is a Unity extension that allows you to paint and sculpt 3D models directly within the Unity Editor. It provides a set of tools that make it easy to paint and sculpt textures, materials, and colors onto 3D models. It also allows you to edit the geometry of models, creating new shapes and forms. Polybrush can be used in conjunction with other Unity tools and extensions, such as ProBuilder and Unity’s terrain system. Some of its features include painting and sculpting tools, geometry editing tools, material blending, and Unity integration.

The major components of Polybrush are painting and sculpting tools, geometry editing tools, material blending, Unity integration, brush settings...

Creating prefabs with our GOs

We have our different GOs and scenes, and all these things work great within the scene. But what if we wanted to have a scene that has objects that we can modify, and then it could update on all the other scenes You’ll notice that every time we make a new project, we duplicate our scene, and then anything that happens in the scene that we worked on now won’t work on the other scenes. So, a way to create instances of objects that update across scenes is through the use of prefabs.

Prefabs in Unity are preconfigured GOs that can be reused multiple times in a scene or across multiple scenes. They are like templates or blueprints of GO and can contain any combination of components, such as scripts, meshes, and materials. To create a prefab, you can select a GO in a scene, drag it into the Project window, give it a name, and make changes to it in the Inspector window. These changes will be applied to all instances of the prefab in the scene...

Organizing project assets with folders in the Project tab

In Unity, the Project tab is where you can organize and access all of the assets in your project. One way to keep your project organized is to use folders to group related assets together. To create a new folder, right-click in the Project tab and select Create | Folder. You can then name the folder and drag and drop assets into it. You can also create subfolders within a folder by right-clicking on the parent folder and selecting Create | Folder. This allows you to create a hierarchical structure for organizing your assets. Additionally, you can also search for assets within a specific folder by clicking on the folder and using the search bar at the top of the Project tab. Keep in mind that changes made to the folders in the Project tab will only affect the organization of the assets in the editor and will not affect the file structure on your computer.

To organize the assets in your project with folders, go through the...

Exporting project assets with Unity packages and FBX Export

Exporting assets from Unity can be done in multiple ways, such as exporting as a file type (FBX, OBJ, or COLLADA) that can be imported into other 3D modeling software, creating and exporting Unity packages that can be used in other Unity projects, creating and exporting asset bundles for downloadable content, exporting the project as a standalone executable or web player through Build Settings, using plugins for specific platforms, and using cloud services such as Google Cloud Platform, AWS, and Microsoft Azure. The available options may vary depending on the Unity version and platform being used. Always test exported assets to ensure their proper functioning on the destination software or platform.

In Unity, there are several ways to export project assets, including Unity packages and FBX export.

Unity packages are a convenient way to share assets between different Unity projects, or to share assets with other Unity...

Summary

This chapter has provided a comprehensive overview of GOs and their crucial role in enhancing the visual quality of VR experiences in Unity. Our understanding of custom materials, creating custom 3D shapes and environments using ProBuilder and Polybrush, and proper asset management should by now have been reinforced through hands-on projects and practical applications. You should now be able to use these techniques to create a customized grid, replace VR hands with custom game objects, and design a demo room using Google Drawings, ProBuilder, and Polybrush.

We are well equipped to move forward and develop a more robust demo scene by incorporating animation and physics in Chapter 5.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Enhancing Virtual Reality Experiences with Unity 2022
Published in: Nov 2023 Publisher: Packt ISBN-13: 9781804619537
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}