예제 #1
0
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public override void LoadData(string stringData)
        {
            FootstepSoundData data = Serializer.LoadScriptData <FootstepSoundData> (stringData);

            if (data == null)
            {
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            if (GetComponent <FootstepSounds>())
            {
                FootstepSounds footstepSounds = GetComponent <FootstepSounds>();

                AudioClip[] walkSounds = StringToSounds(data.walkSounds);
                if (walkSounds != null && walkSounds.Length > 0)
                {
                    footstepSounds.footstepSounds = walkSounds;
                }

                AudioClip[] runSounds = StringToSounds(data.runSounds);
                if (runSounds != null && runSounds.Length > 0)
                {
                    footstepSounds.runSounds = runSounds;
                }
            }
        }
예제 #2
0
        /**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        public override string SaveData()
        {
            FootstepSoundData footstepSoundData = new FootstepSoundData();

            footstepSoundData.objectID      = constantID;
            footstepSoundData.savePrevented = savePrevented;

            if (GetComponent <FootstepSounds>())
            {
                FootstepSounds footstepSounds = GetComponent <FootstepSounds>();
                footstepSoundData.walkSounds = SoundsToString(footstepSounds.footstepSounds);
                footstepSoundData.runSounds  = SoundsToString(footstepSounds.runSounds);
            }

            return(Serializer.SaveScriptData <FootstepSoundData> (footstepSoundData));
        }