Skip to content

Commit 84f6710

Browse files
committed
fix scriptable setting
1 parent e2c0f5c commit 84f6710

File tree

6 files changed

+23
-33
lines changed

6 files changed

+23
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
### Add the lines below to `Packages/manifest.json`
66

7-
for version `1.0.8`
7+
for version `1.0.9`
88
```csharp
9-
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#1.0.8",
9+
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#1.0.9",
1010
```
1111

1212
- If you are missing some of the libraries used in the package, you can download them [here](https://drive.google.com/drive/folders/1OdT5EfMDfkQsEleMM6C2-HHav9o0neTS)

VirtueSky/Core/BaseMono.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,8 @@ protected virtual void Reset()
142142
[ContextMenu("GetTickerAndPools")]
143143
void GetTickerAndPools()
144144
{
145-
ticker = AssetUtils.FindAssetAtFolder<Ticker>(new string[] { "Assets" }).FirstOrDefault();
146-
if (ticker == null)
147-
{
148-
ScriptableSetting.CreateSettingAssets<Ticker>();
149-
ticker = AssetUtils.FindAssetAtFolder<Ticker>(new string[] { "Assets" }).FirstOrDefault();
150-
}
151-
152-
pools = AssetUtils.FindAssetAtFolder<Pools>(new string[] { "Assets" }).FirstOrDefault();
153-
if (pools == null)
154-
{
155-
ScriptableSetting.CreateSettingAssets<Pools>();
156-
pools = AssetUtils.FindAssetAtFolder<Pools>(new string[] { "Assets" }).FirstOrDefault();
157-
}
158-
145+
ticker = ScriptableSetting.CreateAndGetScriptableAsset<Ticker>();
146+
pools = ScriptableSetting.CreateAndGetScriptableAsset<Pools>();
159147
EditorUtility.SetDirty(this);
160148
}
161149
#endif

VirtueSky/Core/BaseSO.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,8 @@ protected virtual void Reset()
142142
[ContextMenu("GetTickerAndPools")]
143143
void GetTickerAndPools()
144144
{
145-
ticker = AssetUtils.FindAssetAtFolder<Ticker>(new string[] { "Assets" }).FirstOrDefault();
146-
if (ticker == null)
147-
{
148-
ScriptableSetting.CreateSettingAssets<Ticker>();
149-
ticker = AssetUtils.FindAssetAtFolder<Ticker>(new string[] { "Assets" }).FirstOrDefault();
150-
}
151-
152-
pools = AssetUtils.FindAssetAtFolder<Pools>(new string[] { "Assets" }).FirstOrDefault();
153-
if (pools == null)
154-
{
155-
ScriptableSetting.CreateSettingAssets<Pools>();
156-
pools = AssetUtils.FindAssetAtFolder<Pools>(new string[] { "Assets" }).FirstOrDefault();
157-
}
158-
145+
ticker = ScriptableSetting.CreateAndGetScriptableAsset<Ticker>();
146+
pools = ScriptableSetting.CreateAndGetScriptableAsset<Pools>();
159147
EditorUtility.SetDirty(this);
160148
}
161149
#endif

VirtueSky/EditorControl/WindowControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace VirtueSky.EditorControl
77
#if UNITY_EDITOR
88
public class WindowControl : EditorWindow
99
{
10-
[MenuItem("DataControl/Clear Data %F1")]
10+
[MenuItem("GameControl/Clear Data %F1")]
1111
public static void ClearAllData()
1212
{
1313
GameData.DelDataInStorage();
@@ -16,7 +16,7 @@ public static void ClearAllData()
1616
Debug.Log($"<color=Green>Clear data succeed</color>");
1717
}
1818

19-
[MenuItem("DataControl/Save Data %F2")]
19+
[MenuItem("GameControl/Save Data %F2")]
2020
public static void SaveData()
2121
{
2222
GameData.Save();

VirtueSky/EditorUtils/ScriptableSetting.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.IO;
2+
using System.Linq;
23
using UnityEngine;
4+
using VirtueSky.Utils;
35

46
namespace VirtueSky.EditorUtils
57
{
@@ -28,5 +30,17 @@ public static string DefaultResourcesPath()
2830

2931
return defaultResourcePath;
3032
}
33+
34+
public static T CreateAndGetScriptableAsset<T>() where T : ScriptableObject
35+
{
36+
var so = AssetUtils.FindAssetAtFolder<T>(new string[] { "Assets" }).FirstOrDefault();
37+
if (so == null)
38+
{
39+
ScriptableSetting.CreateSettingAssets<T>();
40+
so = AssetUtils.FindAssetAtFolder<T>(new string[] { "Assets" }).FirstOrDefault();
41+
}
42+
43+
return so;
44+
}
3145
}
3246
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.virtuesky.sunflower",
33
"displayName": "Sunflower",
44
"description": "Core ScriptableObject Architecture for building Unity games",
5-
"version": "1.0.8",
5+
"version": "1.0.9",
66
"unity": "2021.3",
77
"category": "virtuesky",
88
"keywords": [

0 commit comments

Comments
 (0)