Hi there!I have a problem that the GUI Buttons dont work or react if i click on them. The Canvas is in World Space, because i want to drop the GUI on a keypad model. I have tried several things now, but the buttons dont react. i give you the screens of my settings and my testcode. any ideas? Thank you!
Maybe something is hiding the raycast?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.UI;
namespace FPSHorror
{
public class Keypad : MonoBehaviour
{
public string correctPassword;
private string passwordInput;
//Buttons and Numbers for Keypad
public Button ButtonOneUp;
public Button ButtonTwoUp;
public Button ButtonThreeUp;
public Button ButtonFourUp;
public Button ButtonOneDown;
public Button ButtonTwoDown;
public Button ButtonThreeDown;
public Button ButtonFourDown;
private int numberOne;
private int numberTwo;
private int numberThree;
private int numberFour;
public Text numberOneText;
private bool keypadActive = false;
public Camera mainCam;
public Camera keypadCam;
//Initalizing Variables
private FirstPersonController playerController;
private GameManager_ToggleCursor toggleCursor;
// Use this for initialization
void Start ()
{
SetInitialReferences ();
}
void SetInitialReferences ()
{
playerController = GameObject.FindObjectOfType<FirstPersonController> ();
toggleCursor = GameObject.FindObjectOfType<GameManager_ToggleCursor> ();
}
// Update is called once per frame
void Update ()
{
}
public void MoveCameraToKeypad()
{
mainCam.enabled = false;
playerController.enabled = false;
gameObject.layer = LayerMask.NameToLayer ("Default");
toggleCursor.isCursorlocked = false;
keypadActive = true;
keypadCam.enabled = true;
}
public void CountNumberOneUp ()
{
numberOneText.text = numberOne.ToString ();
numberOne = numberOne += 1;
Debug.Log (numberOne);
print ("Clicked");
}
}
}