I am hoping someone can help me with this issue. Everything in my scene is working fine in the Editor within Unity, but once I build it, I lose some functionality. Like, some of my scripts aren’t working, but the game will run.
Research online, and help from other users sounds like it’s not an issue with my script, but somewhere in the building process (makes sense). I can’t find any kind of a log, and there are no errors in the console.
Try to isolate the problematic scripts into an empty project and test them again in editor and build mode. If you can spot a specific script that causes this issue, share it here so we can comment better.
It appears to be this script, it seems to be the only one that isn’t carrying over to the build.
using UnityEngine;
using System.Collections;
public class DestroyObj : MonoBehaviour {
void OnEnable()
{
StartCoroutine(TurnOff());
}
IEnumerator TurnOff()
{
yield return new WaitForSeconds(2);
gameObject.SetActive(false);
}
}
Also, my other canvas (correct GameObject) isn’t showing up OnMouseDown with this script:
using UnityEngine;
using System.Collections;
public class xThroughIN : MonoBehaviour {
public GameObject xThroughHold;
public GameObject correct;
[SerializeField]
private xThroughINDoer Dd;
void OnMouseDown () {
if (xThroughHold.active)
{
Dd.Switch (true);
xThroughHold.SetActive (false);
correct.SetActive (true);
}
else
Dd.Switch (false);
}
}
It does seem to be exclusively UI objects, if that matters.
Is it a possibility there’s something cached? It looks like I have some UI elements that are no longer being called in any scripts (at least I thought), that are still showing up on build. Does Unity save any files like that?
Figured it out, solution: I’m an idiot. But, I am soooo glad it wasn’t an issue with Unity.
I am very new to Unity, and as an animator, I am used to saving my files in iterations - which I have been doing, so I forgot to add my newer iterations to my build settings, so my Start menu was going to an older version, which is what was being rendered at Build.
I feel bad for my stupidity, but thank you to those that were willing to help!