Ejemplo n.º 1
0
        public async Task <T> LoadAsync <T>(string assetPath) where T : UnityEngine.Object
        {
            Debug.Log("assetPath " + assetPath);
            var   req = Assets.LoadAssetAsync(assetPath, typeof(T));
            await req;

            RegisterPool(ref req);

            return(req.asset as T);
        }
Ejemplo n.º 2
0
        public void LoadAsync(string assetPath, Type type, Action <UnityEngine.Object, XException> callback)
        {
            Debug.Log("assetPath " + assetPath);
            var req = Assets.LoadAssetAsync(assetPath, type);

            req.completed += assetReq =>
            {
                if (assetReq.error.IsNullOrEmpty())
                {
                    RegisterPool(ref assetReq);

                    callback?.Invoke(assetReq.asset, null);
                }
                else
                {
                    callback?.Invoke(null, new XException(assetReq.error));
                }
            };
        }