Bug: Changes to "Content Update Restriction" in Editor GUI aren't being serialized

When I use the Editor GUI to change a “Content Update Restriction” those changes aren’t saved to disk, even after clicking “Save Project.”

5255378--525251--Screen Shot 2019-12-06 at 4.20.17 PM.png

        [SerializeField]
        bool m_StaticContent;
        /// <summary>
        /// Is the group static.  This property is used in determining which assets need to be moved to a new remote group during the content update process.
        /// </summary>
        public bool StaticContent
        {
            get { return m_StaticContent; }
            set
            {
                m_StaticContent = value;
                SetDirty(true);
            }
        }

        /// <inheritdoc/>
        public override void OnGUI()
        {
            ContentType current = m_StaticContent ? ContentType.CannotChangePostRelease : ContentType.CanChangePostRelease;
            var newType = (ContentType)EditorGUILayout.EnumPopup("Update Restriction", current);
            if (newType != current)
                m_StaticContent = newType == ContentType.CannotChangePostRelease;
        }

The code overrides OnGUI() and only updates the local field m_StaticContent.

If I change the code instead to set the public property which sets the local field and sets this object to be dirty, then it works:

            if (newType != current)
                StaticContent = newType == ContentType.CannotChangePostRelease;

Ah yeah, you’re right. Thanks for pointing it out and providing a potential solution!

1 Like