-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeBundleState.cs
57 lines (48 loc) · 1.86 KB
/
CodeBundleState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace CodeBundle
{
[CreateAssetMenu(menuName = "CodeBundle/Options state", fileName = "CodeBundleOptions")]
public class CodeBundleState : ScriptableObject
{
[Tooltip("Link to the version.json file with information about the current version")]
public string RemoteUrl;
public string MainAssetBundleName => $"{Application.companyName}.{Application.productName}";
public bool DisableWindows;
public bool DisableLinux;
public bool DisableOSX;
public bool DisableAndroid;
public AssetBundleVersionState CurrentRemoteState { get; set; }
public IDictionary<string, AssetBundle> AssetBundles;
public IDictionary<string, AssetBundle> AssetNameToBundle;
private void OnEnable()
{
AssetBundles = new Dictionary<string, AssetBundle>();
AssetNameToBundle = new Dictionary<string, AssetBundle>();
}
/// <summary>
/// Load state asset or just check that argument is not null
/// </summary>
public static CodeBundleState CheckAndLoad(CodeBundleState state)
{
if (state != null)
{
return state;
}
Debug.Log("State asset not set. Try find in resources");
state = Resources.FindObjectsOfTypeAll<CodeBundleState>().FirstOrDefault();
if (state == null)
{
Debug.LogError("State asset asset not found in resources. " +
"Create it from context menu in any Resources folder and configure");
}
else
{
Debug.Log($"State asset found. Use asset with name `{state.name}`");
}
return state;
}
}
}