Game Development Reference
In-Depth Information
If you create a private variable, it will only be visible within the current class in the code,
for example:
private float myPrivateVariable;
If you create a variable property with a public property getter (
get
), it will be visible to
any reference in the class but
not
in the editor, for example:
private float myPrivateVariable;
public float myPublicProperty
{
get { return myPrivateVariable; }
}
The pattern you use is up to you, based on how you need to access/control the property.
You can also customize the visibility of the properties in the editor using the
([Serial-
izeField]
and
[HideinInspector]}
attributes; more information on this will be
provided in
Chapter 12
,
Deployment and Beyond
, and
Appendix
,
Additional Resources
.
To ensure that we can also anchor the command bar to a region on the screen, we will en-
able it to be placed relative to a fixed position such as top-left and bottom-right. To do
this, we will first need a new
enum
state for all the positions we are going to support. So,
create a new script in
Assets\Scripts\Classes
called
ScreenPositionAn-
chorPoint
and replace its contents with the following:
public enum ScreenPositionAnchorPoint
{
TopLeft,
TopCenter,
TopRight,
MiddleLeft,
MiddleCenter,
MiddleRight,
BottomLeft,
BottomCenter,
BottomRight
}