I have a problem when trying to build a unity project in Web GL. I am currently using the unity playground script + two of my own design. Here's my script, can anybody tell me what/where the problem is? Thank you!
Error:UnityEditor.BuildPlayerWindow+BuildMethodException: Error building Player because scripts have compile errors in the editor at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002bb] in <90d4bcb003fb405fb09241aed2f178aa>:0 at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <90d4bcb003fb405fb09241aed2f178aa>:0 UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
My scripts:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour
{
public void PlayGame()
{
SceneManager.LoadScene("Game");
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
private Rigidbody2D rb;
private bool isGrounded;
public Transform feetPos;
public float checkRadius, jumpForce, moveInput, speed, jumpTimeCounter,jumpTime;
public LayerMask whatIsGround;
private bool isJumping;
private Animator anim;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
moveInput = Input.GetAxisRaw("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
}
// Update is called once per frame
void Update()
{
isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround);
if(moveInput == 0)
{
anim.SetBool("isRunning",false);
}
else
{
anim.SetBool("isRunning", true);
}
if (moveInput > 0)
{
transform.eulerAngles = new Vector3(0, 0, 0);
}else if(moveInput < 0)
{
transform.eulerAngles = new Vector3(0, 180, 0);
}
if(isGrounded == true && Input.GetKeyDown(KeyCode.Space))
{
isJumping = true;
jumpTimeCounter = jumpTime;
rb.velocity = Vector2.up * jumpForce;
}
if (Input.GetKey(KeyCode.Space) && isJumping==true)
{
if (jumpTimeCounter > 0)
{
rb.velocity = Vector2.up * jumpForce;
jumpTimeCounter -= Time.deltaTime;
}
else
{
isJumping = false;
}
}
if (Input.GetKeyUp(KeyCode.Space))
{
isJumping = false;
}
}
}