Skip to content

Commit 7a17ab3

Browse files
committed
*fix create asset
1 parent 84f6710 commit 7a17ab3

File tree

6 files changed

+18
-24
lines changed

6 files changed

+18
-24
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.9`
7+
for version `1.1.0`
88
```csharp
9-
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#1.0.9",
9+
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#1.1.0",
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ protected virtual void Reset()
142142
[ContextMenu("GetTickerAndPools")]
143143
void GetTickerAndPools()
144144
{
145-
ticker = ScriptableSetting.CreateAndGetScriptableAsset<Ticker>();
146-
pools = ScriptableSetting.CreateAndGetScriptableAsset<Pools>();
145+
ticker = ScriptableSetting.CreateAndGetScriptableAsset<Ticker>("/Core");
146+
pools = ScriptableSetting.CreateAndGetScriptableAsset<Pools>("/Core");
147147
EditorUtility.SetDirty(this);
148148
}
149149
#endif

VirtueSky/Core/BaseSO.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ protected virtual void Reset()
142142
[ContextMenu("GetTickerAndPools")]
143143
void GetTickerAndPools()
144144
{
145-
ticker = ScriptableSetting.CreateAndGetScriptableAsset<Ticker>();
146-
pools = ScriptableSetting.CreateAndGetScriptableAsset<Pools>();
145+
ticker = ScriptableSetting.CreateAndGetScriptableAsset<Ticker>("/Core");
146+
pools = ScriptableSetting.CreateAndGetScriptableAsset<Pools>("/Core");
147147
EditorUtility.SetDirty(this);
148148
}
149149
#endif

VirtueSky/EditorUtils/ScriptableSetting.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.IO;
23
using System.Linq;
34
using UnityEngine;
@@ -8,35 +9,35 @@ namespace VirtueSky.EditorUtils
89
public static class ScriptableSetting
910
{
1011
#if UNITY_EDITOR
11-
public static void CreateSettingAssets<T>() where T : ScriptableObject
12+
public static void CreateSettingAssets<T>(string path = "") where T : ScriptableObject
1213
{
1314
var setting = UnityEngine.ScriptableObject.CreateInstance<T>();
14-
UnityEditor.AssetDatabase.CreateAsset(setting, $"{DefaultResourcesPath()}/{typeof(T).Name}.asset");
15+
UnityEditor.AssetDatabase.CreateAsset(setting, $"{DefaultResourcesPath(path)}/{typeof(T).Name}.asset");
1516
UnityEditor.AssetDatabase.SaveAssets();
1617
UnityEditor.AssetDatabase.Refresh();
1718

18-
Debug.Log($"{typeof(T).Name} was created ad {DefaultResourcesPath()}/{typeof(T).Name}.asset");
19+
Debug.Log($"{typeof(T).Name} was created ad {DefaultResourcesPath(path)}/{typeof(T).Name}.asset");
1920
}
2021
#endif
2122

2223

23-
public static string DefaultResourcesPath()
24+
public static string DefaultResourcesPath(string path = "")
2425
{
2526
const string defaultResourcePath = "Assets/_Root/Resources";
26-
if (!Directory.Exists(defaultResourcePath))
27+
if (!Directory.Exists(defaultResourcePath + path))
2728
{
28-
Directory.CreateDirectory(defaultResourcePath);
29+
Directory.CreateDirectory(defaultResourcePath + path);
2930
}
3031

31-
return defaultResourcePath;
32+
return defaultResourcePath + path;
3233
}
3334

34-
public static T CreateAndGetScriptableAsset<T>() where T : ScriptableObject
35+
public static T CreateAndGetScriptableAsset<T>(string path = "") where T : ScriptableObject
3536
{
3637
var so = AssetUtils.FindAssetAtFolder<T>(new string[] { "Assets" }).FirstOrDefault();
3738
if (so == null)
3839
{
39-
ScriptableSetting.CreateSettingAssets<T>();
40+
ScriptableSetting.CreateSettingAssets<T>(path);
4041
so = AssetUtils.FindAssetAtFolder<T>(new string[] { "Assets" }).FirstOrDefault();
4142
}
4243

VirtueSky/Misc/ButtonCustom.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,7 @@ void ResetScale()
6767
protected override void Reset()
6868
{
6969
base.Reset();
70-
clickButtonEvent = AssetUtils.FindAssetAtFolder<ClickButtonEvent>(new string[] { "Assets" })
71-
.FirstOrDefault();
72-
if (clickButtonEvent == null)
73-
{
74-
ScriptableSetting.CreateSettingAssets<ClickButtonEvent>();
75-
clickButtonEvent = AssetUtils.FindAssetAtFolder<ClickButtonEvent>(new string[] { "Assets" })
76-
.FirstOrDefault();
77-
}
70+
clickButtonEvent = ScriptableSetting.CreateAndGetScriptableAsset<ClickButtonEvent>("/Event");
7871
}
7972
#endif
8073
}

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.9",
5+
"version": "1.1.0",
66
"unity": "2021.3",
77
"category": "virtuesky",
88
"keywords": [

0 commit comments

Comments
 (0)