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


C# GUITexture.HitTest方法代码示例

本文整理汇总了C#中GUITexture.HitTest方法的典型用法代码示例。如果您正苦于以下问题:C# GUITexture.HitTest方法的具体用法?C# GUITexture.HitTest怎么用?C# GUITexture.HitTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GUITexture的用法示例。


在下文中一共展示了GUITexture.HitTest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: touchInput

 public void touchInput(GUITexture texture)
 { 
     if (Input.touchCount > 0)
 { 
         if (texture.HitTest(Input.GetTouch(0).position))
 { 
             switch (Input.GetTouch(0).phase)
 { 
                 case TouchPhase.Began:
     //do stuff 
     SendMessage("OnFirstTouchBegan",SendMessageOptions.DontRequireReceiver);
     SendMessage("OnFirstTouch",SendMessageOptions.DontRequireReceiver);
     guiTouch = true; 
     break; 
     case TouchPhase.Stationary: 
     //do stuff
     SendMessage("OnFirstTouchStayed",SendMessageOptions.DontRequireReceiver);
     SendMessage("OnFirstTouch",SendMessageOptions.DontRequireReceiver);
     guiTouch = true; 
     break;
     case TouchPhase.Moved:
     //do stuff 
     SendMessage("OnFirstTouchMoved",SendMessageOptions.DontRequireReceiver);
     SendMessage("OnFirstTouch",SendMessageOptions.DontRequireReceiver);
     guiTouch = true;
     break;
     case TouchPhase.Ended:
     //do stuff 
     SendMessage("OnFirstTouchEnded",SendMessageOptions.DontRequireReceiver);
     guiTouch = false;
     break; } } } 
     if (Input.touchCount > 1)
     { 
         if (texture.HitTest(Input.GetTouch(1).position))
     { 
             switch (Input.GetTouch(1).phase)
     { 
                 case TouchPhase.Began:
         //do stuff 
         SendMessage("OnSecondTouchBegan",SendMessageOptions.DontRequireReceiver); 
         SendMessage("OnSecondTouch",SendMessageOptions.DontRequireReceiver); 
         break; 
         case TouchPhase.Stationary:
         //do stuff 
         SendMessage("OnSecondTouchStayed",SendMessageOptions.DontRequireReceiver);
         SendMessage("OnSecondTouch",SendMessageOptions.DontRequireReceiver);
         break; 
         case TouchPhase.Moved: 
         //do stuff 
         SendMessage("OnSecondTouchMoved",SendMessageOptions.DontRequireReceiver);
         SendMessage("OnSecondTouch",SendMessageOptions.DontRequireReceiver); 
         break; 
         case TouchPhase.Ended: 
         //do stuff 
         SendMessage("OnSecondTouchEnded",SendMessageOptions.DontRequireReceiver); break; 
     }
     }
     }
 }
开发者ID:JanuszSobczak,项目名称:Ninja2D,代码行数:59,代码来源:TouchMenager.cs

示例2: TouchInput

    public void TouchInput(GUITexture texture)
    {
        if (texture.HitTest(Input.GetTouch(0).position))
        {
            switch (Input.GetTouch(0).phase)
            {
                case TouchPhase.Began:
                    SendMessage("OnFirstTouchBegan");
                    SendMessage("OnFirstTouch");
                    guiTouch = true;
                    break;
                case TouchPhase.Moved:
                    SendMessage("OnFirstTouchMoved");
                    SendMessage("OnFirstTouch");
                    guiTouch = true;
                    break;
                case TouchPhase.Stationary:
                    SendMessage("OnFirstTouchStayed");
                    SendMessage("OnFirstTouch");
                    guiTouch = true;
                    break;
                case TouchPhase.Ended:
                    SendMessage("OnFirstTouchEnded");
                    guiTouch = true;
                    break;
            }

        }
        if (texture.HitTest(Input.GetTouch(0).position))
        {
            switch (Input.GetTouch(1).phase)
            {
                case TouchPhase.Began:
                    SendMessage("OnSecondTouchBegan");
                    SendMessage("OnSecondTouch");
                    break;
                case TouchPhase.Moved:
                    SendMessage("OnSecondTouchMoved");
                    SendMessage("OnSecondTouch");
                    break;
                case TouchPhase.Stationary:
                    SendMessage("OnSecondTouchStayed");
                    SendMessage("OnSecondTouch");
                    break;
                case TouchPhase.Ended:
                    SendMessage("OnSecondTouchEnded");
                    break;
            }

        }
    }
开发者ID:MustacescuPaul,项目名称:Platformer,代码行数:51,代码来源:Touch+Manager.cs

示例3: Button

    public void Button(GUITexture button, int callButton)
    {
        if (button != null)
        {
            if (button.HitTest(Input.mousePosition))
            {
                if (button.color.a <= 0.2f)
                    fadeButton = true;
                if (button.color.a >= 0.4f)
                    fadeButton = false;

                if (!fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a - 0.55f * Time.deltaTime);
                }

                if (fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.55f * Time.deltaTime);
                }

                if (Input.GetMouseButtonDown(0))
                {
                    switch (callButton)
                    {
                        case 0:
                            DestroyInterface();
                            SceneManager.Instance.scene.CloseScene();
                            SceneManager.Instance.ChangeLevelCampaignMode(1);
                            break;

                        case 1:
                            DestroyInterface();
                            break;

                        case 2:
                            DestroyInterface();
                            SceneManager.Instance.scene.CloseScene();
                            SceneManager.Instance.ChangeMenu(0);
                            break;
                    }
                    SceneManager.Instance.paused = !SceneManager.Instance.paused;
                }

            }
            else if (button.color.a < 0.5f)
            {
                button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.45f * Time.deltaTime);
            }
        }
    }
