0
Fixed

Applying changes to prefabs with scene references shows "Object reference at index # does not match target type" warning

Alexey Pankov 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 5

I could not update prefab from object in scene to its prefab. Variables are saving on scene prefab, but than i hit apply to prefab they are gone missing with error (also this mistake in prefab mode) :

[Deserialization] Object reference at index #1 does not match target type (UnityEngine.Object != UnityEngine.GameObject). Defaulting to null.

UnityEngine.Debug:LogWarning(Object, Object)
Ludiq.Serialization:HandleResult(String, fsResult, Object) (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Serialization/Serialization.cs:190)
Ludiq.Serialization:DeserializeJson(fsSerializer, String, Object&, Boolean) (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Serialization/Serialization.cs:178)
Ludiq.Serialization:DeserializeInto(SerializationData, Object&, Boolean) (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Serialization/Serialization.cs:113)
Ludiq.LudiqBehaviour:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at C:/Users/lazlo/Projects/Bolt1/Package/Ludiq.Core/Runtime/Unity/LudiqBehaviour.cs:46)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Links on video are here:

https://imgur.com/a/9tP2vEW

Same issue than i try to "open" the prefab instead of changing it in the Hierarchy:

https://imgur.com/a/5XO3DOP

Whan i restarting Unity this Variables become missing.

After updating to v.1.4.1b4 i cant even add object to variable now:

https://imgur.com/a/WcyBiZZ

Its working only if i making new Object with new graph....

https://imgur.com/a/NdgNmeK

i got old prefab, old variable and i could not apply to old variable gameobject.....iam creating in old prefab new variable and still could not apply to old variable gameojbect.....so i making new prefab with new graph and new variable.... so i could now apply gameoibject to new variable....but this is NEW prefab....and he got nothing...after i checked off graphs from old object and run project unity got crashed

https://imgur.com/a/yB3zEZr

Iam tryed rebuld new object and its worked, but after some play scenes my newprefab appeared broken same way.... and i cant add object to GameObect variable type and List <GameObject> type again......

and some bug in inspector.... OMG

Bolt Version:
v.1.4.1b3
Unity Version:
2018.3.0f2
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

just switched now to bolt 2.0 and graph works fine in there. after installing bolt 2.0 i following this:

Run Tools > Ludiq > Fix Missing Scripts...

After restarting unity got same issue....didnt solve it.

If i change variables in inspector and not in variables windows, its keeps save them in bolt 2.0.
But now they didnt match to each other...in variables window and inspector variables, my variables are different:

and Graph tab is not availabe in variables window any more:

error than i want choise gameobject as waypoint in prefabmode:

[Deserialization] Object reference at index #2 does not match target type (UnityEngine.Object != UnityEngine.GameObject). Defaulting to null.

UnityEngine.Debug:LogWarning(Object, Object)
Ludiq.Serialization:HandleFullResult(String, fsResult, Object) (at Assets/Ludiq/Ludiq.Core/Runtime/Serialization/Serialization.cs:195)
Ludiq.Serialization:FullDeserializeJson(fsSerializer, String, Object&, Boolean) (at Assets/Ludiq/Ludiq.Core/Runtime/Serialization/Serialization.cs:183)
Ludiq.Serialization:FullDeserializeInto(FullSerializationData, Object&, Boolean) (at Assets/Ludiq/Ludiq.Core/Runtime/Serialization/Serialization.cs:118)
Ludiq.LudiqBehaviour:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at Assets/Ludiq/Ludiq.Core/Runtime/Unity/LudiqBehaviour.cs:47)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPt


error than i want choise palyer prefab as player variable in prefabmode:


[Deserialization] Object reference at index #1 does not match target type (UnityEngine.Object != UnityEngine.GameObject). Defaulting to null.

UnityEngine.Debug:LogWarning(Object, Object)
Ludiq.Serialization:HandleFullResult(String, fsResult, Object) (at Assets/Ludiq/Ludiq.Core/Runtime/Serialization/Serialization.cs:195)
Ludiq.Serialization:FullDeserializeJson(fsSerializer, String, Object&, Boolean) (at Assets/Ludiq/Ludiq.Core/Runtime/Serialization/Serialization.cs:183)
Ludiq.Serialization:FullDeserializeInto(FullSerializationData, Object&, Boolean) (at Assets/Ludiq/Ludiq.Core/Runtime/Serialization/Serialization.cs:118)
Ludiq.LudiqBehaviour:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at Assets/Ludiq/Ludiq.Core/Runtime/Unity/LudiqBehaviour.cs:47)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

i could upload full project if u need for tests.

+1
Working on Fix

Thanks for the thorough report. I'll have a look at this ASAP. I believe it's related to some very weird reference changes Unity is doing behind the scenes with the new prefab workflow. The devs of Odin mentioned something similar happening on their end.

+1

Thanks for the prompt attitude to the reviews. I believe that you will have the best solution.

Fixed in Beta

Hi Alexey,

I looked into your issue some more and there are actually different things happening here.

The main issue is that you're assigning scene references to the prefab definition itself (an asset), while in version 1.4.1b3. This is not supported in Unity, because assets cannot know about anything in any scene. This is why, when you hit play or restart Unity, the references are lost and set back to null.

In v.1.4.1b4, this was fixed, which is why Bolt does not let you assign scene references to your prefab asset anymore (the forbidden cursor symbol). If you moved to the Instance tab, it would. Let me explain:

The variables window has two tabs: Prefab and Instance. Prefab refers to the prefab definition (the asset) and Instance refers to the prefab instance (the object in the scene). I understand where the source of the confusion comes from, though: the labels are unclear, and by default, Prefab is selected.

Starting in v.1.4.1b5, these tabs will be swapped, and their labels will be made clearer. So they'll be Prefab Instance and Prefab Definition. By default, the Prefab Instance tab will be selected if available.

The scary warning you see is actually a side effect of this invalid assignment. When deserializing the prefab asset, Bolt sees a null-ref Unity Object and freaks out. I improved the handling for this for v.1.4.1b5, so there won't be a warning anymore.

Hope that clarifies things!

tl;dr: Make sure you're in the Instance tab when assigning scene references.