Prefab object gets view Id 0 assigned and fails?

Options
Hi, I modified one of my prefabs today and found that I'm now encountering issues.
I applied the prefab change to all of my scenes. First thing I find quite odd is that the prefab does not have the same PhotonView ID in all scenes.

Also, in some scenes, even though the id is diffferent in the editor, after running the scene this PhotonView gets ID 0. This leads to a failed PUNRPC call.

I'm super confused about this. Any ideas what could be causing it?

Thanks!

Comments

  • Spaggi
    Options
    Hmm, its very odd.

    I've set the prefab to a random number in editor, however when applying the prefab it resets it to 1

    See for yourself:

    https://giphy.com/gifs/xT0xeKMh2jW0ousB1K

    I saw this thread, but wasn't able to fix it for all my scenes. It works just in some even though it's a blue prefab object


    Also, I'm getting the following error in console:

    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.GameObjectInspector.RegisterNewComponents (System.Collections.Generic.List`1 newHierarchy, System.Collections.Generic.List`1 hierarchy) (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:412)
    UnityEditor.GameObjectInspector.RevertAndCheckForNewComponents (UnityEngine.GameObject gameObject) (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:373)
    UnityEditor.GameObjectInspector.DoPrefabButtons (PrefabType prefabType, UnityEngine.GameObject go) (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:302)
    UnityEditor.GameObjectInspector.DrawInspector () (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:226)
    UnityEditor.GameObjectInspector.OnHeaderGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/GameObjectInspector.cs:136)
    UnityEditor.Editor.DrawHeader () (at C:/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:355)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor[] editors, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1116)
    UnityEditor.InspectorWindow.DrawEditors (UnityEditor.Editor[] editors) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1021)
    UnityEditor.InspectorWindow.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:362)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:272)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:265)
    UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:232)
  • Spaggi
    Options
    I temporarely fixed it by assinging the PV Ids by hand in all scenes and saved the scenes without applying the prefab. However the ids might break if I update the prefab in the future. So a root cause analysis would be much appreciated!
  • Tobias
    Options
    A prefab in a scene is not a prefab.
    It's an instance of the prefab in the scene.
    All instances must have unique viewIDs (it's what the ID identifies, after all), so our Editor scripts will do exactly as you describe: assign unique IDs.

    You should be able to manually assign a ViewID to some GO at runtime and keep this "manually instantiated" GO with ID across scenes (via DontDestroyOnLoad).

    https://doc.photonengine.com/en-us/pun/current/gameplay/instantiation#manual_instantiation