UI Designer Exception

fablechris

New member
Unity 2020.3.18f1 (LTS)

I just started setting up my first database and I'm running into this exception when I try to open the UI Designer tab in the Inventory Manager window. The window is completely blank and this exception appears in the console:

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Opsive.UltimateInventorySystem.Editor.Managers.UIDesigner.UIDesignerSchemaSetupSubMenu..ctor () (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/UIDesigner/SetupDesigner.cs:171)
Opsive.UltimateInventorySystem.Editor.Managers.UIDesigner.SetupDesigner..ctor () (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/UIDesigner/SetupDesigner.cs:45)
Opsive.UltimateInventorySystem.Editor.Managers.UIDesigner.UIDesignerManager.BuildVisualElements () (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/UIDesigner/UIDesignerManager.cs:105)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.UpdateDatabase (Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase database) (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:538)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.set_Database (Opsive.UltimateInventorySystem.Storage.InventorySystemDatabase value) (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:100)
Opsive.UltimateInventorySystem.Editor.Managers.SetupManager+<>c__DisplayClass12_0.<BuildVisualElements>b__0 (UnityEngine.UIElements.ChangeEvent`1[T] evt) (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/SetupManager.cs:80)
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase evt) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.DefaultDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.VisualElement.SendEvent (UnityEngine.UIElements.EventBase e) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
UnityEngine.UIElements.BaseField`1[TValueType].set_value (TValueType value) (at <08270fb28ecf479b927dcf4fe817bc07>:0)
Opsive.UltimateInventorySystem.Editor.Managers.SetupManager.DuplicateDatabase () (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/SetupManager.cs:223)
Opsive.UltimateInventorySystem.Editor.Managers.SetupManager.<ShowDatabaseMoreOptionsMenu>b__14_0 () (at Packages/upm-ultimate-inventory/UltimateInventorySystem/Editor/Managers/SetupManager.cs:151)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at <5ad584e208e14caaa9e6b2e6027e9204>:0)
 
I just tried on a fresh project and it's working, so It looks like this is related to how we setup our packages. We tend to pull all of our packages out into individual git submodules so they are easy to isolate and include in the Unity project. There must be some kind of assumption about where the imported assets live and it's causing this particular menu to fail.
 
I'm looking at the code and it seem the issue isn't the path of the file but that the file wasn't found within the Assets folder.
This is what I do to retrieve pre-built schemas.
Code:
void FetchSchemas()
{
    var assetGUIDs = AssetDatabase.FindAssets("t:UIDesignerSchema", new[] { "Assets" });
    m_Schemas.Clear();
    for (var i = 0; i < assetGUIDs.Length; i++) {
        var guid = assetGUIDs[i];
        var path = AssetDatabase.GUIDToAssetPath(guid);
        var schema = AssetDatabase.LoadAssetAtPath<UIDesignerSchema>(path);
        m_Schemas.Add(schema);
    }
}

Have you imported the schemas when importing the asset?
Just in case I changed the code where your issue took place to hopefully have a better error message:
In the SetupDesigner.cs file replace this part of the code:
C#:
public UIDesignerSchemaSetupSubMenu()
{
    m_Schemas = new List<UIDesignerSchema>();
    FetchSchemas();
    m_PanelManagerField = new ObjectField("DisplayManager");
    m_PanelManagerField.objectType = typeof(DisplayPanelManager);
    m_PanelManagerField.value = GameObject.FindObjectOfType<DisplayPanelManager>();
    m_PanelManagerField.RegisterValueChangedCallback(evt => { Refresh(); });
    Add(m_PanelManagerField);
    m_SchemaSelectionContainer = new VisualElement();
    m_SchemaSelectionContainer.style.flexDirection = FlexDirection.Row;
    Add(m_SchemaSelectionContainer);
    if (UIDesignerSchema == null) {
        if (m_Schemas.Count != 0) {
            UIDesignerManager.UIDesignerSchema = m_Schemas[0];
        }
    }
    var defaultValue = UIDesignerSchema;
    if (defaultValue == null) {
        Debug.LogError(
            "ERROR: No Schemas were found in the project, make sure at least one exist. Try Reimporting the UIDesignerSchema asset if one does exist");
        return;
    }
    
    ...
    ...
    ...
 
Top