Skip to content

Commit 97bac15

Browse files
committed
feat: Modernize settings
1 parent 48c2d7f commit 97bac15

33 files changed

+7684
-5265
lines changed

Assets/JCSUnity/Resources/JCS_Managers.prefab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ MonoBehaviour:
143143
m_Script: {fileID: 11500000, guid: 4bbeb25e792087645b19e4cf30c3218a, type: 3}
144144
m_Name:
145145
m_EditorClassIdentifier:
146-
mGameDoneInitialize: 0
146+
mDoneInitialize: 0
147147
--- !u!114 &11439248
148148
MonoBehaviour:
149149
m_ObjectHideFlags: 0
@@ -162,7 +162,7 @@ MonoBehaviour:
162162
mAlign: 0
163163
mPopWhiteScreen: 1
164164
mWhiteScreen: {fileID: 0}
165-
mSwitchSceneType: 1
165+
mSwitchSceneType: 2
166166
mOverrideSetting: 0
167167
mSceneFadeInTime: 1
168168
mSceneFadeOutTime: 1

Assets/JCSUnity/Scripts/Interfaces/JCS_Cursor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public abstract class JCS_Cursor : JCS_Settings<JCS_Cursor>
3232

3333
protected virtual void Awake()
3434
{
35-
instance = CheckInstance(instance, this);
35+
CheckInstance(this);
3636

3737
#if UNITY_EDITOR
3838
mShowCursor = true;

Assets/JCSUnity/Scripts/Interfaces/JCS_Instance.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public abstract class JCS_InstanceOld<T> : JCS_Instance<T>
4444
/// <param name="destroyGO">
4545
/// If true, destory the entire game object instead of just the component.
4646
/// </param>
47-
protected void CheckInstance(T _new, bool destroyGO = false)
47+
protected virtual void CheckInstance(T _new, bool destroyGO = false)
4848
{
4949
if (instance != null)
5050
{
@@ -97,7 +97,7 @@ public abstract class JCS_InstanceNew<T> : JCS_Instance<T>
9797
/// <param name="destroyGO">
9898
/// If true, destory the entire game object instead of just the component.
9999
/// </param>
100-
protected void CheckInstance(T _new, bool destroyGO = false)
100+
protected virtual void CheckInstance(T _new, bool destroyGO = false)
101101
{
102102
if (instance != null)
103103
{

Assets/JCSUnity/Scripts/Interfaces/JCS_Settings.cs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Assets/JCSUnity/Scripts/Network/JCS_PacketLostPreventer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class JCS_PacketLostPreventer : JCS_Settings<JCS_PacketLostPreventer>
5050

5151
private void Awake()
5252
{
53-
instance = CheckInstance(instance, this);
53+
CheckInstance(this);
5454
}
5555

5656
private void LateUpdate()

Assets/JCSUnity/Scripts/Network/JCS_ServerRequestProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class JCS_ServerRequestProcessor
3030

3131
private void Awake()
3232
{
33-
instance = CheckInstance(instance, this);
33+
CheckInstance(this);
3434
}
3535

3636
private void Update()

Assets/JCSUnity/Scripts/Settings/JCS_AppSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class JCS_AppSettings : JCS_Settings<JCS_AppSettings>
6262

6363
private void Awake()
6464
{
65-
instance = CheckInstance(instance, this);
65+
CheckInstance(this);
6666

6767
if (SET_FRAME_RATE)
6868
Application.targetFrameRate = FRAME_RATE;

Assets/JCSUnity/Scripts/Settings/JCS_GameSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class JCS_GameSettings : JCS_Settings<JCS_GameSettings>
118118

119119
private void Awake()
120120
{
121-
instance = CheckInstance(instance, this);
121+
CheckInstance(this);
122122

123123
REAL_DATA_PATH = JCS_AppData.SavePath();
124124
REAL_SCREENSHOT_PATH = JCS_Camera.SavePath();

Assets/JCSUnity/Scripts/Settings/JCS_InputSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public JoystickMap GetJoysitckMapByIndex(int index)
206206

207207
private void Awake()
208208
{
209-
instance = CheckInstance(instance, this);
209+
CheckInstance(this);
210210
}
211211

212212
private void LateUpdate()

Assets/JCSUnity/Scripts/Settings/JCS_NetworkSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class JCS_NetworkSettings : JCS_Settings<JCS_NetworkSettings>
6868

6969
private void Awake()
7070
{
71-
instance = CheckInstance(instance, this);
71+
CheckInstance(this);
7272

7373
this.mServerRequestProcessor = this.GetComponent<JCS_ServerRequestProcessor>();
7474
this.mPacketLostPreventer = this.GetComponent<JCS_PacketLostPreventer>();

0 commit comments

Comments
 (0)