Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Prefabs are no longer saving string property values

Discussion in 'Editor & General Support' started by mortoray, Aug 7, 2023.

  1. mortoray

    mortoray

    Joined:
    Sep 14, 2018
    Posts:
    89
    I'm having a weird issue where a property on a component, in a prefab, is not being fully saved when I exit the prefab.Below I'm showing what I typed with the prefab open...



    ...and below I show what results when I leave the prefab and go back to where it's used (Left arrow in Hierarchy).



    This appears to be happening for any "public string" field now, as I've tried adding new dummy components to test it. It's also happening for string fields that previously worked.

    It always takes a bit of the text, clipping it.

    I've tried adding an OnValidate method to emit the value, and it correctly shows the value that I've edited. I've also tried adding an explicit [SerializeField], but it doesn't change the result.

    I have no idea what could be causing this. I restarted the editor but it did not help.

    ----

    Example of component that fails:

    Code (CSharp):
    1. public class DummyInformation : MonoBehaviour {
    2.     public string text;
    3. }
    4.  
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,557
    That sure sounds mysterious... I would reboot Unity, perhaps reimport all... try a blank project, etc.
     
  3. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    390
    maybe somehow the saving is deferred or something. Does it happen with auto-save (in prefab mode) turned off and manually saving the prefab?
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    Worth telling us what Unity version this is happening on.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,557
    How about the underlying asset data? Is that truncated too? Or is it merely the display that is chopped off?
     
  6. mortoray

    mortoray

    Joined:
    Sep 14, 2018
    Posts:
    89
    Version:
    2022.3.4f1.0.14531
    Revision: 2022.3/staging 35713cd46cd7
    Built: Wed, 21 Jun 2023 17:47:39 GMT
    on Linux

    I tried a new 2D URP Project and created a single prefab and the behaviour persists.

    I tried editing the string, and saving, then closing Unity. Then checking the underlying asset the text is truncated in the saved file.

    I'll try upgrading, assuming there's a newer LTS release.
     
  7. mortoray

    mortoray

    Joined:
    Sep 14, 2018
    Posts:
    89
    I upgraded and the problem persists, in a clean new project. I'm not sure what I should do now, since basically it means I can't modify text in the editor at all. :(

    2022.3.6f1.0.15644
    Revision: 2022.3/staging b9e6e7e9fa2d
    Built: Tue, 25 Jul 2023 15:03:37 GMT
     
  8. mortoray

    mortoray

    Joined:
    Sep 14, 2018
    Posts:
    89
    The problem seems to happen with any field type, not just text. It also applies if I open the prefab directly and edit it. The final changes are not saved. For example, if I edit three fields, the first two will have their full values saved, and the final one will be truncated.

    I've tried disabling auto-save and it appears to work correctly. If I try to exit, and choose to Save, or if I manually click the "Save" button, it saves all of the values. Turning back on auto-save causes the same truncation to happen. I guess I live without auto-save. :(
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820