- Home /
Drag scene object works in editor but not in release
Hello world,
I am working in the Unity Editor 2019.4.8f1 and have a little problem. Please imagine an empty scene with a GameObject, where the following script is attached to:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class TransportTest : MonoBehaviour
{
public Object scene;
private void Start()
{
SceneManager.LoadScene(scene.name);
}
}
The public Object scene was a scene, dragged&dropped from the project view into the objects script component. Running this script in the Editor works pretty well. But when I use this in a built version of the game, I get a null reference exception. Here's what the log says:
Mono path[0] = 'C:/Users/SteakTop/Desktop/Unity Projects/Prototype Light in the Lost/Build v0.4.7/Prototype Light in the Lost_Data/Managed' Mono config path = 'C:/Users/SteakTop/Desktop/Unity Projects/Prototype Light in the Lost/Build v0.4.7/MonoBleedingEdge/etc' PlayerConnection initialized from C:/Users/SteakTop/Desktop/Unity Projects/Prototype Light in the Lost/Build v0.4.7/Prototype Light in the Lost_Data (debug = 0) PlayerConnection initialized network socket : 0.0.0.0 55313 Multi-casting "[IP] 192.168.8.100 [Port] 55313 [Flags] 3 [Guid] 700479046 [EditorId] 2792049016 [Version] 1048832 [Id] WindowsPlayer(LAPTOP-RA4VVA5H) [Debug] 1 [PackageName] WindowsPlayer [ProjectName] Prototype Light in the Lost" to [225.0.0.222:54997]... Waiting for connection from host on [0.0.0.0:55313]... Remaining time:8s Remaining time:7s Remaining time:6s Remaining time:5s Remaining time:4s Remaining time:3s Remaining time:2s Remaining time:1s Remaining time:0s Timed out. Continuing without host connection. Started listening to [0.0.0.0:55313] Starting managed debugger on port 56046 Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,server=y,suspend=n,address=0.0.0.0:56046 PlayerConnection already initialized - listening to [0.0.0.0:55313] Initialize engine version: 2019.4.8f1 (60781d942082) [Subsystems] Discovering subsystems at path C:/Users/SteakTop/Desktop/Unity Projects/Prototype Light in the Lost/Build v0.4.7/Prototype Light in the Lost_Data/UnitySubsystems GfxDevice: creating device client; threaded=1 Direct3D: Version: Direct3D 11.0 [level 11.0] Renderer: NVIDIA GeForce GTX 950M (ID=0x139a) Vendor: (null) VRAM: 2010 MB Driver: 26.21.14.4614 Begin MonoManager ReloadAssembly - Completed reload, in 0.218 seconds D3D11 device created for Microsoft Media Foundation video decoding. Initializing input.
Input initialized.
Initialized touch support.
UnloadTime: 1.253800 ms NullReferenceException: Object reference not set to an instance of an object at TransportTest.Start () [0x00001] in C:\Users\SteakTop\Desktop\Unity Projects\Prototype Light in the Lost\Assets\TransportTest.cs:12
(Filename: C:/Users/SteakTop/Desktop/Unity Projects/Prototype Light in the Lost/Assets/TransportTest.cs Line: 12)
I tripple checked, that the scene is added to the build settings / scene in build. I use the Mono compiler. (The L2cpp compiler didn't want to work) My target plattform is Windows. I have really no idea what is going on here and try to troubleshoot this problem for days now. Does anybody have a hint or a solution? Or nearly an explanation why this may not ever work?
Thanks in advance.
Your answer
![](https://koobas.hobune.stream/wayback/20220613021224im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Build Error 1 Answer
Built project, now scripts are missing. 2 Answers
Xcode build fails, How to ? 1 Answer
The 3D camera no longer exists -> AudioListener Spam 2 Answers