Not loading stylesheet

Zaddo

Active member
My UIS editor window is coming up blank. It is getting an error in MainManagerWindow on this line:

Code:
            rootVisualElement.styleSheets.Add(InspectorUtility.LoadAsset<StyleSheet>("e70f56fae2d84394b861a2013cb384d0"));//shared uss

ArgumentNullException: Value cannot be null.
Parameter name: styleSheet
UnityEngine.UIElements.VisualElementStyleSheetSet.Add (UnityEngine.UIElements.StyleSheet styleSheet) (at Library/PackageCache/com.unity.ui@1.0.0-preview.13/Core/VisualElementStyleSheetSet.cs:30)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow.OnEnable () (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:239)
UnityEditor.EditorWindow:GetWindow(Boolean, String)
Opsive.UltimateInventorySystem.Editor.Managers.MainManagerWindow:ShowWindow() (at Assets/Opsive/UltimateInventorySystem/Editor/Managers/MainManagerWindow.cs:125)

The UIS editor does work in a pristine project.

I hunted for the Guid and found it was in this file: G:\UnityProjects\UCCPristine\UCCPristine\Assets\Opsive\Shared\Editor\UIElements\Styles\SharedStyles.uss.meta

This file in my game project has the same guid value. As they are the same, I don't know why the InspectorUtility cannot find it?

I compared the folder structure between the pristine and my game projects. The Opsive/Shared and Opsive/UltimateInventorySystem were identical. I tried deleting these folders and reimporting the UIS package. This did not fix the issue.

Do you know why, the InspectorUtility is not finding the file?

UIS Version: 1.1.4
UCC Version: 2.2.7
Unity Version: 2020.2.1f1 URP

Thx

1612008734761.png



1612007481681.png
 
Last edited:
Found a fix.

I think this this issue is caused because I have the UI Toolkit loaded.

To fix this I need to add the following line to the bottom of the meta data for each style sheet (*.uss.meta):
Code:
  disableValidation: 0

CommonStyles.uss.meta
ControlTypeStules.uss.meta
ManagerStyles.uss.meta
ReorderableListStyles.uss.meta
SharedStyles.uss.meta

The call to InspectorUtility.LoadAsset does not work for some reason. Maybe because it is compiled into a DLL.

So I created the following static utility in the Opsive.Shared assembly and changed all calls from InspectorUtility.LoadAsset to LoadAssetUtility.LoadAsset.

CommonStyles.cs
ControlTypeStyles.cs
ManagerStyles.cs
MainManagerWindow.cs
InstpectorBase.cs

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public static class LoadAssetUtility
{
    public static T LoadAsset<T>(string guid) where T : UnityEngine.Object
    {
        string assetPath = AssetDatabase.GUIDToAssetPath(guid);
        return !string.IsNullOrEmpty(assetPath) ? AssetDatabase.LoadAssetAtPath(assetPath, typeof(T)) as T : (T)null;
    }

}

Please let me know if there is an simpler solution than this.

EDIT: I had to re-install, so I am updating this with a little more detail as I go through it
 
Last edited:
I'm sorry about this, I had never seen this problem before. I will dig into it to see if I can find any other solution.
I'm glad you found a work around in the meantime.
 
hummm Perhaps there is a clash between the guids from both packages.
So we are expecting a uss file but perhaps Debugging Essentials has another asset for that exact same guid...
But for that to happen to 5 uss files... the probability is extremely low.

The other thing is perhaps Debugging Essentials does something special with uss files which we don't know about.
I would contact Debugging Essentials about this if I were you.

@Justin you may want to have a look at this. Perhaps you have a better hypothesis about this?
 
@Zaddo - Does that error occur regularly? Even if you create a fresh project?
@Justin & @Sangemdoko ,
The menus always work with a fresh project when just UIS and UCC are loaded.

Apologies, I thought I had found the root of the issue, but the UIS menu's are working again with Debugging Essentials loaded.

I cannot find a consistent pattern that causes this issue. I have just rebuilt my project with all packages and assets loaded and the UIS menus are displaying correctly. After glitching when I loaded debugging essentials temporarily, they came good again after I loaded some other assets. I can't give you a reliable way to reproduce this issue. I will update this thread if I can find a pattern.
 
Top