File tree Expand file tree Collapse file tree 4 files changed +29
-8
lines changed
Assets/JCSUnity/Scripts/SaveLoad Expand file tree Collapse file tree 4 files changed +29
-8
lines changed Original file line number Diff line number Diff line change 88 */
99using System ;
1010using UnityEngine ;
11+ using MyBox ;
1112
1213namespace JCSUnity
1314{
@@ -19,15 +20,28 @@ public abstract class JCS_AppData
1920 {
2021 /* Variables */
2122
22- private bool mInitialized = false ;
23+ [ Separator ( "Runtime Variables (JCS_AppData)" ) ]
2324
25+ [ Tooltip ( "The copyright information." ) ]
2426 public string Copyright = "" ;
27+
28+ [ Tooltip ( "The resource version." ) ]
2529 public string Version = "" ;
26-
30+
31+ [ Tooltip ( "Set to true when the data is initialized." ) ]
32+ [ SerializeField ]
33+ [ ReadOnly ]
34+ private bool mInitialized = false ;
35+
2736 /* Setter & Getter */
2837
2938 /* Functions */
3039
40+ protected JCS_AppData ( )
41+ {
42+ InitFile ( ) ;
43+ }
44+
3145 protected void InitFile ( )
3246 {
3347 var pds = JCS_PackageDataSettings . instance ;
@@ -41,15 +55,16 @@ protected void InitFile()
4155 Copyright = pds . CopyrightString ;
4256 Version = pds . VersionString ;
4357
44- this . mInitialized = true ;
58+ // Set init flag.
59+ mInitialized = true ;
4560 }
4661
4762 /// <summary>
4863 /// Return true if data is initialized.
4964 /// </summary>
50- public bool Initialized ( )
51- {
52- return this . mInitialized ;
65+ public bool Initialized ( )
66+ {
67+ return this . mInitialized ;
5368 }
5469
5570 /// <summary>
Original file line number Diff line number Diff line change 66 * $Notice: See LICENSE.txt for modification and distribution information
77 * Copyright © 2018 by Shen, Jen-Chieh $
88 */
9+ using System ;
910using System . IO ;
1011using System . Runtime . Serialization . Formatters . Binary ;
1112
@@ -14,7 +15,7 @@ namespace JCSUnity
1415 /// <summary>
1516 /// Interface of storing game data as binary format.
1617 /// </summary>
17- [ System . Serializable ]
18+ [ Serializable ]
1819 public abstract class JCS_BinData : JCS_AppData
1920 {
2021 /* Variables */
Original file line number Diff line number Diff line change 66 * $Notice: See LICENSE.txt for modification and distribution information
77 * Copyright © 2019 by Shen, Jen-Chieh $
88 */
9+ using System ;
910using System . IO ;
1011using System . Text ;
1112using Newtonsoft . Json ;
@@ -15,7 +16,7 @@ namespace JCSUnity
1516 /// <summary>
1617 /// Interface to store game data in JSON format.
1718 /// </summary>
18- [ System . Serializable ]
19+ [ Serializable ]
1920 public abstract class JCS_JSONData : JCS_AppData
2021 {
2122 /* Variables */
@@ -93,10 +94,12 @@ public static T LoadFromFile<T>(string fullFilePath)
9394 using ( var stream = new FileStream ( fullFilePath , FileMode . Open ) )
9495 {
9596 string contents = "" ;
97+
9698 using ( var sr = new StreamReader ( stream ) )
9799 {
98100 contents = sr . ReadToEnd ( ) ;
99101 }
102+
100103 return JsonConvert . DeserializeObject < T > ( contents ) ;
101104 }
102105 }
Original file line number Diff line number Diff line change 66 * $Notice: See LICENSE.txt for modification and distribution information
77 * Copyright (c) 2016 by Shen, Jen-Chieh $
88 */
9+ using System ;
910using System . IO ;
1011using System . Xml . Serialization ;
1112
@@ -14,6 +15,7 @@ namespace JCSUnity
1415 /// <summary>
1516 /// Interface of storing game data as XML format.
1617 /// </summary>
18+ [ Serializable ]
1719 public abstract class JCS_XMLData : JCS_AppData
1820 {
1921 /* Variables */
You can’t perform that action at this time.
0 commit comments