When I played the game I made in the editor, it ran fine.
klutzynecessarygermanspaniel
But when I export it to windows, the menu and the watermark scenes worked fine but when actually playing the game it the performance is bad or nothing is happening except for the updating of the UI.
pleasantverifiableambushbug
Please help
[EDIT]
When I ran the profiler (somebody suggested to use it) on the build, the scripts usage on the cpu is VERY HIGH. But I couldn’t figure out what was making it spike.
[EDIT 2]
When playing the game in build, other than the bad performance the music doesn’t sync as well even though it lines up fine in the editor. Here is the code for the music syncing:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class KeyClick : MonoBehaviour
{
public KeyCode key;
bool active = false;
GameObject note;
public SpriteRenderer rendererSprite;
public Sprite pressedKey;
public Sprite unpressedKey;
public AudioSource music;
void Update()
{
if (Input.GetKeyDown(key) && active)
{
add();
Destroy(note);
}
if (Input.GetKeyDown(key) && active == false){
minus();
}
if (Input.GetKeyUp(key))
{
rendererSprite.sprite = unpressedKey;
}
if (Input.GetKeyDown(kee))
{
rendererSprite.sprite = pressedKey;
}
}
//Void add and minus for the score
void add(){
scorekeeper.score += 5;
canvasManager.notesClicked++;
}
void minus(){
scorekeeper.score -= 2;
}
void OnTriggerEnter2D(Collider2D collision1)
{
active = true;
if (collision1.gameObject.tag == "note"){
note = collision1.gameObject;
}
//Music Sync Code
if (collision1.gameObject.tag == "openingkey"){
music.Play();
note = collision1.gameObject;
}
}
void OnTriggerExit2D(Collider2D collision)
{
active = false;
}
}