コード例 #1
0
        public int LoadAssetSync <T>(string path, Action <T> onSuccess = null, Action <int> onFailed = null) where T : class
        {
            path = AssetPathUtil.NormalizePath(path);
            AssetLoadHandler handler = LoadAssetHandler <T>(path, (AssetLoadResult result) =>
            {
                if (result.isDone && result.asset != null)
                {
                    onSuccess?.Invoke(result.GetAsset <T>());
                }
                else
                {
                    onFailed?.Invoke(AssetLoadStatus.LOAD_ERROR);
                }
            });

            return(handler.id);
        }
コード例 #2
0
        public int LoadAssetAsync <T>(string path, Action <T> onSuccess = null, Action <int> onFailed = null) where T : class
        {
            path = AssetPathUtil.NormalizePath(path);
            var handler = LoadAssetHandler <T>(path);

            handler.OnCompleted((AssetLoadResult result) =>
            {
                if (handler.status == AssetLoadStatus.LOAD_FINISHED)
                {
                    onSuccess?.Invoke(result.GetAsset <T>());
                }
                else
                {
                    onFailed?.Invoke(handler.status);
                }
            });
            return(handler.id);
        }