Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(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;

    }

}

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!!

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.