Game Development Reference
In-Depth Information
You might also want to check out the rest of Fredrik's other free assets in the repository.
The command bar
Starting with the command bar manager, create a C# script called CommandBar in As-
sets\Scripts and replace its contents with the following class definition and proper-
ties:
using UnityEngine;
using System.Collections;
public class CommandBar : MonoBehaviour {
private CommandButton [] commandButtons;
public float buttonSize = 1.28f;
public float buttonRows = 1;
public float buttonColumns = 6;
public float buttonRowSpacing = 0;
public float buttonColumnSpacing = 0;
public Sprite DefaultButtonImage;
public Sprite SelectedButtonImage;
private float ScreenHeight;
private float ScreenWidth;
}
Note
Remember, where CommandButton is referenced, it will show as an error until we add
the CommandButton class to the next section.
The properties should speak for themselves: an array for the buttons that the bar is man-
aging, settings related to button's positioning, two images to use for the base button back-
drops, and finally a couple of properties to manage the screen's real estate that the com-
mand bar will be drawn in.
Next, we need a few controlled properties. These will be accessible in the code but not
visible in the editor because they are not marked as [SerializeField] :
Search WWH ::




Custom Search