Book Image

Mastering Unity Scripting

By : Alan Thorn
Book Image

Mastering Unity Scripting

By: Alan Thorn

Overview of this book

Table of Contents (17 chapters)
Mastering Unity Scripting
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Procedural meshes


Although Unity now offers a Quad primitive from the application menu, which you can access by navigating to GameObject | 3D Object | Quad, it's still useful to know how to create geometry manually, such as Quads. There are several reasons for this. First, you'll frequently need to edit vertices in the script to move, animate, or distort meshes for various effects to create, for example, a jelly-like surface in a platform game that bends and wobbles whenever characters step on it. Second, you'll need to edit the UV coordinates of a mesh, perhaps, to create animated or scrolling-texture effects, as shown here:

Generating meshes from script

Consider the following code sample 9-2, which should be included inside the Editor folder of a project. It creates an editor add-on that generates a Quad in script with full customization over the location of the mesh pivot point. As we'll see in the code comments, this sample features many useful tips:

001 //EDITOR CLASS TO CREATE QUAD MESH...