AddReservedArea() public static method

Adds a reserved area.
public static AddReservedArea ( Rect rec ) : void
rec Rect /// Rec. ///
return void
Esempio n. 1
0
    void OnGUI()
    {
        if (enable)
        {
            GUI.depth = guiDepth;

            useGUILayout = isUseGuiLayout;

            VirtualScreen.ComputeVirtualScreen();
            VirtualScreen.SetGuiScaleMatrix();

            if (normalTexture != null && activeTexture != null)
            {
                ComputeButtonAnchor(anchor);

                if (normalTexture != null)
                {
                    if (Application.isEditor && !Application.isPlaying)
                    {
                        currentTexture = normalTexture;
                    }

                    if (showDebugArea && Application.isEditor)
                    {
                        GUI.Box(buttonRect, "");
                    }


                    if (currentTexture != null)
                    {
                        if (isActivated)
                        {
                            GUI.color = currentColor;
                            if (Application.isPlaying)
                            {
                                EasyTouch.RemoveReservedArea(buttonRect);
                                EasyTouch.AddReservedArea(buttonRect);
                            }
                        }
                        else
                        {
                            GUI.color = new Color(currentColor.r, currentColor.g, currentColor.b, 0.2f);
                            if (Application.isPlaying)
                            {
                                EasyTouch.RemoveReservedArea(buttonRect);
                            }
                        }
                        GUI.DrawTexture(buttonRect, currentTexture);
                        GUI.color = Color.white;
                    }
                }
            }
        }
        else
        {
            EasyTouch.RemoveReservedArea(buttonRect);
        }
    }
Esempio n. 2
0
 void Start()
 {
     textMesh = (TextMesh)GameObject.Find("TouchOnLayer").transform.gameObject.GetComponent("TextMesh");
     EasyTouch.AddReservedArea(rect1);
     EasyTouch.AddReservedArea(rect2);
 }
Esempio n. 3
0
	void OnGUI(){
							
		if (enable){
	
			GUI.depth = guiDepth;
			
			useGUILayout = isUseGuiLayout;
			
			if (dynamicJoystick && Application.isEditor && !Application.isPlaying){
				switch (area){
					case DynamicArea.Bottom:	
						ComputeJoystickAnchor(JoystickAnchor.LowerCenter);
						break;
					case DynamicArea.BottomLeft:
						ComputeJoystickAnchor(JoystickAnchor.LowerLeft);
						break;
					case DynamicArea.BottomRight:
						ComputeJoystickAnchor(JoystickAnchor.LowerRight);
						break;
					case DynamicArea.FullScreen:
						ComputeJoystickAnchor(JoystickAnchor.MiddleCenter);
						break;
					case DynamicArea.Left:
						ComputeJoystickAnchor(JoystickAnchor.MiddleLeft);
						break;
					case DynamicArea.Right:
						ComputeJoystickAnchor(JoystickAnchor.MiddleRight);
						break;
					case DynamicArea.Top:
						ComputeJoystickAnchor(JoystickAnchor.UpperCenter);
						break;
					case DynamicArea.TopLeft:
						ComputeJoystickAnchor(JoystickAnchor.UpperLeft);
						break;
					case DynamicArea.TopRight:
						ComputeJoystickAnchor(JoystickAnchor.UpperRight);
						break;
				}
			}
			
			if (Application.isEditor && !Application.isPlaying){
				VirtualScreen.ComputeVirtualScreen();
				ComputeJoystickAnchor( joyAnchor);
			}
			
			VirtualScreen.SetGuiScaleMatrix();
			
			
			
			// area zone
			if ((showZone && areaTexture!=null && !dynamicJoystick) || (showZone && dynamicJoystick && virtualJoystick && areaTexture!=null) 
				|| (dynamicJoystick && Application.isEditor && !Application.isPlaying)){
				if (isActivated){
					GUI.color = areaColor;
					
					if (Application.isPlaying && !dynamicJoystick){
						EasyTouch.RemoveReservedArea( areaRect );
						EasyTouch.AddReservedArea( areaRect );
					}
				}
				else{
					GUI.color = new Color(areaColor.r,areaColor.g,areaColor.b,0.2f);	
					if (Application.isPlaying && !dynamicJoystick){
						EasyTouch.RemoveReservedArea( areaRect );	
					}
				}		
				
				if (showDebugRadius && Application.isEditor){
					GUI.Box( areaRect,"");				
				}
				
				GUI.DrawTexture( areaRect, areaTexture,ScaleMode.StretchToFill,true);
			}
			
			
			// area touch
			if ((showTouch && touchTexture!=null && !dynamicJoystick)|| (showTouch && dynamicJoystick && virtualJoystick && touchTexture!=null) 
				|| (dynamicJoystick && Application.isEditor && !Application.isPlaying)){
				if (isActivated){
					GUI.color = touchColor;
				}
				else{
					GUI.color = new Color(touchColor.r,touchColor.g,touchColor.b,0.2f);	
				}			
				GUI.DrawTexture( new Rect(anchorPosition.x +  joystickCenter.x+(joystickTouch.x -touchSize) ,anchorPosition.y + joystickCenter.y-(joystickTouch.y+touchSize),touchSize*2,touchSize*2), touchTexture,ScaleMode.ScaleToFit,true);
			}	
	
			// dead zone
			if ((showDeadZone && deadTexture!=null && !dynamicJoystick)|| (showDeadZone && dynamicJoystick && virtualJoystick && deadTexture!=null) 
				|| (dynamicJoystick && Application.isEditor && !Application.isPlaying)){			
				GUI.DrawTexture( deadRect, deadTexture,ScaleMode.ScaleToFit,true);
			}	
			
			GUI.color = Color.white;
		}
		else{
			EasyTouch.RemoveReservedArea( areaRect );	
		}
	}