Example #1
0
        public override string SaveData()
        {
            Sound sound = GetComponent <Sound>();
            AudioSource audioSource = GetComponent <AudioSource>();

            SoundData soundData = new SoundData();
            soundData.objectID = constantID;
            if (sound.IsFadingOut ())
            {
                soundData.isPlaying = false;
            }
            else
            {
                soundData.isPlaying = sound.IsPlaying ();
            }
            soundData.isLooping = audioSource.loop;
            soundData.samplePoint = audioSource.timeSamples;
            soundData.relativeVolume = sound.relativeVolume;

            if (audioSource.clip != null)
            {
                soundData.clipID = AssetLoader.GetAssetInstanceID (audioSource.clip);
            }

            return Serializer.SaveScriptData <SoundData> (soundData);
        }