After 4.3.3, the output display strange info when load new scene

Hi everyone,

Our game is to publish in WP8 platform. I upgraded my Unity to 4.3.3 this afternoon. After this, whenever I run the game(maybe especially when the game loads a new scene), there are countless strange message displayed in the output of VS2012. They are something like this below:

Incorrectly unloaded MonoBehaviour class ‘UIAnchor’ in prefab ‘b_BackgroundCenter’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

While the output keep on saying these, the game lag heavily. What’s wrong? Has something to do with 4.3.3?

Any help is appreciated!!

Can you post the player log? Also, are you running debug configuration by any chance? Which Unity version did you upgrade from?

When you upgraded Unity version, did you rebuilt the project cleanly (as in not on top of visual studio solution built with older version of Unity)?

Build from ‘’ branch, version is ‘4.3.3f1 (c8ca9b6b9936)’ (Release build).
Physical memory: 1912 MB, commited memory limit: 570 MB.
PlayerConnection initialized from C:/Data/Programs/{2FCCC7D2-EE02-4F72-BED5-

5C05BC761D13}/Install/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55221
Multi-casting "[IP] 192.168.0.111 [Port] 55221 [Flags] 2 [Guid] 244502440 [EditorId] 4219120905

[Version] 1048832 [Id] WP8Player(192.168.0.111) [Debug] 0" to [225.0.0.222:54997]…
Direct3D:
Version: Direct3D 11.0 [level 9.3]
Renderer: Qualcomm Adreno 330 (WDDM v1.2) (ID=0x46363432)
Vendor: Qualcomm
VRAM: 350 MB
Initialize engine version: 4.3.3f1 (c8ca9b6b9936)
item type error at row981

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

item type error at row1181

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

CheckUpdate C:/Data/Users/DefApps/AppData/{2FCCC7D2-EE02-4F72-BED5-5C05BC761D13}/Local

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

Resource Version : 0

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

GET check_update
params:
channel=10001
platform=ios
client_version=9
resource_version=0
env=dev

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

Gzip

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

GET check_update
{ “status”: “up-to-date”}

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

Incorrectly unloaded MonoBehaviour class ‘PlayIdleAnimations’ in prefab ‘shan_gui_bei_qi’ during

GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour

directly instead of the game object or other component.

(Filename:

C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp

Line: 658)

Incorrectly unloaded MonoBehaviour class ‘PlayIdleAnimations’ in prefab ‘gu’ during

GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour

directly instead of the game object or other component.

(Filename:

C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp

Line: 658)

Incorrectly unloaded MonoBehaviour class ‘uv’ in prefab ‘lun_effect’ during

GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour

directly instead of the game object or other component.

(Filename:

C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp

Line: 658)

Incorrectly unloaded MonoBehaviour class ‘uv’ in prefab ‘ma_tou_qin_effect’ during

GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour

directly instead of the game object or other component.

(Filename:

C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp

Line: 658)

Incorrectly unloaded MonoBehaviour class ‘PlayIdleAnimations’ in prefab ‘mie_xian_fan’ during

GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour

directly instead of the game object or other component.

(Filename:

C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp

Line: 658)

Incorrectly unloaded MonoBehaviour class ‘PlayIdleAnimations’ in prefab ‘dizi’ during

GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour

directly instead of the game object or other component.

(Filename:

C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp

Line: 658)

Unloading 7 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)

Unloading 42 unused Assets to reduce memory usage. Loaded Objects now: 1165. Operation took

306.876862 ms.
System memory in use: 12.0 MB.
UnloadTime: 9.004739 ms
SpawnPool MenuPlayerAIPool: Initializing…

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

SpawnPool MenuPlayerAIPool: Preloading 5 MenuPlayerAI

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.Transform

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.NavMeshAgent

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

CharacterGenerator

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

MenuPlayerAI

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

XCharacterInfo

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UIShowPlayerName

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.Transform

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshFilter

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshRenderer

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.Transform

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshFilter

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshRenderer

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.Transform

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshFilter

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshRenderer

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.Transform

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshFilter

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshRenderer

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.Transform

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.Transform

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

UnityEngine.MeshFilter

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/WP8SupportGenerated/UnityEngineDebug.cpp

Line: 55)

These are the log content. We upgrade from 4.3.1. We didn’t do the clean build.

Can you try rebuilding it cleanly?

Did you try switching to Master configuration? Or is that not an option?

I have the same bug:

Incorrectly unloaded MonoBehaviour class ‘MarkLine’ in prefab ‘MarkLine’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

