예제 #1
0
        /**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        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));
        }