Question by
comolokko11 · Jun 01, 2020 at 12:11 AM ·
getkeygetkeyup
assign another key
here, pressing Mouse1 opens the panel. pressing again closes the panel. but I want it to turn off when the Mouse0 key is pressed.
To open: only Mouse1 To Close: Mouse1 + Mouse0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RightClick : MonoBehaviour
{
public GameObject Panel;
private bool ShowPanel;
void Start(){
Panel.SetActive (false);
}
void Update(){
if (Input.GetKeyUp (KeyCode.Mouse1)){
ShowPanel =!ShowPanel;
Panel.SetActive(ShowPanel);
if (Panel && Panel) {
Panel.transform.position = Input.mousePosition;
}
}
}
}
Comment