O'Reilly logo

HoloLens Beginner’s Guide by Jason Odom

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variables

Variables are how we store data for use in other places. Now in the preceding example, we want to change the color of an object. Here, we have a piece of code that would do just that:

rend.material.color = new Color(1f, 0.4f, 0.8f); 

In this example, we hardcoded a new color; this is considered a bad practice and should be avoided.

To help facilitate this, we use variables; a variable is a name given to space in memory or a storage area. A better way to handle the preceding problem would be to declare a variable and initialize it, or give it a value:

private Color lbColor;  
lbColor = new Color(0.1f, 0.2f, 0.5f); 

Here, the data type is Color and the variable name is lbColor, and we have stored a collection of floats that make a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required