When I saved my C# code, I came up with 2 errors in the Unity Editor:
“} expected”
“Type or namespace definition, or end-of-file expected”
I do not see ANY errors that could have popped up.
Here’s my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Button2 : MonoBehaviour
{
private static Button2 instance;
public static Button2 SharedInstance {
get
{
if (instance == null)
{
instance = new Button2();
}
return instance;
}
public int start;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0) == true)
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (hit.transform.name == "Square")
{
start = 1;
}
}
}
}
}
What happened?