Quantcast
Channel: Questions in topic: "build"
Viewing all articles
Browse latest Browse all 4084

Input.GetMouseButtonDown not working in Play mode

$
0
0
Hi! I don't know why Input.GetMouseButtonDown(0) not working in Play mode, but if i build&run - it's works good. Why? This is my code: using UnityEngine; using System.Collections; public class Spawner : MonoBehaviour { public static Spawner Instance { get; private set; } public GameObject area; public GameObject enemy; public GameObject player; public float scaleX, scaleY, startPoint, minY, maxY; public bool gameRunning; public float enemyDefaultSize = 0.2F; void Awake() { gameRunning = true; Instance = this; } void Start () { scaleX = area.transform.localScale.x; scaleY = area.transform.localScale.y; startPoint = scaleX / 2; minY = (-area.transform.localScale.y / 2)+0.2F; maxY = (area.transform.localScale.y / 2)-0.2F; CallEnemy (); spawnPlayer (); } void spawnPlayer(Vector3 pos = default(Vector3)) { float spawnPlayerPoint = (scaleX / 2)/2; float startY = Random.Range (minY, maxY); player.GetComponent ().damage = 20; player.GetComponent ().fireDelaySet = 1.0F; if(pos == Vector3.zero) Instantiate (player, new Vector3(-spawnPlayerPoint, startY, -1), Quaternion.identity); else Instantiate (player, new Vector3(pos.x, pos.y, -1), Quaternion.identity); } public void CallEnemy() { float startY = Random.Range (minY, maxY); Instantiate (enemy, new Vector3(startPoint, startY, -1), Quaternion.identity); enemy.name = "Bot"; } void Update () { if (gameRunning) { Debug.Log ("Test message"); if (Input.GetMouseButtonDown (0)) { Debug.Log ("Clicked!"); spawnPlayer (); //Work in Build&Play, but not in Editor(Play mode) } } } }

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>