Create parameters on audioSource

Hello, I have a question … I want to implement a sound system.
the idea is to make a menu in the inspector that contains a list of creatable sounds (AudioClip sample).
to write “1” will create a menu to insert an audio and under, has a parameter “float”.

someone to guide me?

My best answer would be to create a simple serializable class, with 2 public variables to hold the information you wish it to handle:

using UnityEngine;
using System.Collections;
using System; // <-- This is key here, allows you to use the [Serializable] above a class.

[Serializable]
public class MyAudioThingy
{
    public AudioClip clip;
    public float sampleFloat;
}

And then in your AudioHandler class, or what you wish to call it you can do as so:

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour
{
    // This can be seen in the inspector
    public MyAudioThingy[] sample;

    void Start()
    {

    }

    void Update()
    {

    }
}

Hope it helps! :slight_smile:

Okay, you can use the ‘Serializable’ attribute to allow visibility of class properties within the Inspector. Simply create a class within the scope of your MonoBehaviour and give it the Serializable attribute to allow visibility within the Inspector. Then create a public instance of the class and fill out the data inside of the Inspector.

Here is a very basic script as an example.

public class AudioSetup : MonoBehaviour 
{
    [Serializable]
    public class AudioData
    {
        public AudioClip AudioClip;
        public float FloatValue;
    }

    // You can create a single instance of the class.
    public AudioData SingleInstance;

    // You can also maintain a list of instances and store different data for each.
    public List<AudioData> ListOfInstances; 

    // Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}