Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Feature Request: Nice Auto Property Names

Discussion in 'Editor Workflows' started by erineccleston, Mar 22, 2019.

  1. erineccleston

    erineccleston

    Joined:
    May 26, 2017
    Posts:
    1
    Now that serialization of an auto property's backing field is supported with the [field: SerializeField] syntax, it would be nice for the variable name nicifier to convert the ugly <PropertyName>k__BackingField that's currently displayed in the inspector into PropertyName.

    I've also included a file with a workaround for anyone that currently needs it.
     

    Attached Files:

  2. DarkNBlood

    DarkNBlood

    Joined:
    Jun 19, 2014
    Posts:
    28
  3. ErnestSurys

    ErnestSurys

    Joined:
    Jan 18, 2018
    Posts:
    94
    We need this, I also wrote similar classes to make this work.
    Making properties with private write access is a good practice.

    Code (csharp):
    1. [field: SerializeField]
    2. public SomePrefab { get; private set; }
    This shouldn't be discouraged because of ugly editor representation.
     
  4. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    358
    The new label should be nicified once more time.

    Code (CSharp):
    1. label.text = ObjectNames.NicifyVariableName(label.text.Split(new[] { '<', '>' }, System.StringSplitOptions.RemoveEmptyEntries)[0]);
     
  5. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    What they actually need to support here is proper auto property serialization, not this attribute workaround. An ideal implementation from a user perspective would be: It meets the Unity serialization rules, it gets serialized. No attribute necessary, and interface support.
     
    joshcamas likes this.
  6. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
  7. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    I'll add that, for me, the "nicifier" is completely useless because I don't really care about the ugly name, as I can make it out just fine, and it only changes what's displayed in the inspector, not the serialized name. There's no way to change the serialized name of anything, as far as I know. It's tied to the variable name.
     
    Last edited: Dec 3, 2019