Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

GUI Button Conflict

Discussion in 'Immediate Mode GUI (IMGUI)' started by Predster, Mar 3, 2008.

  1. Predster

    Predster

    Joined:
    Sep 11, 2007
    Posts:
    145
    I'm having some GUI problems. I have some script below for changing my camera view, and the button "changer" is mapped to left ctrl in the input window. BUT, whenever I make a GUI button and click it, it runs this code, changing the camera view! How do I stop it from doing this?


    Code (csharp):
    1. function Update () {
    2.    
    3.     if (Input.GetButtonDown("Changer")) {
    4.         switcher = !switcher;
    5.         if (switcher == true) {
    6.              modelUse.renderer.sharedMaterial = orientationMaterial;
    7.              fpsCam.active = false;
    8.              orientationCam.active = true;
    9.              orientationLight.active = true;
    10.              orientationLight1.active = true;
    11.            
    12.         }
    13.         else {
    14.             modelUse.renderer.sharedMaterial = fpsMaterial;
    15.             fpsCam.active = true;
    16.             orientationCam.active = false;
    17.             orientationLight.active = false;
    18.             orientationLight1.active = false;
    19.         }
    20.     }
    21. }
    22.  
     
  2. Predster

    Predster

    Joined:
    Sep 11, 2007
    Posts:
    145
    Even though my GUI buttons all do other things, they keep switching the camera as well!

    I'm really desperate for help here--does anyone know why "Input.GetButtonDown("Changer")" keeps activating my GUI buttons?
     
  3. CoherentInk

    CoherentInk

    Joined:
    Jul 16, 2006
    Posts:
    216
    Can you post some of your OnGUI() code? It may be that the GUI Button is returning true for some other reason.
     
  4. Predster

    Predster

    Joined:
    Sep 11, 2007
    Posts:
    145