当前位置: 首页>>代码示例>>C#>>正文


C# GUITexture.GetScreenRect方法代码示例

本文整理汇总了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;
    }
开发者ID:BasmanovDaniil,项目名称:Whoosh,代码行数:27,代码来源:JoystickAbstract.cs

示例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;
		}
    }
开发者ID:CaminhoneiroHell,项目名称:unity-game-programming-patterns,代码行数:76,代码来源:TouchJoystick.cs


注:本文中的GUITexture.GetScreenRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。