- Home /
Question by
TheGabeMeister · Jan 14, 2013 at 07:32 PM ·
delayonmouseenter
Delay Problem, coule be 'OnMouseEnter'?
I am having a problem where it only spawns a cube when i drag the mouse. When I single-click it doesnt even Spawn one cube! Ive placed Debugs to verify if the mouse is being picked up and it isnt on a single click :( Heres the code:
using UnityEngine; using System.Collections;
public class GridHighlight : MonoBehaviour {
public GameObject _NONRIGIDCube;
void Update(){
}
void start () {
}
// color change to red
void OnMouseEnter() {
Vector3 objectPos = transform.position;
if(Input.GetKey (KeyCode.Mouse0)){
Debug.Log("MouseClick");
Vector3 newPosition = new Vector3(objectPos.x, objectPos.y +1, objectPos.z);
Debug.Log("Instantiate");
Instantiate (_NONRIGIDCube,newPosition,Quaternion.identity);
}
renderer.material.color = Color.red;
}
// change back to white
void OnMouseExit() {
renderer.material.color = Color.white;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613090935im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Play sound on mouse enter 1 Answer
Very simple inventory script... 0 Answers
Audio help. 1 Answer
My health decreases to fast. 1 Answer