- Home /
onmousedown issues
for some reason on the object print will run on the 0 click but never on the 1 or 2, why also the code never runs for anything other then 0??????
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class PlanetName : MonoBehaviour {
public Text PlanetInfo;
public bool TextShowing;
public string planetName;
// Update is called once per frame
void Update () {
}
void OnMouseDown(){
if (Input.GetMouseButtonDown (0)) {
print("hit");
// Debug.Log ("true");
PlanetInfo.gameObject.SetActive (true);
PlanetInfo.text = planetName;
}
if (Input.GetMouseButtonDown (1)) {
print("hit");
// Debug.Log ("true");
PlanetInfo.gameObject.SetActive (false);
PlanetInfo.text = planetName;
}
}
}
Comment
Answer by Bren0831 · Mar 21, 2017 at 06:00 AM
Is your collapsed setting on inside of your console tab in the editor? that would make it look like only one message instead of the multiple.
Your answer
![](https://koobas.hobune.stream/wayback/20220612113618im_/https://answers.unity.com/themes/thub/images/avi.jpg)