Error CS1519
I'm getting the error message: Assets/Scripts/ButtonExecute.cs(10,25): error CS1519: Unexpected symbol `=' in class, struct, or interface member declaration. I've seen other posts where people got this from missing a semicolon, but I can't seem to find any spot like that. Here's the code: using UnityEngine; using UnityEngine.EventSystems; using System.Collections;
public class ButtonExecute : MonoBehaviour {
public float timeToSelect = 2.0f;
private float countDown;
private GameObject currentButton;
private clicker = new Clicker ();
void Update () {
Transform camera = Camera.main.transform;
Ray ray = new Ray (camera.position, camera.rotation * Vector3.forward);
RaycastHit hit;
GameObject hitButton = null;
PointerEventData data = new PointerEventData (EventSystem.current);
if (Physics.Raycast (ray, out hit)) {
if (hit.transform.gameObject.tag == "Button") {
hitButton = hit.transform.parent.gameObject;
}
}
if (currentButton != hitButton) {
if (currentButton != null) {
ExecuteEvents.Execute<IPointerExitHandler> (currentButton, data, ExecuteEvents.pointerExitHandler);
}
currentButton = hitButton;
if (currentButton != null) {
ExecuteEvents.Execute<IPointerExitHandler> (currentButton, data, ExecuteEvents.pointerEnterHandler);
countDown = timeToSelect;
}
}
if (currentButton != null) {
countDown -= Time.deltaTime;
if (clicker.clicked () || countDown < 0.0f) {
ExecuteEvents.Execute<IPointerClickHandler> (currentButton, data, ExecuteEvents.pointerClickHandler);
countDown = timeToSelect;
}
}
}
}
Answer by PaEnsing · Dec 05, 2015 at 05:18 AM
I was missing the type identifier for the clicker
. After adding this, the code was fixed: private Clicker clicker = new Clicker();
Answer by ucezhu · Oct 25, 2016 at 07:06 AM
could you tell me how you correct the " missing the type identify for the clicker", where did you added? thanks!
It's been awhile since I've looked at this code, so I might be wrong, but I'm pretty sure I had to edit line 6 to say private Clicker clicker = new Clicker ();