Esempio n. 1
0
        public Thread LoadFromFile(string filename, AssetLoaderOptions options = null, GameObject wrapperGameObject = null,
                                   ObjectLoadedHandle onAssetLoaded            = null, string basePath = null, AssimpInterop.ProgressCallback progressCallback = null)
#endif
        {
            if (basePath == null)
            {
                basePath = FileUtils.GetFileDirectory(filename);
            }
            var usesWrapperGameObject = wrapperGameObject != null;

            return(ThreadUtils.RunThread(delegate
            {
                InternalLoadFromFile(filename, basePath, options, usesWrapperGameObject, progressCallback);
            },
                                         delegate
            {
                var loadedGameObject = BuildGameObject(options, basePath, wrapperGameObject);
                if (onAssetLoaded != null)
                {
                    onAssetLoaded(loadedGameObject);
                }
                ReleaseImport();
            }
                                         ));
        }
Esempio n. 2
0
        public Thread LoadFromFileWithTextures(string filename, AssetLoaderOptions options = null, GameObject wrapperGameObject = null, ObjectLoadedHandle onAssetLoaded = null, string basePath = null, AssimpInterop.ProgressCallback progressCallback = null)
#endif
        {
            var extension = FileUtils.GetFileExtension(filename);

            if (basePath == null)
            {
                basePath = FileUtils.GetFileDirectory(filename);
            }
            var usesWrapperGameObject = wrapperGameObject != null;

            return(ThreadUtils.RunThread(delegate
            {
                var fileData = FileUtils.LoadFileData(filename);
                InternalLoadFromMemoryAndZip(fileData, extension, basePath, options, usesWrapperGameObject, null, null, null, progressCallback);
            },
                                         delegate
            {
                var loadedGameObject = BuildGameObject(options, extension, wrapperGameObject);
                if (onAssetLoaded != null)
                {
                    onAssetLoaded(loadedGameObject);
                }
                ReleaseImport();
            }
                                         ));
        }
Esempio n. 3
0
        /// <summary>
        /// Internally asynchronously loads a <see cref="UnityEngine.GameObject"/> from input filename with defined options.
        /// </summary>
        /// <param name="filename">Filename used to load the <see cref="UnityEngine.GameObject"/>.</param>
        /// <param name="options"><see cref="AssetLoaderOptions"/> used to load the object.</param>
        /// <param name="wrapperGameObject">Use this field to load the new <see cref="UnityEngine.GameObject"/> into referenced <see cref="UnityEngine.GameObject"/>.</param>
        /// <param name="onAssetLoaded">The action that will be executed when the <see cref="UnityEngine.GameObject"/> be loaded.</param>
        /// <param name="progressCallback">Callback used to retrieve file loading percentage.</param>
        /// <returns>The created Thread on NET 2.0, otherwise returns the created Task.</returns>
        private object AsyncLoadFileInternal(string filename, AssetLoaderOptions options, GameObject wrapperGameObject, ObjectLoadedHandle onAssetLoaded, AssimpInterop.ProgressCallback progressCallback = null)
        {
            var basePath = FileUtils.GetFileDirectory(filename);
            var usesWrapperGameObject = wrapperGameObject != null;

            return(ThreadUtils.RunThread(delegate
            {
                InternalLoadFromFile(filename, basePath, options, usesWrapperGameObject, progressCallback);
            },
                                         delegate
            {
                var loadedGameObject = BuildGameObject(options, basePath, wrapperGameObject);
                if (onAssetLoaded != null)
                {
                    onAssetLoaded(loadedGameObject);
                }
                ReleaseImport();
            }
                                         ));
        }
Esempio n. 4
0
        public Thread LoadFromMemoryWithTextures(byte[] fileData, string assetExtension, AssetLoaderOptions options, GameObject wrapperGameObject, ObjectLoadedHandle onAssetLoaded, string basePath = null, AssimpInterop.DataCallback dataCallback = null, AssimpInterop.ExistsCallback existsCallback = null, AssimpInterop.ProgressCallback progressCallback = null)
#endif
        {
            if (basePath == null)
            {
                basePath = FileUtils.GetFileDirectory(assetExtension);
            }
            var usesWrapperGameObject = wrapperGameObject != null;

            return(ThreadUtils.RunThread(delegate
            {
                InternalLoadFromMemoryAndZip(fileData, assetExtension, basePath, options, usesWrapperGameObject, dataCallback, existsCallback, null, progressCallback);
            },
                                         delegate
            {
                var loadedGameObject = BuildGameObject(options, assetExtension, wrapperGameObject);
                if (onAssetLoaded != null)
                {
                    onAssetLoaded(loadedGameObject);
                }
                ReleaseImport();
            }
                                         ));
        }