Esempio n. 1
0
        public static string GetAbsolutePath( string relativePath, PathRelativeType type, bool createDirectory )
        {
            switch( type )
            {
            case PathRelativeType.ApplicationDataPath:
                relativePath = Path.Combine( Application.dataPath, relativePath );
                break;

            case PathRelativeType.ApplicationPersistentDataPath:
                relativePath = Path.Combine( Application.persistentDataPath, relativePath );
                break;

            case PathRelativeType.StreamingAssets:
                relativePath = Path.Combine( Application.streamingAssetsPath, relativePath );
                break;

            default:

                break;
            }

            if( createDirectory )
            {
                Directory.CreateDirectory( Path.GetDirectoryName( relativePath ) );
            }

            return relativePath;
        }
Esempio n. 2
0
        public static string GetAbsolutePath(string relativePath, PathRelativeType type, bool createDirectory)
        {
            switch (type)
            {
            case PathRelativeType.ApplicationDataPath:
                relativePath = Path.Combine(Application.dataPath, relativePath);
                break;

            case PathRelativeType.ApplicationPersistentDataPath:
                relativePath = Path.Combine(Application.persistentDataPath, relativePath);
                break;

            case PathRelativeType.StreamingAssets:
                relativePath = Path.Combine(Application.streamingAssetsPath, relativePath);
                break;

            default:

                break;
            }

            if (createDirectory)
            {
                Directory.CreateDirectory(Path.GetDirectoryName(relativePath));
            }

            return(relativePath);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the path to which to write to.
        /// If the path contains a non-existent directory,
        /// it will be created.
        /// </summary>
        public string SetPath(string newPath, PathRelativeType newPathType)
        {
            path     = newPath;
            pathType = newPathType;

            _absPath = GATPathsHelper.GetAbsolutePath(newPath, newPathType, true);

            return(_absPath);
        }
Esempio n. 4
0
        public static string PathForWavFile( string relativePath, PathRelativeType type, bool createDirectory )
        {
            string extension = Path.GetExtension( relativePath );

            if( extension != ".wav" )
            {
                relativePath = Path.ChangeExtension( relativePath, ".wav" );
            }

            return GetAbsolutePath( relativePath, type, createDirectory );
        }
Esempio n. 5
0
        public static string PathForWavFile(string relativePath, PathRelativeType type, bool createDirectory)
        {
            string extension = Path.GetExtension(relativePath);

            if (extension != ".wav")
            {
                relativePath = Path.ChangeExtension(relativePath, ".wav");
            }

            return(GetAbsolutePath(relativePath, type, createDirectory));
        }
Esempio n. 6
0
        /// <summary>
        /// Convenience method for loading files asynchronously
        /// to a sample bank. This method instantiates, configures and
        /// enqueues a AGATLoadingOperation. Use NewOperation if you need
        /// more control over progress callbacks.
        /// </summary>
        public void LoadFilesToSampleBank(string[] filePaths, PathRelativeType pathType, GATSampleBank targetBank, GATDataAllocationMode allocationMode, OperationCompletedHandler onOperationCompleted, bool forceMono = false)
        {
            AGATLoadingOperation operation = new LoadingOperation(allocationMode, filePaths.Length, targetBank.AddLoadedFile, forceMono);
            int i;

            for (i = 0; i < filePaths.Length; i++)
            {
                operation.AddFile(filePaths[i], pathType);
            }

            operation.OnOperationCompleted = onOperationCompleted;

            EnqueueOperation(operation);
        }
Esempio n. 7
0
        /// <summary>
        /// Convenience method for loading files asynchronously
        /// to a sample bank. All wav and ogg files of the specified folder
        /// will be loaded.
        /// This method instantiates, configures and enqueues a AGATLoadingOperation.
        /// Use the NewOperation method if you need more control over progress callbacks.
        /// </summary>
        public void LoadFolderToSampleBank(string folderPath, PathRelativeType pathType, GATSampleBank targetBank, GATDataAllocationMode allocationMode, OperationCompletedHandler onOperationCompleted, bool forceMono = false)
        {
            folderPath = GATPathsHelper.GetAbsolutePath(folderPath, pathType, false);
            if (Directory.Exists(folderPath) == false)
            {
                throw new GATException("No such directory!");
            }

            string[] files = Directory.GetFiles(folderPath);

            if (files.Length == 0)
            {
                                #if UNITY_EDITOR || GAT_DEBUG
                Debug.LogError("Directory exists but is empty");
                                #endif
                return;
            }

            LoadFilesToSampleBank(files, PathRelativeType.Absolute, targetBank, allocationMode, onOperationCompleted, forceMono);
        }
Esempio n. 8
0
            public override bool AddFile(string relativePath, PathRelativeType pathType)
            {
                string extension;

                if (Status != LoadOperationStatus.Configuring)
                {
                                        #if UNITY_EDITOR || GAT_DEBUG
                    Debug.LogError("Cannot add file to operation in progress!");
                                        #endif
                    return(false);
                }

                extension = System.IO.Path.GetExtension(relativePath).ToLower();

                if (extension != ".wav" && extension != ".ogg")
                {
                                        #if UNITY_EDITOR || GAT_DEBUG
                    Debug.LogError("Only ogg and wav files supported by GATAsyncAudioLoader, ignoring " + relativePath);
                                        #endif
                    return(false);
                }

                string path = GATPathsHelper.GetAbsolutePath(relativePath, pathType, false);

                if (System.IO.File.Exists(path) == false)
                {
                                        #if UNITY_EDITOR || GAT_DEBUG
                    Debug.LogError("File not found, ignoring " + path);
                                        #endif
                    return(false);
                }

                _paths.Enqueue(path);

                return(true);
            }
Esempio n. 9
0
 /// <summary>
 /// Adds the specified file to the operation. Returns false
 /// if the file format is not supported or does not exist, 
 /// or if the operation is already scheduled / processing.
 /// </summary>
 /// <returns><c>true</c>, if file was added, <c>false</c> otherwise.</returns>
 public abstract bool AddFile( string relativePath, PathRelativeType pathType );
Esempio n. 10
0
            public override bool AddFile( string relativePath, PathRelativeType pathType )
            {
                string extension;

                if( Status != LoadOperationStatus.Configuring )
                {
                    #if UNITY_EDITOR || GAT_DEBUG
                    Debug.LogError( "Cannot add file to operation in progress!");
                    #endif
                    return false;
                }

                extension = System.IO.Path.GetExtension( relativePath ).ToLower();

                if( extension != ".wav" && extension != ".ogg" )
                {
                    #if UNITY_EDITOR || GAT_DEBUG
                    Debug.LogError( "Only ogg and wav files supported by GATAsyncAudioLoader, ignoring " + relativePath );
                    #endif
                    return false;
                }

                string path = GATPathsHelper.GetAbsolutePath( relativePath, pathType, false );

                if( System.IO.File.Exists( path ) == false )
                {
                    #if UNITY_EDITOR || GAT_DEBUG
                    Debug.LogError( "File not found, ignoring " + path );
                    #endif
                    return false;
                }

                _paths.Enqueue( path );

                return true;
            }
Esempio n. 11
0
        /// <summary>
        /// Convenience method for loading files asynchronously
        /// to a sample bank. All wav and ogg files of the specified folder
        /// will be loaded. 
        /// This method instantiates, configures and enqueues a AGATLoadingOperation.
        /// Use the NewOperation method if you need more control over progress callbacks.
        /// </summary>
        public void LoadFolderToSampleBank( string folderPath, PathRelativeType pathType, GATSampleBank targetBank, GATDataAllocationMode allocationMode, OperationCompletedHandler onOperationCompleted, bool forceMono = false )
        {
            folderPath = GATPathsHelper.GetAbsolutePath( folderPath, pathType, false );
            if( Directory.Exists( folderPath ) == false )
            {
                throw new GATException( "No such directory!" );
            }

            string[] files = Directory.GetFiles( folderPath );

            if( files.Length == 0 )
            {
                #if UNITY_EDITOR || GAT_DEBUG
                Debug.LogError( "Directory exists but is empty" );
                #endif
                return;
            }

            LoadFilesToSampleBank( files, PathRelativeType.Absolute, targetBank, allocationMode, onOperationCompleted, forceMono );
        }
Esempio n. 12
0
        /// <summary>
        /// Convenience method for loading files asynchronously
        /// to a sample bank. This method instantiates, configures and 
        /// enqueues a AGATLoadingOperation. Use NewOperation if you need 
        /// more control over progress callbacks.
        /// </summary>
        public void LoadFilesToSampleBank( string[] filePaths, PathRelativeType pathType, GATSampleBank targetBank, GATDataAllocationMode allocationMode, OperationCompletedHandler onOperationCompleted, bool forceMono = false )
        {
            AGATLoadingOperation operation = new LoadingOperation( allocationMode, filePaths.Length, targetBank.AddLoadedFile, forceMono );
            int i;
            for( i = 0; i < filePaths.Length; i++ )
            {
                operation.AddFile( filePaths[ i ], pathType );
            }

            operation.OnOperationCompleted = onOperationCompleted;

            EnqueueOperation( operation );
        }
Esempio n. 13
0
        /// <summary>
        /// Sets the path to which to write to.
        /// If the path contains a non-existent directory, 
        /// it will be created.
        /// </summary>
        public string SetPath( string newPath, PathRelativeType newPathType )
        {
            path 		= newPath;
            pathType 	= newPathType;

            _absPath = GATPathsHelper.GetAbsolutePath( newPath, newPathType, true );

            return _absPath;
        }
Esempio n. 14
0
 /// <summary>
 /// Adds the specified file to the operation. Returns false
 /// if the file format is not supported or does not exist,
 /// or if the operation is already scheduled / processing.
 /// </summary>
 /// <returns><c>true</c>, if file was added, <c>false</c> otherwise.</returns>
 public abstract bool AddFile(string relativePath, PathRelativeType pathType);