@@ -13,7 +13,7 @@ namespace JCSUnity
1313 /// <summary>
1414 /// Interface of all setting class.
1515 /// </summary>
16- public abstract class JCS_Settings < T > : JCS_Instance < T >
16+ public abstract class JCS_Settings < T > : JCS_InstanceNew < T >
1717 where T : MonoBehaviour
1818 {
1919 /* Variables */
@@ -23,34 +23,12 @@ public abstract class JCS_Settings<T> : JCS_Instance<T>
2323 /* Functions */
2424
2525 /// <summary>
26- /// Force the setting object singleton .
26+ /// Check singleton for keep the new one .
2727 /// </summary>
28- /// <param name="_old"> old instance. </param>
29- /// <param name="_new"> new instance. </param>
30- protected T CheckInstance ( T _old , T _new )
28+ /// <param name="_new"> new instance </param>
29+ protected virtual void CheckInstance ( T _new )
3130 {
32- if ( _old != null )
33- {
34- TransferData ( _old , _new ) ;
35-
36- // Delete the old one
37- Destroy ( _old . gameObject ) ;
38- }
39-
40- return _new ;
31+ base . CheckInstance ( _new , true ) ;
4132 }
42-
43- /// <summary>
44- /// Instead of Unity Engine's scripting layer's DontDestroyOnLoad.
45- /// I would like to use own define to transfer the old instance
46- /// to the newer instance.
47- ///
48- /// Every time when unity load the scene. The script have been
49- /// reset, in order not to lose the original setting.
50- /// transfer the data from old instance to new instance.
51- /// </summary>
52- /// <param name="_old"> old instance </param>
53- /// <param name="_new"> new instance </param>
54- protected abstract void TransferData ( T _old , T _new ) ;
5533 }
5634}
0 commit comments