Game Development Reference
In-Depth Information
position.y = (Height / 2);
position.x = -(Width / 2);
break;
case ScreenPositionAnchorPoint.MiddleRight:
position.y = (Height / 2);
position.x = (ScreenWidth / 2) - Width;
break;
case ScreenPositionAnchorPoint.TopLeft:
position.y = (ScreenHeight / 2) - Height;
position.x = -(ScreenWidth / 2) + buttonSize;
break;
case ScreenPositionAnchorPoint.TopCenter:
position.y = (ScreenHeight / 2) - Height;
position.x = -(Width / 2);
break;
case ScreenPositionAnchorPoint.TopRight:
position.y = (ScreenHeight / 2) - Height;
position.x = (ScreenWidth / 2) - Width;
break;
}
return anchorOffset + position;
}
With all the settings in place for the command bar, we next need to initialize it. So, add an
Awake function as follows:
void Awake()
{
ScreenHeight = Camera.main.orthographicSize * 2;
ScreenWidth = ScreenHeight * Screen.width / Screen.height;
}
This simply displays the current screen's size, which will be used to scale the command
bar to the screen.
Search WWH ::




Custom Search