- Home /
Trying to set up some GUI using planes and textures. Need help with dynamic changes.
Currently I am using the OnMouseOver() function to check if the mouse is over the object. But I have three colliders that the mouse can be over. I need to find a way that I can edit one collider at a time depending on if the mouse if over it. Basically in the code below where I am changing the position of the gameobject "play" it changes the position if I am over the gameobject "options" I need it to only change "play" when over "play" and "options" when over "options".
 using UnityEngine;
 using System.Collections;
 
 public class MainMenu : MonoBehaviour {
     
     public GameObject menu;
     GameObject play;
     GameObject options;
     public Texture menu_new;
     public Texture menu_original;
     
     void Start () {
         
     }
     
     //Called when mouse is over the collider
     void OnMouseOver () {
         
         //Finds the GameObjects with the text
         play = GameObject.Find("Play");
         options = GameObject.Find("Options");
         
         //Collects the transform position of each variable
         Vector3 play_pos = play.transform.position;
         Vector3 options_pos = options.transform.position;
         
         //play.transform.Translate (0, Time.deltaTime, 0);
         //options.transform.Translate (0, Time.deltaTime, 0);
         
         if(play_pos.z == 2.4F)
         {
             play.transform.position = new Vector3 (0, 4.4F, 2.1F);
         }
         
         menu.renderer.material.SetTexture("_MainTex", menu_new);    
     }
     
     void OnMouseExit () {
         
         //Find the GameObject with the text
         play = GameObject.Find("Play");
         options = GameObject.Find("Options");
         
         //Collects the transform position of each variable
         Vector3 play_pos = play.transform.position;
         Vector3 options_pos = options.transform.position;
         
         if(play_pos.z == 2.1F)
         {
             play.transform.position = new Vector3 (0, 4.4F, 2.4F);    
         }
         
         menu.renderer.material.SetTexture("_MainTex", menu_original);
     }
 
 }
Also some of those lines might not be doing anything haven't cleaned it up yet. But everything is working fine other than the problem I can't figure out.
Your answer
 
 
             Follow this Question
Related Questions
HealthBar for 5 Objects 3 Answers
How to set the position of a guitext using transform? 1 Answer
positioning gui! 2 Answers
lock GUITexture on the screen at specific co - ordinates 3 Answers
GUI item with object position+dimensions 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                