Inspector assigned variables not assigning in build
So, for the past two hours or so, I was confronting with this weird bug that came out of nowhere.
Without further ado, this is my problem:
Any public variable(that can be assigned in the inspector) isn't showing up/updated in the build but works just fine in the editor. Even if I set the value in code, if the variable is public, it won't show up/be updated. But, if I change the modifier to 'private', it works with no problems.
So, the public variables that existed before the bug, even if I change them(script or inspector, doesn't matter), they hold the value that they had before the bug appeared, and if I try to add new public fields, they just don't show up, here a little example:
using UnityEngine;
using System.Collections;
public class TestScript : MonoBehaviour {
public GameObject publicVariable;
void Start ()
{
Debug.LogError("publicVariable.name = " + publicVariable.name);
}
}
here, I am assigning a gameobject to 'publicVariable' form the inspector. When I run the script in the editor, it works as expected:
publicVariable.name = GeneratorBoundsLeft
UnityEngine.Debug:LogError(Object)
However, if I run this on a development build, the Debug.LogError doesn't show up at all.
I hope this was enough information to describe my problem. If code is needed, I will provide.
Any help would be much appreciated.
So, i've fixed it by exporting the project as package and importing it in a brand new project. Now everything works fine.
Your answer
Follow this Question
Related Questions
How do i fix my problem with minimizing/maximizing and just opening unity editor windows? 0 Answers
Unity Has Completely Stopped Working on My Computer 0 Answers
Unity 5.0 Crashing At Opening A Project 6 Answers
Unity 2017 or 5.6 Doesn't work after install. Editor is broken. 0 Answers
How to create a drop down menu in editor inspector 0 Answers