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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Official SerializeReference improvements in Unity 2021 LTS

Discussion in 'Scripting' started by Unity_Joseph, Jun 30, 2022.

  1. yu_yang

    yu_yang

    Joined:
    May 3, 2015
    Posts:
    53
    oscarAbraham and spiney199 like this.
  2. MartinBarrette

    MartinBarrette

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    26
    The MovedFrom bug https://issuetracker.unity3d.com/issues/movedfrom-attribute-doesnt-work-on-prefab-overrides is actively being worked on currently and hopefully will be resolved in the coming days.

    @yu-yang reported bug: https://issuetracker.unity3d.com/is...working-incorrectly-when-using-prefab-variant is fixed and in the process of being integrated/backported. (Sorry did not see yu-yang, post above when I was replying to you Oscar).
    Hope this helps.
     
    oscarAbraham likes this.
  3. yu_yang

    yu_yang

    Joined:
    May 3, 2015
    Posts:
    53
    How to change SerializeReference object type without managed id changing?

    Code (CSharp):
    1.     class MyMonoBehaviour : MonoBehaviour
    2.     {
    3.         [SerializeReference]
    4.         object myObject;
    5.         [SerializeReference]
    6.         object referenceToMyObject;
    7.     }
    If I change myObject to a new value with different type, referenceToMyObject will lose reference to myObject because the new value of myObject has a different managed id. Is there a way to keep managed id when I change SerializeReference object type?
     
  4. Thomas-Bousquet

    Thomas-Bousquet

    Joined:
    Dec 19, 2016
    Posts:
    28
    Is there a plan to update the UX for SerializeReference in the editor ?

    All the examples from the articles are assigning values from code, but a major use case is for these values to be input in the editor using the inspector.

    However, at this point, if one declares field/array to be set by editor users, they just get empty field, with no control to create an object of a compatible type; even when using the + button.
    upload_2022-11-30_15-35-40.png

    There are a few packages out there that offer attributes to change that ([1] and [2]); but it really feels this should be done natively; since:
    1. without the extension, SerializeReference are unusable by data creators out of the box.
    2. packages can't easily (at all?) customize the +/- of the Collection UI using attributes.