Game Development Reference
In-Depth Information
and no true 3D objects, the perception of depth is not required. Play.
Nothing will happen.
Step 2. In the Project create a new Shader. Edit the Shader by double-
clicking to open and add the code given in Listing 3.1 . Because sprites are
two dimensional, usually you don't want them affected by a light in the
game environment; so they don't look shaded and washed out, a special
shader for them is a good idea.
Listing 3.1 Shader Code for an Unlit Texture with Transparency
Shader "Sprite"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans. (Alpha)", 2D) = "white" { }
}
Category
{
ZWrite On
Alphatest Greater 0.5
Cull Off
SubShader
{
Pass
{
Lighting Off
SetTexture [_MainTex]
{
constantColor [_Color]
Combine texture * constant, texture * constant
}
}
}
}
}
Step 3. The groups of icons in the center of the Game are drawn on the
SimplePlane object in the Hierarchy. Select it and note the texture atlas
material. The objective is to isolate one of the icons and draw it on the
plane when the game is run. To do this we need to modify the UV values
with script. Create a new JavaScript file called setSprite
and add the code in Listing 3.2 .
Search Nedrilad ::




Custom Search