You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.2 KiB
60 lines
2.2 KiB
using UnityEngine; |
|
|
|
namespace ET |
|
{ |
|
public static class YooAssetHelper |
|
{ |
|
public static async ETTask<GameObject> InstantiateAsync(this Entity self, string location, Transform parent_transform = null, bool stay_world_space = false) |
|
{ |
|
var autoResLoaderComp = self.GetComponent<AutoResLoaderComponent>(); |
|
if ( autoResLoaderComp == null) |
|
{ |
|
autoResLoaderComp = self.AddComponent<AutoResLoaderComponent>(); |
|
} |
|
|
|
var go = await autoResLoaderComp.InstantiateAsync(location, parent_transform, stay_world_space); |
|
return go; |
|
} |
|
|
|
public static GameObject InstantiateSync(this Entity self, string location, Transform parent_transform = null, bool stay_world_space = false) |
|
{ |
|
var autoResLoaderComp = self.GetComponent<AutoResLoaderComponent>(); |
|
if ( autoResLoaderComp == null) |
|
{ |
|
autoResLoaderComp = self.AddComponent<AutoResLoaderComponent>(); |
|
} |
|
|
|
var go = autoResLoaderComp.InstantiateSync(location, parent_transform, stay_world_space); |
|
return go; |
|
} |
|
|
|
public static async ETTask<T> LoadAssetAsync<T>(this Entity self, string location) where T : UnityEngine.Object |
|
{ |
|
var autoResLoaderComp = self.GetComponent<AutoResLoaderComponent>(); |
|
if ( autoResLoaderComp == null) |
|
{ |
|
autoResLoaderComp = self.AddComponent<AutoResLoaderComponent>(); |
|
} |
|
|
|
var obj = await autoResLoaderComp.LoadAssetAsync<T>(location); |
|
return obj; |
|
} |
|
|
|
public static T LoadAssetSync<T>(this Entity self, string location) where T : UnityEngine.Object |
|
{ |
|
var autoResLoaderComp = self.GetComponent<AutoResLoaderComponent>(); |
|
if ( autoResLoaderComp == null) |
|
{ |
|
autoResLoaderComp = self.AddComponent<AutoResLoaderComponent>(); |
|
} |
|
|
|
var obj = autoResLoaderComp.LoadAssetSync<T>(location); |
|
return obj; |
|
} |
|
|
|
public static string ToPrefabAddress(this string self) |
|
{ |
|
return "Prefab_" + self; |
|
} |
|
} |
|
} |