Skip to content

Commit 8958abb

Browse files
authored
Merge pull request #33 from brunomikoski/feature/fix-aot-issue-again
Feature/fix aot issue again
2 parents 7f24966 + 054975e commit 8958abb

5 files changed

Lines changed: 16 additions & 11 deletions

File tree

CHANGELOG.MD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.2.6]
8+
## Changed
9+
- Fixed AOT issue.
10+
711
## [1.2.5]
812
## Changed
913
- Fixed issue with the read only lists not refreshing properly on Inspector calls on PlayMode.
@@ -129,6 +133,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
129133
## [Unreleased]
130134
- Proper setup for automatic creation of necessary collections
131135

136+
[1.2.6]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.6
132137
[1.2.5]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.5
133138
[1.2.4]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.4
134139
[1.2.3]: https://github.com/badawe/ScriptableObjectCollection/releases/tag/v1.2.3

Scripts/Editor/Utils/CollectionUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private static void CreateNewItem()
2727
[MenuItem("Assets/Create/ScriptableObject Collection/Create Settings", false, 200)]
2828
private static void CreateSettings()
2929
{
30-
ScriptableObjectCollectionSettings.LoadOrCreateInstance();
30+
ScriptableObjectCollectionSettings.LoadOrCreateInstance<ScriptableObjectCollection>();
3131
}
3232

3333
public static Editor GetEditorForItem(CollectableScriptableObject collectionItem)

Scripts/Runtime/CollectionsRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class CollectionsRegistry : ResourceScriptableObjectSingleton<Collections
1515

1616
public void UsedOnlyForAOTCodeGeneration()
1717
{
18-
LoadOrCreateInstance();
18+
LoadOrCreateInstance<CollectionsRegistry>();
1919
// Include an exception so we can be sure to know if this method is ever called.
2020
throw new InvalidOperationException("This method is used for AOT code generation only. Do not call it at runtime.");
2121
}

Scripts/Runtime/ResourceScriptableObjectSingleton.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ public static T Instance
1111
get
1212
{
1313
if (instance == null)
14-
instance = LoadOrCreateInstance();
14+
instance = LoadOrCreateInstance<T>();
1515
return instance;
1616
}
1717
}
1818

1919
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
20-
public static T LoadOrCreateInstance()
20+
public static T2 LoadOrCreateInstance<T2>() where T2 : ScriptableObject
2121
{
22-
T newInstance = Resources.Load<T>(typeof(T).Name);
22+
T2 newInstance = Resources.Load<T2>(typeof(T2).Name);
2323

2424
if (newInstance != null)
2525
return newInstance;
@@ -28,22 +28,22 @@ public static T LoadOrCreateInstance()
2828
if (Application.isPlaying)
2929
return null;
3030

31-
string registryGUID = UnityEditor.AssetDatabase.FindAssets($"t:{typeof(T).Name}")
31+
string registryGUID = UnityEditor.AssetDatabase.FindAssets($"t:{typeof(T2).Name}")
3232
.FirstOrDefault();
3333

3434
if (!string.IsNullOrEmpty(registryGUID))
3535
{
36-
newInstance = (T) UnityEditor.AssetDatabase.LoadAssetAtPath<ScriptableObject>(
36+
newInstance = (T2) UnityEditor.AssetDatabase.LoadAssetAtPath<ScriptableObject>(
3737
UnityEditor.AssetDatabase.GUIDToAssetPath(registryGUID));
3838
}
3939

4040
if (newInstance != null)
41-
return newInstance;
41+
return newInstance ;
4242

43-
newInstance = CreateInstance<T>();
43+
newInstance = CreateInstance<T2>();
4444

4545
AssetDatabaseUtils.CreatePathIfDontExist("Assets/Resources");
46-
UnityEditor.AssetDatabase.CreateAsset(newInstance, $"Assets/Resources/{typeof(T).Name}.asset");
46+
UnityEditor.AssetDatabase.CreateAsset(newInstance, $"Assets/Resources/{typeof(T2).Name}.asset");
4747
UnityEditor.AssetDatabase.SaveAssets();
4848
UnityEditor.AssetDatabase.Refresh();
4949
return newInstance;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.brunomikoski.scriptableobjectcollection",
33
"displayName": "Scriptable Object Collection",
4-
"version": "1.2.5",
4+
"version": "1.2.6",
55
"unity": "2018.4",
66
"description": "Scriptable Object Collection",
77
"keywords": [

0 commit comments

Comments
 (0)