Skip to content

Commit 84faf4b

Browse files
authored
Add missing methods for MonoSingleton.cs
1 parent e902a9f commit 84faf4b

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

Assets/Scripts/MonoSingleton.cs

+33-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,39 @@ protected virtual void Awake ()
7171
}
7272
}
7373
}
74+
75+
public static void CreateInstance()
76+
{
77+
DestroyInstance();
78+
instance = Instance;
79+
}
80+
81+
public static void DestroyInstance()
82+
{
83+
if (instance == null) return;
84+
85+
instance.Clear();
86+
instance = default(T);
87+
}
88+
89+
protected void Init()
90+
{
91+
OnInit();
92+
}
93+
94+
public void Clear()
95+
{
96+
OnClear();
97+
}
98+
99+
protected virtual void OnInit()
100+
{
101+
}
102+
103+
protected virtual void OnClear()
104+
{
105+
}
74106

75107
#endregion
76108

77-
}
109+
}

0 commit comments

Comments
 (0)