modio / modio-unity

Unity Engine Plugin for easily integrating mod.io into your game - the UGC management service for game developers
https://mod.io
MIT License
28 stars 7 forks source link

Addressables build fails if ModIOBrowser from Assets/Plugins/mod.io/UI/Examples/ModIOBrowser.prefab is in a Scene because the asset Assets/Plugins/mod.io/UI/Sprites/modio-icon-color.png is marked with HideFlags.DontSave #7

Open Raidenxd2 opened 6 months ago

Raidenxd2 commented 6 months ago

Unity version: 2022.3.29f1 Addressables version: 1.21.21 Scriptable Build Pipeline version: 1.21.23 Mod.io version: v2024.3.1p1

Have no if this is a Unity issue or a mod.io issue

Title, the only way to temporary fix this is to restart the Editor. The reason why I say "temporary" is because when you modify the Scene that contains the ModIoBrowser prefab or clear the build cache, it fails again Blank Unity project (template '3D (Built-In Render Pipeline').

Errors on Addressable build Error 1: An asset is marked with HideFlags.DontSave but is included in the build: Asset: 'Assets/Plugins/mod.io/UI/Sprites/modio-icon-color.png' Included from scene: 'Assets/Scenes/ModIoScene.unity' Asset name: modio-icon-color (You are probably referencing internal Unity data in your build.) UnityEditor.GenericMenu:CatchMenu (object,string[],int)

Error 2: Assertion failed on expression: 'm_LockCount == 0' UnityEditor.GenericMenu:CatchMenu (object,string[],int)

Error 3: Build Task WriteSerializedFiles failed with exception: Could not find file "E:\Stuff\stuff\ModIoAddressablesTest\Library\BuildCache\c6\c6ffc3440e239d2963c8dd27ab1a16dd\81e0980ee0c78fb2f9e216fdae7205d1\CAB-bc35dac5a8e94bc239d1b52bd86bc27f.sharedAssets" at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <467a840a914a47078e4ae9b0b1e8779e>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) [0x00000] in <467a840a914a47078e4ae9b0b1e8779e>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access) [0x00000] in <467a840a914a47078e4ae9b0b1e8779e>:0 at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess) at UnityEditor.Build.Pipeline.Utilities.HashingMethods.CalculateFile (System.String filePath) [0x00000] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Utilities\HashingMethods.cs:488 at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.CalculateFileMetadata (UnityEditor.Build.Content.WriteResult& result) [0x0002f] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\WriteSerializedFiles.cs:134 at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility.IRunCachedCallbacks<UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.Item>.ProcessUncached (UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility+WorkItem1[T] item) [0x000bb] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\WriteSerializedFiles.cs:178 at UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility.RunCachedOperation[T] (UnityEditor.Build.Pipeline.Interfaces.IBuildCache cache, UnityEditor.Build.Pipeline.Interfaces.IBuildLogger log, UnityEditor.Build.Pipeline.Interfaces.IProgressTracker tracker, System.Collections.Generic.List1[T] workItems, UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility+IRunCachedCallbacks1[T] cbs) [0x00177] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Utilities\TaskCachingUtility.cs:100 at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.Run () [0x0003b] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Tasks\WriteSerializedFiles.cs:120 at UnityEditor.Build.Pipeline.BuildTasksRunner.Run (System.Collections.Generic.IList1[T] pipeline, UnityEditor.Build.Pipeline.Interfaces.IBuildContext context) [0x0009d] in .\Library\PackageCache\com.unity.scriptablebuildpipeline@1.21.23\Editor\Shared\BuildTasksRunner.cs:56 UnityEditor.GenericMenu:CatchMenu (object,string[],int)

Error 4: SBP ErrorException UnityEditor.GenericMenu:CatchMenu (object,string[],int)

Error 5: Addressable content build failure (duration : 0:00:11.629) UnityEditor.GenericMenu:CatchMenu (object,string[],int)

After restarting the Editor, the build succeeds

I also tried to search through the code for 'HideFlags.DontSave' and 'HideFlags' but couldn't find anything.

g6hFN13SDy image image

Raidenxd2 commented 6 months ago

(Will make a pull request later)

Found out how to fix it. The reason this is happening is because scripts are using the same icon that some UI elements are using.

I fixed by duplicating Assets/Plugins/mod.io/UI/Sprites/modio-icon-color.png as modio-icon-color-script.png and changing its texture type to Editor GUI and Legacy GUI

These are the scripts that have this icon (they are all under Assets/Plugins/mod.io/UI) Color Scheme/ColorScheme.cs Color Scheme/ColorSetter.cs Color Scheme/MultiTargetButton.cs Color Scheme/MultiTargetDropdown.cs Color Scheme/MultiTargetToggle.cs Overlays/SelectionOverlayHandler.cs Scripts/Browser.cs Scripts/InputReceiver.cs Utility/ViewportRestraint.cs