void Update() { // If we are visible and the screenHeight has changed, reset linespacing if (visible == true && screenHeight != Screen.height) { InitGuis(); } if (draggable == true) { if (Input.GetMouseButtonDown(0)) { if (connectedToMouse == false && guiText.HitTest(Input.mousePosition) == true) { connectedToMouse = true; } else if (connectedToMouse == true) { connectedToMouse = false; } } if (connectedToMouse == true) { float posX = DebugGui.transform.position.x; float posY = DebugGui.transform.position.y; posX = Input.mousePosition.x / Screen.width; posY = Input.mousePosition.y / Screen.height; DebugGui.transform.position = new Vector3(posX, posY, 0F); } } }
//Check if mouse was clicked on this public bool CheckHit(Vector3 Coords) { if (pText.HitTest(Coords) == true) { return(true); } else { return(false); } }
/// <summary> /// Checks to see if a GUIText object was touched /// </summary> /// <returns> /// True if the GUIText object was touched. /// </returns> /// <param name='id'> /// Touch id. /// </param> /// <param name='guiText'> /// GUIText object to check. /// </param> /// <param name='pos'> /// Set with the screen position of the touch /// </param> public static bool TouchedGUIText(int id, GUIText guiText, out Vector2 pos) { bool touchedGUIText = false; if (TouchManager.GetTouchPos(id, out pos)) { touchedGUIText = guiText.HitTest(pos); } return(touchedGUIText); }
void Update() { // if (Input.GetMouseButtonDown(0)) { if (m_guiText.HitTest(Input.mousePosition)) { SceneManager.LoadScene("DigScene", LoadSceneMode.Single); } } else { if (m_guiText.HitTest(Input.mousePosition)) { m_guiText.color = Color.blue; } else { m_guiText.color = Color.white; } } }
void Update() { // if (Input.GetMouseButtonDown(0)) { if (m_guiText.HitTest(Input.mousePosition)) { m_gameMode = (m_gameMode + 1) % m_modeNames.Length; m_guiText.text = m_modeNames[m_gameMode]; PlayerPrefs.SetInt("GameState gameMode", m_gameMode); } } else { if (m_guiText.HitTest(Input.mousePosition)) { m_guiText.color = Color.blue; } else { m_guiText.color = Color.white; } } }
void Update() { if (Input.GetMouseButtonDown(0)) { if (set1.HitTest(Input.mousePosition, Camera.main)) { Debug.Log("Set 1!"); PlayerPrefs.SetInt("Set1", 1); } if (set2.HitTest(Input.mousePosition, Camera.main)) { Debug.Log("Set 2!"); PlayerPrefs.SetInt("Set2", 1); } if (set3.HitTest(Input.mousePosition, Camera.main)) { Debug.Log("Set 3!"); PlayerPrefs.SetInt("Set3", 1); } if (set4.HitTest(Input.mousePosition, Camera.main)) { Debug.Log("Set 4!"); PlayerPrefs.SetInt("Set4", 1); } if (deleter.HitTest(Input.mousePosition, Camera.main)) { Debug.Log("Delete!"); PlayerPrefs.DeleteAll(); get.a1 = 0; get.a2 = 0; get.a3 = 0; get.a4 = 0; } if (Quit.HitTest(Input.mousePosition, Camera.main)) { Application.Quit(); Debug.Log("Quitszzz"); } } }
void Update() { if (Input.GetMouseButtonUp(0)) { if (m_PlayGame.HitTest(Input.mousePosition)) { // TODO:: player needs to be able to load a saved level (in a certain world) Application.LoadLevel("LevelSelect"); } else if (m_ExitGame.HitTest(Input.mousePosition)) { Application.Quit(); } else if (m_Practice.HitTest(Input.mousePosition)) { m_Game.StartPractice(); } } }
void Update() { if (Input.GetKeyUp(KeyCode.Escape)) { // PlayerPrefs.SetInt("isLoaded", 0); SaveGameData(); return; } if (!isGameOver) { if (Input.GetKeyUp(KeyCode.M) || Input.GetKeyUp(KeyCode.P) || Input.mousePresent && Input.GetMouseButton(1)) { Pause(); return; } foreach (Touch touch in Input.touches) { if (!isPause) { if (menuText.HitTest(touch.position)) { Pause(); } } } } if (isRestart) { if (Input.GetKeyDown(KeyCode.R) || Input.mousePresent && Input.GetMouseButton(0) || Input.touchCount > 0) { // PlayerPrefs.SetInt("isLoaded", 1); Application.LoadLevel(Application.loadedLevel); } } }
// Update is called once per frame void Update() { if (Input.touchCount > 0) { Touch t = Input.GetTouch(0); /* * if (t.phase == TouchPhase.Began) { * if (bt.HitTest (t.position, Camera.main)) { * * } * } */ } if (Input.GetMouseButtonDown(0)) { //1st Column if (Love.HitTest(Input.mousePosition, Camera.main)) { Change = Love.GetComponent <GUITexture>(); positionIndicator(); audio.PlayOneShot(clip[2]); } if (Family.HitTest(Input.mousePosition, Camera.main)) { Change = Family.GetComponent <GUITexture>(); positionIndicator(); if (position != 0) { family = true; audio.PlayOneShot(clip[2]); } } if (Dreams.HitTest(Input.mousePosition, Camera.main)) { Change = Dreams.GetComponent <GUITexture>(); positionIndicator(); audio.PlayOneShot(clip[2]); } if (Philippines.HitTest(Input.mousePosition, Camera.main)) { Change = Philippines.GetComponent <GUITexture>(); positionIndicator(); if (position != 0) { philippines = true; audio.PlayOneShot(clip[2]); } } if (Sadness.HitTest(Input.mousePosition, Camera.main)) { Change = Sadness.GetComponent <GUITexture>(); positionIndicator(); audio.PlayOneShot(clip[2]); } //2nd Column if (Life.HitTest(Input.mousePosition, Camera.main)) { Change = Life.GetComponent <GUITexture>(); positionIndicator(); audio.PlayOneShot(clip[2]); } if (God.HitTest(Input.mousePosition, Camera.main)) { Change = God.GetComponent <GUITexture>(); positionIndicator(); audio.PlayOneShot(clip[2]); } if (Farewell.HitTest(Input.mousePosition, Camera.main)) { Change = Farewell.GetComponent <GUITexture>(); positionIndicator(); if (position != 0) { farewell = true; audio.PlayOneShot(clip[2]); } } if (Patriot.HitTest(Input.mousePosition, Camera.main)) { Change = Patriot.GetComponent <GUITexture>(); positionIndicator(); if (position != 0) { patriot = true; audio.PlayOneShot(clip[2]); } } if (Hope.HitTest(Input.mousePosition, Camera.main)) { Change = Hope.GetComponent <GUITexture>(); positionIndicator(); if (position != 0) { hope = true; audio.PlayOneShot(clip[2]); } } if (disableThis) { if (Reset.HitTest(Input.mousePosition, Camera.main)) { resetAll(); audio.PlayOneShot(clip[0]); } } if (disableThis) { if (OK.HitTest(Input.mousePosition, Camera.main)) { checkAnswers(); audio.PlayOneShot(clip[0]); } } if (disableFinish) { if (Finish.HitTest(Input.mousePosition, Camera.main)) { //Debug.Log("Change Scene"); storage.newer = 1; Application.LoadLevel("New Act4 Part3 Scene1"); audio.PlayOneShot(clip[1]); } } } }
/// <summary> /// Checks to see if a GUIText object was touched /// </summary> /// <returns> /// True if the GUIText object was touched. /// </returns> /// <param name='id'> /// Touch id. /// </param> /// <param name='guiText'> /// GUIText object to check. /// </param> /// <param name='pos'> /// Set with the screen position of the touch /// </param> public static bool TouchedGUIText(int id, GUIText guiText, out Vector2 pos) { bool touchedGUIText = false; if (TouchManager.GetTouchPos(id, out pos)) { touchedGUIText = guiText.HitTest(pos); } return touchedGUIText; }
protected void Update() { float currentTime = Time.realtimeSinceStartup; customDeltaTime = currentTime - timeToLatestFrame; timeToLatestFrame = currentTime; if (ButtonEnabled) { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && (guiTexture.HitTest(Input.GetTouch(0).position) || (label != null && label.HitTest(Input.GetTouch(0).position)))) { buttonTouched = true; buttonTouch = Input.GetTouch(0); OnButtonDown(); PlayButtonDownAnim(); if (buttonDownClip != null) { audio.volume = buttonDownSoundVolume; audio.PlayOneShot(buttonDownClip); } } if (buttonTouched && buttonTouch.phase == TouchPhase.Ended) { if (InputInButtonArea()) { OnButtonUp(); } PlayButtonUpAnim(); buttonTouched = false; if (buttonUpClip != null) { audio.volume = buttonUpSoundVolume; audio.PlayOneShot(buttonUpClip); } } if (label != null) { if (Input.GetMouseButtonDown(0) && label.HitTest(Input.mousePosition)) { OnButtonDown(); PlayButtonDownAnim(); labelClicked = true; if (buttonDownClip != null) { audio.volume = buttonDownSoundVolume; audio.PlayOneShot(buttonDownClip); } } else if (labelClicked && Input.GetMouseButtonUp(0)) { if (InputInButtonArea()) { OnButtonUp(); } PlayButtonUpAnim(); labelClicked = false; if (buttonUpClip != null) { audio.volume = buttonUpSoundVolume; audio.PlayOneShot(buttonUpClip); } } } } }
// Update is called once per frame void Update() { /* * If the mouse hovers over any of the menu options, I set the color of the text to the color stored in the * highlightedText variable. I also increase the font size slightly. I increase the size but limit it to * the size stored in the maxFontSize variable. This gives a really nice effect when a menu option is selected * and the player can clearly see which option is being hovered over with the cursor. */ if (thisText.HitTest(Input.mousePosition)) { thisText.color = highlightedColor; thisText.fontSize += 1; if (thisText.fontSize > maxFontSize) { thisText.fontSize = maxFontSize; } if (Input.GetMouseButtonDown(0)) //The level that is loaded depends on which option is clicked { //levelToLoad = thisText.text; levelToLoad = thisText.name; } } else //When the mouse is moved off a menu option, it returns to its normal colorand size { thisText.color = originalColor; thisText.fontSize = 20; } /* * This just loads a level depending on what is stored in the "levelToLoad" variable. */ if (levelToLoad == "Start Game") { Application.LoadLevel("Level1"); } if (levelToLoad == "Level 1") { Application.LoadLevel("football"); } else if (levelToLoad == "Level 2") { Application.LoadLevel("Level2"); } else if (levelToLoad == "Level 3") { Application.LoadLevel("Level3"); } else if (levelToLoad == "Level 4") { Application.LoadLevel("Level4"); } else if (levelToLoad == "Level 5") { Application.LoadLevel("Level5"); } else if (levelToLoad == "Level 6") { Application.LoadLevel("Level6"); } else if (levelToLoad == "Level 7") { Application.LoadLevel("Level7"); } else if (levelToLoad == "Level 8") { Application.LoadLevel("Level8"); } else if (levelToLoad == "Level 9") { Application.LoadLevel("Level9"); } else if (levelToLoad == "Quit") { Application.Quit(); } else if (levelToLoad == "Target Practice") { Application.LoadLevel("TargetPractice"); } else if (levelToLoad == "Main Menu") { Application.LoadLevel("MainMenu"); } else if (levelToLoad == "Random Level") { Application.LoadLevel(Random.Range(1, 10)); } else if (levelToLoad == "Goalkeeper Mode") { Application.LoadLevel("Goalkeeper Mode"); } /* * If the Instructions menu option is clicked, the Instructions are displayed. */ else if (levelToLoad == "Instructions") { GameObject.Find("InstructionsList").GetComponent <GUIText>().enabled = true; } }