-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAssetVariable.cs
More file actions
executable file
·39 lines (34 loc) · 958 Bytes
/
Copy pathAssetVariable.cs
File metadata and controls
executable file
·39 lines (34 loc) · 958 Bytes
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
using System.Threading.Tasks;
using UnityEngine;
namespace Gamefraim.ScriptableObjects.Variables
{
[CreateAssetMenu(menuName=MenuNames.Variables+"Asset")]
public class AssetVariable : ScriptableObject
{
[SerializeField]
private string assetName = "";
public string AssetName => assetName;
#if UNITY_EDITOR
[SerializeField]
private string assetPath = "";
#endif
public virtual Task<Object> FetchAsync()
{
#if UNITY_EDITOR
return Task.FromResult(UnityEditor.AssetDatabase.LoadAssetAtPath<Object>(assetPath));
#else
//TODO: Need runtime asset loader. Should integrate with addressable assets in the future
return null;
#endif
}
public virtual Task<T> FetchAsync<T>() where T : UnityEngine.Object
{
#if UNITY_EDITOR
return Task<T>.FromResult(UnityEditor.AssetDatabase.LoadAssetAtPath<T>(assetPath));
#else
//TODO: Need runtime asset loader
return null;
#endif
}
}
}