Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. namespace AC
  5. {
  6.  
  7. /**
  8. * This script is attached to GameObject in the scene whose change in Tag we wish to save.
  9. */
  10.  
  11. public class RememberTag : Remember
  12. {
  13.  
  14. /**
  15. * <summary>Serialises appropriate GameObject values into a string.</summary>
  16. * <returns>The data, serialised as a string</returns>
  17. */
  18. public override string SaveData ()
  19. {
  20. TagData tagData = new TagData();
  21. tagData.objectID = constantID;
  22.             tagData.savePrevented = savePrevented;
  23.  
  24.             tagData.newTag = gameObject.tag;
  25.            
  26.  
  27. return Serializer.SaveScriptData <TagData> (tagData);
  28. }
  29.  
  30.  
  31. /**
  32. * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
  33. * <param name = "stringData">The data, serialised as a string</param>
  34. */
  35. public override void LoadData (string stringData)
  36. {
  37. TagData data = Serializer.LoadScriptData <TagData> (stringData);
  38. if (data == null) return;
  39. SavePrevented = data.savePrevented; if (savePrevented) return;
  40.  
  41. gameObject.tag = data.newTag;
  42. }
  43.  
  44. }
  45.  
  46.  
  47. /**
  48. * A data container used by the RememberTagscript.
  49. */
  50. [System.Serializable]
  51. public class TagData : RememberData
  52. {
  53.  
  54. /** The GameObject's new Tag */
  55. public string newTag;
  56.  
  57. /**
  58. * The default Constructor.
  59. */
  60. public TagData () { }
  61.  
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement