GameToolkit-Localization icon indicating copy to clipboard operation
GameToolkit-Localization copied to clipboard

Prefabs dirtied on opening

Open iMobCoding opened this issue 1 month ago • 5 comments

Recently I noticed that upon opening prefabs that have GameObjects with LocalizedTextBehaviours, the whole prefab gets dirty requiring me to save it again and again without even changing anything. And no actual change is made upon saving.

Analyzed the Localization package and specifically LocalizedGenericAssetBehaviourBase.cs. If I make this change:

#if UNITY_EDITOR
                // if (!Application.isPlaying) <-- Remove
                if (!Application.isPlaying && m_Component && m_Component.gameObject && m_Component.gameObject.scene.isLoaded) // <-- Add
                {
                    UnityEditor.Undo.RecordObject(m_Component, "Locale value change");
                }
#endif

Then only objects in the scene will be subject to Undo.RecordObject() and my prefabs aren't dirtied anymore without the reason. Not sure this is the good solution, because my scenes also get dirtied when I make any script change without a reason.

So please, can you take a look and make some more robust re-factorings regarding the Undo system so Unity scenes/prefabs don't get dirtied (and requiring saving without any changes) whenever we make some script changes and trigger the re-compiling?

Just to mention, I am on Unity 6.2.8, the latest Localization and my Enter Play Mode Settings are Reload Scene only

iMobCoding avatar Oct 22 '25 14:10 iMobCoding