I’ve already checked many threads on this issue and tries everything suggested there. It just doesn’t work.
The idea: I have a group of 8 spheres attached to one cube positioned between them and 8 point lights attached to these spheres. During the game when player holds any button (let’s say, LeftShift), this group appears at the current position of mouse and after that moves with the camera so that the cursor can move separately from the group. When the player releases LeftShift, the group disappears.
Here’s the code for this script and it works perfectly:
public class GroupMove : MonoBehaviour {
private Vector3 pos;
private Vector3 oldpos;
private bool appeared;
public Camera cam;
public GameObject Player;
// Use this for initialization
void Start () {
oldpos=transform.position;
appeared=false;
}
// Update is called once per frame
void LateUpdate () {
pos=new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
if(Input.GetKeyDown(KeyCode.LeftShift) & appeared == false){
transform.position=cam.ScreenToWorldPoint(pos);
appeared=true;
}
else if(Input.GetKeyUp(KeyCode.LeftShift)){
transform.position=oldpos;
appeared=false;
}
}
}
Next idea: during this group appearance all the lights are disabled. If player drags the mouse over any of the spheres, the attached light gets enabled.
During the test all the lights are shut down so the Start () function works. However, they don’t react to the mouse.
The script is attached to each sphere, they all have colliders that don’t cross each other or lay on each other in front of the camera view. I even tried to separate them from each other and from their lights really far - no result. Tried functions Over, Enter, Exit, Click. Also added debug command to know wether or not they detect the mouse. Empty result.
The sphere code:
public class ButtonCheck : MonoBehaviour {
public Light BtnLight;
void Start () {
BtnLight.enabled=false;
}
void OnMouseOver () {
Debug.Log ("Clicked!");
BtnLight.enabled=true;
}
}
I really need help on this one cause otherwise the project can be simply thrown away.