Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

"An asset is marked with HideFlags.DontSave but is included in the build: SuperTextMeshDataIcon.png"

A topic by Scarlet String Studios created Dec 14, 2023 Views: 275 Replies: 17
Viewing posts 1 to 9

I've been getting an off-and-on build error that points to an STM asset:

An asset is marked with HideFlags.DontSave but is included in the build: Asset: 'Assets/Plugins/Clavian/SuperTextMesh/Scripts/Icons/SuperTextMeshDataIcon.png' Asset name: SuperTextMeshDataIcon (You are probably referencing internal Unity data in your build.)

Unfortunately, I haven't figured out how to reproduce it consistently; it just happens randomly after creating a few builds, and maybe after switching build targets (unsure if the Reload Domain/Reload Scene project settings are related to this). I had this problem with an icon from another asset, too, so I don't think it's specific to STM.

Anyway, I can fix this with an editor script that just sets the object's hide flags to HideFlags.None. However, this specific STM icon keeps resetting itself, so I have to reapply my fix whenever I launch the editor. Do you know if you're setting this icon's hide flags from an editor script somewhere in STM?

Developer

Huh, I think I received a bug report about this a while ago and I checked to make sure the hide flags were correct, and it looked fine at the time... So I'm not too sure what might be changing the hide flags, actually...?

Since the icon is used on the data components, I wonder if it could be related to some kind of hide flag being applied to that? I'll keep thinking about this but if it's happening in another asset too, there may be some other common thing making it happen. For the other asset, is it also applied to a ScriptableObject?

Hmm, yeah, it's a strange problem... googling it brings up a wide variety of results.

The other asset is Water2D Tool, and the file is water2D_Icon.png (another icon, strangely enough). Not sure where the icon is used, but it's probably one of the gizmos.

Were you able to reproduce the bug when the other person reported it? Looking at this thread, it might be affected by the project's folder layout in some way (like Editor vs non-Editor folders) https://forum.unity.com/threads/an-asset-is-marked-with-hideflags-dontsave-but-i...

I'll delete the meta files for the icons and see if that helps. Wish there was an easier way to reproduce it, but it seems very sporadic for me.

Developer

No, I was never able to reproduce it, even after doing builds with projects that contain STM. But yeah it could just be some Unity thing related to Editor folders, then...?

Same Error, Reproduce  with addressables

Developer

Right, I didn't post but I think I was able to fix this one, actually. It'll be fixed in the next update!

emmmm Updrade to 1.13.1 ,and some build errors occurs

Developer

Ah hm, maybe something with the upgrade doesn't fully work since it's a change to metadata... could you delete the icon & its metadata file and try re-importing STM?

I tried deleting the entire asset and re-importing it, but the problem still didn't work out

Developer

Hey, replying to you here since it's a duplicate issue.


https://pastebin.com/0M2kf8D6 Here is the script I wrote that fixed the issue on my end, and what I did to the file before publishing. If you run this script on the same file, does the issue still persist? If so, I need to dig deeper as to why me running this code didn't fix it for everyone else, and if not... well I guess it's back to the drawing board. Sorry for the trouble! It seems that a few other assets have been effected by this type of error, too... If all else fails, it's just a bad .png file that can be deleted and everything else will work fine.

Thanks, I'll try this code. I do not know how this Bug is triggered, it may take some time to test.

Developer

Put that code on any gameobject, drag in the files causing the error into the field, click the gear icon in the top-right of the component and select "Fix" from the dropdown menu!

(1 edit)

Hi, I did it according to the method you gave, but this problem still occurred.

Is it because there's some code will set this image to DontSave during runtime? Because if I reopen the project and build it directly, I don't get this bug , but if I run the program, I might get this problem

Developer

This problem has been reported for a while and as far as I can tell, I can't seem to find any code that would change the hideflags of the file whatsoever, so I thought the script to manually change the hideflags would solve it for good... Hm... maybe because the file is an icon to a script, that script could be having a hideflag applied to it and that's passed on to the icon somehow...? I do have some code within STM that changes the hideflags of the meshfilter and meshrenderer components, but I can't see how it's related to the icon... I'll be able to take another close look at this soon, sorry for the delays. But this really is a strange problem that's been bigger than it has any right to be. This is very good information though, if it's something happening just during editor runtime, that narrows down where the problem is.


If you want to test something for me, within the file "SuperTextMesh.cs" there's a method named "HideInspectorStuff". if you remove everything within that method, does the problem still occur? This is the part of the code that sets the meshfilter and meshrenderer hideflags I mentioned. I haven't been able to reproduce the bug in a while so that would be a huge help!

(3 edits)

I tried to remove the code in HideInspectorStuff(), but the bug is still occur.

And I found out how the bug triggers, I don't know if this will help you:

 This problem may caused by inspector. When I open STM's inspector, the image is immediately set to HideFlags.HideAndDontSave.

Then if I use the Fix() method you provided earlier, it will be fixed, and later when I open the inspector, bug will not trigger.

BUT, if any of my code changes and a Unity recompile the code, when I open STM's inspector again, the image will be set to DontSave again.

In summary, bugs are triggered when the STM inspector is first time opened after the  Unity Editor is opened and code is recompiled, which may be related to some initialization event.

I searched all the code about STM, and there is no code related to hideflag except HideInspectorStuff(), but HideInspectorStuff() is not the cause of the problem, so this may be a bug in the Unity Editor?

That's all I know so far, below is the code I used for the test.

using UnityEngine;

[ExecuteAlways]

public class TestCode : MonoBehaviour

{

   [SerializeField] Texture m_texture;

    public void Update()

    {

        if (m_texture.hideFlags == HideFlags.HideAndDontSave) {

            Debug.Log("Error");

        }

    }

    [ContextMenu("Fix")]

    public void Fix()

    {

        m_texture.hideFlags = HideFlags.None;

    }

}

Developer

Hmm, I'd believe it being a Unity bug, because without HideInspectorStuff(), there's no call to HideFlags whatsoever... I may just have to hard-code it so that whenever Unity tries to make a build (onpreprocessbuild?), the Fix() code is called...?


I'll take one more look soon before resorting to that method though, the fact it may be related to an initialization even will help! Thank you so much for your patience and help!!

Developer

Ok, I think I've finally got a proper fix for this. Will be publishing an update shortly! The error seemed to be: I had those icons set as textures used by quads to show certain buttons to press in sample scenes, but as icons assigned to scripts/unity UI elements, that seemed to cause some kind of conflict.

Developer

Ok, I think I've finally got a proper fix for this. Will be publishing an update shortly! The error seemed to be: I had those icons set as textures used by quads to show certain buttons to press in sample scenes, but as icons assigned to scripts/unity UI elements, that seemed to cause some kind of conflict.