Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

354
Visualizações
Cursor not appearing in Unity with Screen.lockCursor = false;

Unity version: 2017.2.0b11

In my game when the Inventory Panel is visible on the screen, the cursor should appear so that i can click and interact. I always have to press esc key to make the cursor visible and even from that the cursor disappears after clicking.

Below is my javascript script

var OurInventory : GameObject;
var InvStatus : int;

function Update(){
    if (Input.GetButtonDown("Inventory")){
        if (InvStatus == 0){
            Screen.lockCursor = false;
            InvStatus = 1;
            OurInventory.SetActive(true);
        }
        else {
            Screen.lockCursor = true;
            OurInventory.SetActive(false);
            InvStatus = 0;
        }
    }
}

Below is my C# script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Shop01Access : MonoBehaviour {

    public GameObject ShopInventory;
    public GameObject Item01Text;
    public GameObject Item02Text;
    public GameObject Item03Text;
    public GameObject Item04Text;
    public GameObject ItemCompletion;
    public GameObject CompleteText;
    
    void OnTriggerEnter(){
        ShopInventory.SetActive(true);
        Screen.lockCursor = false;
        GlobalShop.ShopNumber = 1;
        Item01Text.GetComponent<Text>().text = "" + GlobalShop.Item01;
        Item02Text.GetComponent<Text>().text = "" + GlobalShop.Item02;
        Item03Text.GetComponent<Text>().text = "" + GlobalShop.Item03;
        Item04Text.GetComponent<Text>().text = "" + GlobalShop.Item04;
    }
    
    public void Item01() {
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy " + GlobalShop.Item01 + "?";
    }
    
    public void Item02() {
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy " + GlobalShop.Item02 + "?";
    }
    
    public void Item03() {
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy " + GlobalShop.Item03 + "?";
    }
    
    public void Item04() {
        ItemCompletion.SetActive(true);
        CompleteText.GetComponent<Text>().text = "Are you sure you want to buy " + GlobalShop.Item04 + "?";
    }
    
    public void CancelTransaction(){
        ItemCompletion.SetActive(false);
    }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda