Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- namespace AC
- {
- /**
- * This script is attached to GameObject in the scene whose change in Tag we wish to save.
- */
- public class RememberTag : Remember
- {
- /**
- * <summary>Serialises appropriate GameObject values into a string.</summary>
- * <returns>The data, serialised as a string</returns>
- */
- public override string SaveData ()
- {
- TagData tagData = new TagData();
- tagData.objectID = constantID;
- tagData.savePrevented = savePrevented;
- tagData.newTag = gameObject.tag;
- return Serializer.SaveScriptData <TagData> (tagData);
- }
- /**
- * <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)
- {
- TagData data = Serializer.LoadScriptData <TagData> (stringData);
- if (data == null) return;
- SavePrevented = data.savePrevented; if (savePrevented) return;
- gameObject.tag = data.newTag;
- }
- }
- /**
- * A data container used by the RememberTagscript.
- */
- [System.Serializable]
- public class TagData : RememberData
- {
- /** The GameObject's new Tag */
- public string newTag;
- /**
- * The default Constructor.
- */
- public TagData () { }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement