Odin support for the Addressables unity package

Issue #448 resolved
Tor Esa Vestergaard created an issue

Reports are that Odin currently does not work with Unity's new Addressables system. This should probably be dealt with sooner rather than later.

Comments (10)

  1. Sirawat Pitaksarit

    Here's the error. Asset group will try to draw multiple schema associate with it (0.4.0+ new feature)

    Screenshot 2018-10-14 21.30.22.png

    It draws just fine when Odin off

    Screenshot 2018-10-14 21.41.42.png

    Putting some debug label and it goes like this :

    Screenshot 2018-10-14 21.46.29.png

    Screenshot 2018-10-14 21.46.18.png

  2. Tor Esa Vestergaard reporter

    Still not clear where Odin actually comes in, there, since the code there has nothing to do with Odin, but we'll investigate the issue and see what comes of it

  3. Sirawat Pitaksarit

    I think when Odin reflect call OnInspectorGUI it might break the gui layout pair or something?

    Also with Odin off, (but there is an odin drawing in the pref) I can cause this error by pressing arrow key up-down on those assets quickly. (Just clicking slowly does not trigger the error) The odin list disappear/appear as these error logs up.

    https://www.youtube.com/watch?v=WsQIML4yul4

    Pop call mismatch; no corresponding push call! Each call to Pop must always correspond to one - and only one - call to Push.
    UnityEngine.Debug:LogError(Object)
    Sirenix.Utilities.Editor.GUIScopeStack`1:Pop() (at F:/Sirenix/Sirenix Solution/Sirenix.Utilities.Editor/GUI/GUIScopeStack.cs:29)
    Sirenix.Utilities.Editor.GUIHelper:PopHierarchyMode() (at F:/Sirenix/Sirenix Solution/Sirenix.Utilities.Editor/GUI/GUIHelper.cs:624)
    Sirenix.Utilities.Editor.SirenixEditorGUI:EndHorizontalToolbar() (at F:/Sirenix/Sirenix Solution/Sirenix.Utilities.Editor/GUI/SirenixEditorGUI.cs:1531)
    Sirenix.OdinInspector.Editor.InspectorTypeDrawingConfigDrawer:DrawPropertyLayout(GUIContent)
    Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:191)
    Sirenix.OdinInspector.Editor.Drawers.NullableReferenceDrawer`1:DrawPropertyLayout(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/QuaternionDrawer.cs:61)
    Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:191)
    Sirenix.OdinInspector.Editor.Drawers.ReferenceValueConflictDrawer`1:DrawPropertyLayout(GUIContent)
    Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:191)
    Sirenix.OdinInspector.Editor.Drawers.ReferencePathConflictDrawer`1:DrawPropertyLayout(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/ValueDropdownAttributeDrawer.cs:64)
    Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:191)
    Sirenix.OdinInspector.Editor.Drawers.FixUnityNullDrawer`1:DrawPropertyLayout(GUIContent)
    Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:191)
    Sirenix.OdinInspector.Editor.Drawers.ReferenceDrawer`1:DrawPropertyLayout(GUIContent)
    Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:146)
    Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/PropertyRangeAttributeDrawer.cs:650)
    Sirenix.OdinInspector.Editor.InspectorUtilities:DrawPropertiesInTree(PropertyTree) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:250)
    Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/InlineEditorAttributeDrawer.cs:380)
    Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:190)
    Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector()
    Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:190)
    Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditor(Int32) (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyListValueEntryChanger.cs:336)
    Sirenix.OdinInspector.Editor.OdinEditorWindow:DrawEditors()
    Sirenix.OdinInspector.Editor.OdinEditorWindow:OnGUI() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyListValueEntryChanger.cs:240)
    Sirenix.OdinInspector.Editor.OdinMenuEditorWindow:OnGUI() (at F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/OdinSelectors/OdinSelector.cs:555)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    
  4. Tor Esa Vestergaard reporter

    This is now fixed according to the folks at Unity, and the fix should be included in the next release of the Addressables package. (As of the time of writing, the current version is 4.8, so the fix should be in whatever version comes out after that.) I'll let this issue hang around for a bit - once the next Addressables patch releases, it would be nice if someone could give it a whirl and verify that the issue is indeed resolved, so we can mark it so here.

  5. Fidel Soto

    It seems like this issue is fixed but now I have a different one: I have an object with an instance of a list of derived classes and it breaks on builds if the object is put in an addressable asset bundle on a server.

  6. Tor Esa Vestergaard reporter

    I'm afraid that doesn't really help us track down a potential issue. Could you clarify a bit and give some more information - detailed reproduction steps, stacktraces and error logs, screenshots, etc?

  7. Fidel Soto

    I have a prefab which has a script with a list of derived classes. Example structure of the derived class: Base Class - Derived Class 1 - Derived Class 2 All derived classes inherit from Base Class. I have a prefab that has a script with a list of type BaseClass, like this: List<BaseClass> The script inherits SerializedMonoBehaviour. The prefab is inside an addressable remote group. I do the following operations: 1. Addressables.Instante the prefab. 2. Do a GetComponent on the Result from the Addressables.Instantiate when completed. On the editor everything works, even packed mode. When I build for Android however, I get a null reference exception when I do the GetComponent on the Result, even though the prefab is instantiated correctly (or at least referenced since when I do obj.Result.name I get the correct name followed by the (clone) suffix.

    public class BaseClass { }

    public class DerivedClass1 : BaseClass { }

    public class DerivedClass2 : BaseClass { }

    public class ScriptThatGoesOnThePrefab : SerializedMonoBehaviour { public List<BaseClass> myList; }

    public class ScriptThatRuns : MonoBehaviour {

    void Start() { Addressables.Instantiate("Assets/prefab.prefab").Completed += CompletedFunction; }

    private void CompletedFunction(IAsyncOperation<GameObject> obj) { var currentInstance = obj.Result; Debug.Log("Current instance: " + currentInstance .name); //THIS PRINTS OUT CORRECTLY var instanceOfTheScriptOnTheInstantiatedPrefab = currentInstance.GetComponent<ScriptThatGoesOnThePrefab>(); //THIS THROWS OUT AN ERROR }

    }

    The error is:

    NullReferenceException encountered in operation UnityEngine.ResourceManagement.AsyncOperations.ChainOperation2[UnityEngine.GameObject,System.Collections.Generic.IList1[System.Object]], result='prefab(Clone) (UnityEngine.GameObject)(-29512)', status='Failed', valid=True, location=Assets/prefab.prefab..

    UnityEngine.AsyncOperation:InvokeCompletionEvent()

    Remember that it works fine on the editor in all play modes (fast, virtual, packed). The error happens on Android.

    Edit: omg the post lost all line breaks and spaces, ew

  8. Fidel Soto

    In the end I opted for redoing the entire system with a simpler structure, avoiding derived classes altogether. It's gonna take a few days of work but it's going to work, I already tested it. It will also be worth it just for having the simpler structure (easier to use). Thanks!

  9. Tor Esa Vestergaard reporter

    I would hazard a guess that this was more on the addressables system than Odin itself. Addressables have seen a lot of work since this issue was reported. If any issues like this crop up, anyone can feel free to comment on this issue or make a new issue - meanwhile, I'll close this issue down, as the original issue was fixed.

  10. Log in to comment