[Unity C#] Serializable Class

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class CS_AudioClip {
    public AudioClip[] myAudioClips;
    public float myVolum = 1;
    public float myPitchDifference = 0;

    public AudioClip GetMyAudioClip () {
        if (myAudioClips.Length <= 0)
            return null;
        return myAudioClips [Random.Range (0, myAudioClips.Length)];
    }

    public float GetMyPitch () {
        return (1 + myPitchDifference * Random.Range (0, 1.0f));
    }
}

to use this class in other scripts:

public CS_AudioClip myMoveSFX;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s