Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

344
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!