Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Edit array elements properties in editor

So…

I was watching some old unity tutorial videos and saw people editing properties of the elements of an array in editor like this:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When I tried in my project the editor does not showed the properties, just show a place to select an already created element:

enter image description here

Why the "Clip", "Volume" and "Name" properties are missing when I do it in my project?

My classes:

using UnityEngine;

public class AudioManager : MonoBehaviour
{
    [SerializeField]
    public Sound[] Sounds;
}
[System.Serializable]
public class Sound : MonoBehaviour
{
    public AudioClip Clip;

    public string Name;

    [Range(0f, 1f)]
    public float Volume;

    [Range(.1f, 3f)]
    public float Pitch;
}

I’m using Unity 2021.3.5f1

>Solution :

The problem is that your Sound class inherits from Object (MonoBehaviour), and Object are always serialized as reference. Make your Sound not inherit MonoBehaviour and it should look like in example (except that you have newer version of unity with reorderable list drawer)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading