Hello,
I’m new to unity and scripting in general.
In a script attached to a sprite, i try to detect my mouse left button click with this :
but it doesn’t detect it at all. Any explanation why?
I’m using Unity 2017.1 and monodevelop
EDIT : forgot to paste one of the curly braces
If the above is your entire script minus the using statements, then it is certainly not compiling, and hence it is not running.
Look at the console window for error details. You have two open braces and one close brace.
The entire script looks like this :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0)) {
Debug.Log(“Left mouse button clicked!”);
}
}
}
https://imagebin.ca/v/3XWtdUxYyBx2
Obviously it is because the component is greyed out but I don’t understand why is it so
help plz
In the upper right corner of the console window of the above screenshot you have unchecked the normal log messages, causing them to be hidden.
In the above shot there are 153 log messages, probably some of them saying “Left mouse button clicked!” that are being hidden from you.
Click on that 153 button (in the screenshot above) and see your messages coming out.
1 Like
Oh yes, you are right xD thank you 