开发者ID:vitormartins1,项目名称:vermillion-war,代码行数:57,代码来源:Introduction.cs

示例4: ButtonBackToMainMenu

    public void ButtonBackToMainMenu(GUITexture button)
    {
        if (button != null)
        {
            if (button.HitTest(Input.mousePosition))
            {
                if (button.color.a <= 0.2f)
                    fadeButton = true;
                if (button.color.a >= 0.4f)
                    fadeButton = false;

                if (!fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a - 0.55f * Time.deltaTime);
                }

                if (fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.55f * Time.deltaTime);
                }

                if (Input.GetMouseButtonDown(0))
                {
                    SceneManager.Instance.ChangeMenu(0);
                    CloseScene();
                }

            }
            else if (button.color.a < 0.5f)
            {
                button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.45f * Time.deltaTime);
            }
        }
    }
开发者ID:vitormartins1,项目名称:vermillion-war,代码行数:40,代码来源:RankingMenu.cs

示例5: Button

    /// <summary>
    /// 0 for Campaign Mode
    /// 1 for Survive Mode
    /// 2 for Instructions
    /// 3 for Ranking
    /// 4 for Credits
    /// 5 for Quit the game
    /// </summary>
    /// <param name="button">Button to get the effect and call a scene</param>
    /// <param name="callButton">int number for choose the scene to be changed</param>
    public void Button(GUITexture button, int callButton)
    {
        if (button != null)
        {
            if (button.HitTest(Input.mousePosition))
            {
                if (button.color.a <= 0.2f)
                    fadeButton = true;
                if (button.color.a >= 0.4f)
                    fadeButton = false;

                if (!fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a - 0.55f * Time.deltaTime);
                }

                if (fadeButton)
                {
                    button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.55f * Time.deltaTime);
                }

                if (Input.GetMouseButtonDown(0))
                {
                    switch (callButton)
                    {
                        case 0:
                            //Verify the last level played to call the next level
                            SceneManager.Instance.ChangeLevelCampaignMode(1);
                            break;

                        case 1:
                            SceneManager.Instance.ChangeScene(2);
                            break;

                        case 2:
                            SceneManager.Instance.ChangeMenu(1);
                            break;

                        case 3:
                            SceneManager.Instance.ChangeMenu(3);
                            break;

                        case 4:
                            SceneManager.Instance.ChangeMenu(2);
                            break;

                        case 5:
                            Application.Quit();
                            break;
                    }
                    CloseScene();
                }

            }
            else if (button.color.a < 0.5f)
            {
                button.color = new Color(
                                    button.color.r, button.color.g,
                                    button.color.b, button.color.a + 0.45f * Time.deltaTime);
            }
        }
    }
开发者ID:vitormartins1,项目名称:vermillion-war,代码行数:76,代码来源:MainMenu.cs

示例6: Update


//.........这里部分代码省略.........
					brake = false;
					left = false;
					right = false;
					pause = false;
					restart = false;
					leftORright = false;							
				
				
					float angle = 360.0f; // Degree per time unit
					float time = 1.0f; // Time unit in sec
					Vector3 axis = Vector3.left; // Rotation axis, here it the yaw axis
				
					leftTexture = mobileButtons.FindChild ("left").GetComponent<GUITexture> ();
					rightTexture = mobileButtons.FindChild ("right").GetComponent<GUITexture> ();
				
					throttleTexture = mobileButtons.FindChild ("throttle").GetComponent<GUITexture> ();
					brakeTexture = mobileButtons.FindChild ("brake").GetComponent<GUITexture> ();
				
				
					leftTexture.enabled = false;
					rightTexture.enabled = false;
				
					leftTexture.enabled = true;
					rightTexture.enabled = true;
				
					throttleTexture.enabled = true;
					brakeTexture.enabled = true;
				
				
				
					foreach (var touch in touches) {	
					
						//if (touch.phase != TouchPhase.Canceled && touch.phase != TouchPhase.Ended) {																							
						if (throttleTexture.HitTest (touch.position)) //if touch position is inside throttle texture
						
							accelerate = true;
					
						if (brakeTexture.HitTest (touch.position)) //if touch position is inside brake texture
						
							brake = true;
					
					
					
						if (leftTexture.HitTest (touch.position)) //left button is touched
						
							left = true;
					
					
						if (rightTexture.HitTest (touch.position)) //right button is touched
						
							right = true;


						/*if (nitroTexture.HitTest (touch.position)) //if touch position is inside throttle texture
						
						ifnitro = true;
					*/
					
						//if (left || right) //left or right button is touched
						//	leftORright = true;						
						//}
					
					}
				
					if (Input.touchCount == 0) {
					
开发者ID:Avatarchik,项目名称:UnityZombieCross,代码行数:66,代码来源:Motorcycle_Controller2D.cs


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