コード例 #1
0
        /// <summary>
        /// Two parameter constructor.
        /// </summary>
        /// <param name="clipIndex">The index of the AudioClip inside the AudioConfig.</param>
        /// <param name="audioConfig">A reference to the overridden AudioConfig.</param>
        public AudioClipInfo(int clipIndex, AudioConfig audioConfig)
        {
            m_ClipIndex = clipIndex;
            m_AudioClip = audioConfig != null?audioConfig.GetAudioClip(clipIndex) : null;

            m_AudioConfig   = audioConfig;
            m_AudioModifier = new AudioModifier();
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(audioClips, true);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(volumeScale);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(playMode);
            switch ((AudioConfig.AudioPlayModes)playMode.enumValueIndex)
            {
            case AudioConfig.AudioPlayModes.Normal:
                EditorGUILayout.HelpBox("Play normally -- no restrictions at all.", MessageType.None, true);
                break;

            case AudioConfig.AudioPlayModes.Override:
                EditorGUILayout.HelpBox("Each play will override (stop) the previous one.", MessageType.Info, true);
                break;

            case AudioConfig.AudioPlayModes.OneAtATime:
                EditorGUILayout.HelpBox("Will not play if the previous one is still playing.", MessageType.Info, true);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(templateAudioSource);
            if (templateAudioSource.objectReferenceValue != null)
            {
                EditorGUILayout.HelpBox("The rest settings will now override by the template.", MessageType.Info, true);
            }
            else
            {
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(loop);
                EditorGUILayout.PropertyField(priority);
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(spatialMode);
                switch ((AudioConfig.SpatialModes)spatialMode.enumValueIndex)
                {
                case AudioConfig.SpatialModes.Pure2D:
                    EditorGUILayout.HelpBox("No Spatial Blend at all.", MessageType.None, true);
                    break;

                case AudioConfig.SpatialModes.Simple2D:
                    EditorGUILayout.HelpBox("Volume will be scaled based on the distance.\n" +
                                            "Still using 2D Spatial Blend. (No Stereo Pan calculation)", MessageType.Info, true);
                    EditorGUILayout.PropertyField(minDistance);
                    EditorGUILayout.PropertyField(maxDistance);
                    break;

                case AudioConfig.SpatialModes.Simple3D:
                    EditorGUILayout.HelpBox("Using 3D Spatial Blend + Linear Rolloff.", MessageType.Info, true);
                    EditorGUILayout.PropertyField(minDistance);
                    EditorGUILayout.PropertyField(maxDistance);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            serializedObject.ApplyModifiedProperties();

            // Quick Preview
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Quick Preview", "(no volume or templates applied)");
            EditorGUILayout.BeginHorizontal();
            GUI.enabled = config.AudioClips.Count > 0;
            if (GUILayout.Button("Play Solo"))
            {
                PlayClip(config.GetAudioClip());
            }
            if (GUILayout.Button("Stop"))
            {
                StopAllClips();
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
        }