D
D
djEban2019-06-06 16:43:47
Unity
djEban, 2019-06-06 16:43:47

unity. Interaction with objects?

In general, when I click on the computer, another scene opens for me - the desktop scene. But when you open it, there is no cursor. Why is that?
Here is the code for checking that the camera is looking at the computer, where when you click on E, scene number 2 opens.

using UnityEngine;
using UnityEngine.SceneManagement;

public class MonitorOnUse : MonoBehaviour
{
    private bool isUsed;

    void Start()
    {
       
    }

    void Update()
    {
        if (!isUsed)
        {
            if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out RaycastHit obj, 6f))
                if (obj.collider.tag == "Monitor")
                    if (Input.GetKey(KeyCode.E))
                    {
                        SceneManager.LoadScene(2);                   
                    }
        }
    }
}

Here is the desktop scene itself (scene number 2) where I will need to click on "Photoshop" when opening it. But when opening, there is no cursor at all and I can't do anything but close.
5cf918253e131400908948.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2019-06-06
@GavriKos

You need to watch the scripts that are on the second stage. Some of them (maybe even the standard unit one) hides the cursor.
Well, make sure you don't have something like Screen.showCursor or Cursor.visible anywhere

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question