@@ -117,33 +117,57 @@ static void CreateConfigFile()
117
117
[ InitializeOnLoadMethod ]
118
118
static void StoreSDKVersion ( )
119
119
{
120
+ if ( ( ! string . IsNullOrEmpty ( LootLockerConfig . current . sdk_version ) &&
121
+ ! LootLockerConfig . current . sdk_version . Equals ( "N/A" ) ) || ListInstalledPackagesRequest != null )
122
+ {
123
+ return ;
124
+ }
120
125
ListInstalledPackagesRequest = Client . List ( ) ;
121
- EditorApplication . update += ListRequestProgress ;
126
+ EditorApplication . update += ListInstalledPackagesRequestProgress ;
122
127
}
123
128
129
+ [ Serializable ]
124
130
private class LLPackageDescription
125
131
{
126
- public string version ;
132
+ public string name { get ; set ; }
133
+ public string version { get ; set ; }
127
134
}
128
135
129
- static void ListRequestProgress ( )
136
+ static void ListInstalledPackagesRequestProgress ( )
130
137
{
131
138
if ( ListInstalledPackagesRequest . IsCompleted )
132
139
{
133
- EditorApplication . update -= ListRequestProgress ;
140
+ EditorApplication . update -= ListInstalledPackagesRequestProgress ;
134
141
foreach ( var package in ListInstalledPackagesRequest . Result )
135
142
{
136
143
if ( package . name . Equals ( "com.lootlocker.lootlockersdk" ) )
137
144
{
138
145
LootLockerConfig . current . sdk_version = package . version ;
139
- break ;
146
+ return ;
140
147
}
141
148
}
142
149
143
- if ( string . IsNullOrEmpty ( LootLockerConfig . current . sdk_version ) )
150
+ if ( File . Exists ( "Assets/LootLockerSDK/package.json" ) )
144
151
{
145
152
LootLockerConfig . current . sdk_version = LootLockerJson . DeserializeObject < LLPackageDescription > ( File . ReadAllText ( "Assets/LootLockerSDK/package.json" ) ) . version ;
153
+ return ;
154
+ }
155
+
156
+
157
+ foreach ( var assetPath in AssetDatabase . GetAllAssetPaths ( ) )
158
+ {
159
+ if ( assetPath . EndsWith ( "package.json" ) )
160
+ {
161
+ var packageDescription = LootLockerJson . DeserializeObject < LLPackageDescription > ( File . ReadAllText ( assetPath ) ) ;
162
+ if ( ! string . IsNullOrEmpty ( packageDescription . name ) && packageDescription . name . Equals ( "com.lootlocker.lootlockersdk" ) )
163
+ {
164
+ LootLockerConfig . current . sdk_version = packageDescription . version ;
165
+ return ;
166
+ }
167
+ }
146
168
}
169
+
170
+ LootLockerConfig . current . sdk_version = "N/A" ;
147
171
}
148
172
}
149
173
#endif
0 commit comments