本文整理汇总了C#中GUITexture.GetScreenRect方法的典型用法代码示例。如果您正苦于以下问题:C# GUITexture.GetScreenRect方法的具体用法?C# GUITexture.GetScreenRect怎么用?C# GUITexture.GetScreenRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GUITexture
的用法示例。
在下文中一共展示了GUITexture.GetScreenRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEnable
protected void OnEnable()
{
CreateVirtualAxes();
// Cache this component at startup instead of looking up every frame
gui = GetComponent<GUITexture>();
if (gui != null)
{
// Store the default rect for the gui, so we can snap back to it
defaultRect = gui.GetScreenRect();
gui.pixelInset = defaultRect;
transform.localScale = Vector3.zero;
}
transform.position = new Vector3(0.0f, 0.0f, transform.position.z);
moveStick = true;
TypeSpecificOnEnable();
if (enumeratedJoysticks)
return;
// Collect all joysticks in the game, so we can relay finger latching messages
joysticks = FindObjectsOfType<JoystickAbstract>();
enumeratedJoysticks = true;
}
示例2: OnEnable
private void OnEnable()
{
// set axes to use
useX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal);
useY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical);
// create new axes based on axes to use
if (useX) {
horizontalVirtualAxis = new CrossPlatformInput.VirtualAxis(horizontalAxisName);
}
if (useY) {
verticalVirtualAxis = new CrossPlatformInput.VirtualAxis(verticalAxisName);
}
// Cache this component at startup instead of looking up every frame
gui = GetComponent<GUITexture>();
if (gui != null)
{
// Store the default rect for the gui, so we can snap back to it
defaultRect = gui.GetScreenRect();
}
transform.position = new Vector3(0.0f, 0.0f , transform.position.z);
moveStick = true;
if (inputMode == InputMode.TouchPadPositional || inputMode == InputMode.TouchPadRelativePositional || inputMode == InputMode.TouchPadSwipe) {
touchPad = true;
getTouchZoneRect = true;
if (gui == null)
{
// no GUI on this object, so no stick to move
moveStick = false;
} else {
if (touchZone == null) {
// marked as a touchpad, but no touchzone gui assigned, so this object's
// GUI is the touchzone, and no stick to move:
touchZone = gui;
moveStick = false;
} else {
// touchpad, plus we have GUI on this object and a separate touchzone,
// so we do have a stick to move.
moveStick = true;
}
}
} else {
touchPad = false;
// This is an offset for touch input to match with the top left
// corner of the GUI
guiTouchOffset.x = defaultRect.width*0.5f;
guiTouchOffset.y = defaultRect.height*0.5f;
// Cache the center of the GUI, since it doesn't change
guiCenter.x = defaultRect.x + guiTouchOffset.x;
guiCenter.y = defaultRect.y + guiTouchOffset.y;
// Let's build the GUI boundary, so we can clamp joystick movement
guiBoundary.min.x = defaultRect.x - guiTouchOffset.x;
guiBoundary.max.x = defaultRect.x + guiTouchOffset.x;
guiBoundary.min.y = defaultRect.y - guiTouchOffset.y;
guiBoundary.max.y = defaultRect.y + guiTouchOffset.y;
moveStick = true;
}
if (gui != null)
{
gui.pixelInset = defaultRect;
transform.localScale = Vector3.zero;
}
}