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.

71 lines
2.6 KiB

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using YooAsset;
using UnityObject = UnityEngine.Object;
namespace ET
{
[ComponentOf(typeof(Scene))]
public class YooAssetComponent: Entity, IAwake
{
public static YooAssetComponent Instance { get; set; }
public Dictionary<int, List<GameObject>> AutoLoaderGameObjects = new Dictionary<int, List<GameObject>>();
public Dictionary<int, List<UnityObject>> AutoLoaderUnityObjects = new Dictionary<int, List<UnityObject>>();
}
// ConfigLoader中要调用,暂时放在这里
public static partial class YooAssetComponentSystem
{
public static async ETTask<GameObject> InstantiateAsync(this YooAssetComponent self, string location, Transform parent_transform = null,
bool stay_world_space = false)
{
return await YooAssetWrapper.InstantiateAsync(location, parent_transform, stay_world_space);
}
public static GameObject InstantiateSync(this YooAssetComponent self, string location, Transform parent_transform = null,
bool stay_world_space = false)
{
return YooAssetWrapper.InstantiateSync(location, parent_transform, stay_world_space);
}
public static void ReleaseInstance(this YooAssetComponent self, GameObject go)
{
YooAssetWrapper.ReleaseInstance(go);
}
public static async ETTask<T> LoadAssetAsync<T>(this YooAssetComponent self, string location)
where T : UnityEngine.Object
{
return await YooAssetWrapper.LoadAssetAsync<T>(location);
}
public static T LoadAssetSync<T>(this YooAssetComponent self, string location)
where T : UnityEngine.Object
{
return YooAssetWrapper.LoadAssetSync<T>(location);
}
public static async ETTask LoadSceneAsync(this YooAssetComponent self, string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true)
{
await YooAssetWrapper.LoadSceneAsync(location, sceneMode, activateOnLoad);
}
public static void Release(this YooAssetComponent self, UnityEngine.Object obj)
{
YooAssetWrapper.Release(obj);
}
public static Dictionary<string, UnityEngine.Object> GetAssetsByTagSync(this YooAssetComponent self, string tag)
{
return YooAssetWrapper.GetAssetsByTagSync(tag);
}
public static void ReleaseByTag(this YooAssetComponent self, string tag)
{
YooAssetWrapper.ReleaseByTag(tag);
}
}
}