After build the game works not correctly (Release and Master configuration) : (

Are you using asset bundles?

There is a known issue that sometimes assets are unloaded incorrectly on scene load, can happen with asset bundles, but not limited to. This can be prevented using this method on appropriate objects:

No.

I fixed:

public class MyScript: MonoBehaviour
{
public static MyScript_this;

void Awake ()
{
_this = this;
}
//add code
** private void OnDestroy()**
** {**
** _this = null;**
** } **
}

But you can not everywhere (

Hi there

Even we are getting the same issue and Sef’s script also couldn’t fix it.

Will appreciate if someone can point to alternate fixes. Thanks.

Regards
Shashank

Instead of setting static variable you can call DonDestroyOnLoad(object).

Wouldn’t this keep the object in memory while we don’t want to keep the object in memory ?
I mean if a scene has an object and we use DontDestroyOnLoad on that object, then its memory
wont be freed on scene change and so keep on leaking ?

Regards
Shashank

I’m seeing the same, and when running in release or master mode I’m seeing broken behavior.

I get the following from the log:

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/MetroSupportGenerated/UnityEngineDebug.cpp Line: 55)

Incorrectly unloaded MonoBehaviour class ‘UITexture’ in prefab ‘AppIcon’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘TweenColor’ in prefab ‘ButtonBackground’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UISprite’ in prefab ‘Background’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonOffset’ in prefab ‘Button’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonOffset’ in prefab ‘CloseButton’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UISprite’ in prefab ‘ButtonBackground’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButton’ in prefab ‘Button’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonSound’ in prefab ‘CloseButton’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UILabel’ in prefab ‘Label’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIPanel’ in prefab ‘OtherAppsView’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButton’ in prefab ‘CloseButton’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonScale’ in prefab ‘CloseButton’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonScale’ in prefab ‘Button’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UILabel’ in prefab ‘titleLabel’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonMessage’ in prefab ‘CloseButton’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘OtherAppPanel’ in prefab ‘OtherAppsView’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UILabel’ in prefab ‘infoLabel’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UISprite’ in prefab ‘backdrop’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonMessage’ in prefab ‘Button’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UIButtonSound’ in prefab ‘Button’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UISprite’ in prefab ‘background’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/PlatformDependent/WinRT/GarbageCollectSharedAssetsWinRT.cpp Line: 658)

Incorrectly unloaded MonoBehaviour class ‘UISprite’ in prefab ‘Background’ during GarbageCollectUnusedAssets.
The Object will be reloaded from disk, to fix this properly keep a reference to the MonoBehaviour directly instead of the game object or other component.

I do turn various objects off/on using the NGUI setActive methods…

I found the problem - there was a resource prefab I loaded at startup that was used when the user tried to connect to facebook - on Windows Store I don’t do use Facebook (at the moment) so that resource was unused and as I had a static reference to it, it generated these errors when the scene changed. Removed loading it and the static reference and all those errors went away.

Turns out my unusual behavior was related to another Facebook issue that I hadn’t removed correctly.

Grrr… so it still happens on a WP8 version, but now with a lot of prefabs that existed in one scene but not the next – maybe for WP8 I need to clean out a lot of references myself when switching scenes.

I can confirm that keeping and accessing references to objects that were destroyed due to scene load causes these errors. I also suspect it to cause random crashes. Clear those references guys ^^

This happens when I call Destroy(someGameObject) and then call Resources.UnloadUnusedAssets
Sometimes its crashes.
Sometimes its shows null reference if call gameObject.SetActive(bool) and this gameObject was no active at start exception stack trace tells that error somewhere in Start method, but gameObject become active after this method.

On scene happens something wild.

Im getting this also, huge spamming of this error message on winstore builds. I only have one scene. Is there a bug report for this we can track? I have tried holding references etc but havent found anything that makes a difference.

Ok, I think I have sorted out what is happening in my case.

When Resources.UnloadUnusedAssets is called, it is failing to keep hold of certain prefab objects which had been stored a static dictionary with values consisting of a simple class which contains a pointer to the prefab. If I store the prefabs in a list public nonstatic variable in a Monobehavior in the game hierarchy, they don’t get unloaded and no spamming of that error occurs.

I haven’t bothered to establish whether it is being static, being a dictionary<>, or being a member of a simple non-monobehaviour-derived class is the critical issue. (but it was not enough just to make it nonstatic). I encountered a similar problem a while ago where it was using a dictionary that caused a crash on win8 after reload, but Unity eventually fixed that one after several bug reports and example programs.