// ReSharper disable MemberCanBeMadeStatic.Global
        public void Process()
// ReSharper restore MemberCanBeMadeStatic.Global
        {
            if (!string.IsNullOrEmpty(AudioMapperPath))
            {
                Debug.Log("Creating audio mapper...");
                var command = new CreateAudioMapperCommand { AudioMapperPath = AudioMapperPath };
                command.Run();

                AudioMapperPath = null;
            }
        }
예제 #2
0
        private static void InitAudio()
        {
            _audioInitialized = false;

            MapperInfo info;
            AudioPlayerMapper mapper = GetAudioMapper(out info);

            bool result;
            switch (info)
            {
                case MapperInfo.NotFound:
                    string text = @"No default audio mapper found.

Would you like to create it?";

                    if (EditorApplication.isPlaying)
                        text += @"

(Play mode will be stopped)";

                    result = EditorUtility.DisplayDialog("Info", text, "Yes", "No");

                    if (result)
                    {
#if DEBUG
                        if (DebugMode)
                        {
                            Debug.Log("Creating audio mapper");
                        }
#endif

                        if (EditorApplication.isPlaying)
                        {
                            AudioMapperAdditionProcessor.AudioMapperPath = AudioMapperPath;
                            Debug.Log("Stopping the application");
                            EditorApplication.isPlaying = false;
                            return;
                        }

                        CreateAudioMapperCommand cmd = new CreateAudioMapperCommand
                                                           {
                                                               AudioMapperPath = AudioMapperPath,
                                                               NumberOfAudioSources = NumberOfAudioSources,
                                                               NumberOfAudioTokens = NumberOfAudioTokens
                                                           };
                        cmd.Run();
                    }
                    //else
                    //{
                    //    // never mind
                    //    _audioInitialized = true;
                    //}
                    break;
                case MapperInfo.MapperNotEnabled:
                    result = EditorUtility.DisplayDialog("Info", @"Audio mapper found but not enabled.

Would you like to enable it?", "Yes", "No");
                    if (result)
                    {
                        Debug.Log("Enabling default audio player mapper");
                        if (null == mapper)
                            throw new Exception("Error: mapper is null");
                        mapper.enabled = true;
                    }
                    _audioInitialized = true;
                    break;
                default:
#if DEBUG
                    if (DebugMode)
                    {
                        Debug.Log("Audio OK");
                    }
#endif
                    _audioInitialized = true;
                    break;
            }
        }