Esempio n. 1
0
        internal SoundVariation AddVariation(AudioClip clip)
        {
            SoundVariation variation = new SoundVariation();

            variation.Clip = clip;
            variations.Add(variation);

            return(variation);
        }
Esempio n. 2
0
        /// <summary>
        /// Plays sound in 3D space.
        /// </summary>
        /// <param name="position">Position of the sound.</param>
        /// <param name="volume">Volume of the sound. Value must be in [0;1] range.</param>
        /// <param name="pitch">Pitch of the sound. Value must be in [-3;3] range.</param>
        /// <param name="delay">Delay of the sound. Value must be greater or equal to zero.</param>
        /// <remarks>
        /// <para>Volume parameter value will override <see cref="Stem.SoundVariation"/>.<see cref="Stem.SoundVariation.Volume"/> value.</para>
        /// <para>Pitch parameter value will override <see cref="Stem.SoundVariation"/>.<see cref="Stem.SoundVariation.Pitch"/> value.</para>
        /// <para>Delay parameter value will override <see cref="Stem.SoundVariation"/>.<see cref="Stem.SoundVariation.Delay"/> value.</para>
        /// </remarks>
        public void Play3D(Vector3 position, float volume, float pitch, float delay)
        {
            if (sound == null)
            {
                return;
            }

            SoundVariation variation = sound.FetchVariation();

            PlayInternal(position, variation.Clip, volume, pitch, delay);
        }
Esempio n. 3
0
        /// <summary>
        /// Plays sound in 3D space.
        /// </summary>
        /// <param name="position">Position of the sound.</param>
        public void Play3D(Vector3 position)
        {
            if (sound == null)
            {
                return;
            }

            SoundVariation variation = sound.FetchVariation();

            PlayInternal(position, variation.Clip, variation.Volume, variation.Pitch, variation.Delay);
        }
Esempio n. 4
0
        private void SoundVariationElement(ReorderableList list, Rect rect, int index, bool isActive, bool isFocused)
        {
            SoundVariation v      = (SoundVariation)list.list[index];
            float          offset = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            rect.height = EditorGUIUtility.singleLineHeight;
            EditorGUI.LabelField(rect, v.Name, EditorStyles.boldLabel);

            rect.y += offset;
            v.Clip  = (AudioClip)EditorGUI.ObjectField(rect, "Clip", v.Clip, typeof(AudioClip), false);

            float   fixedValue       = v.FixedVolume;
            bool    randomize        = v.RandomizeVolume;
            Vector2 randomValueRange = v.RandomVolume;

            offset  = RandomRangeField("Volume", 0.0f, 1.0f, rect, ref fixedValue, ref randomize, ref randomValueRange);
            rect.y += offset;

            v.FixedVolume     = fixedValue;
            v.RandomizeVolume = randomize;
            v.RandomVolume    = randomValueRange;

            fixedValue       = v.FixedPitch;
            randomize        = v.RandomizePitch;
            randomValueRange = v.RandomPitch;

            offset  = RandomRangeField("Pitch", -3.0f, 3.0f, rect, ref fixedValue, ref randomize, ref randomValueRange);
            rect.y += offset;

            v.FixedPitch     = fixedValue;
            v.RandomizePitch = randomize;
            v.RandomPitch    = randomValueRange;

            fixedValue       = v.FixedDelay;
            randomize        = v.RandomizeDelay;
            randomValueRange = v.RandomDelay;

            offset  = RandomRangeField("Delay", 0.0f, 10.0f, rect, ref fixedValue, ref randomize, ref randomValueRange);
            rect.y += offset;

            v.FixedDelay     = fixedValue;
            v.RandomizeDelay = randomize;
            v.RandomDelay    = randomValueRange;
        }
Esempio n. 5
0
        private float SoundVariationElementHeight(ReorderableList list, int index)
        {
            SoundVariation variation = (SoundVariation)list.list[index];

            int numLines = 8;

            if (variation.RandomizeVolume)
            {
                numLines += 1;
            }

            if (variation.RandomizePitch)
            {
                numLines += 1;
            }

            if (variation.RandomizeDelay)
            {
                numLines += 1;
            }

            return((EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * numLines);
        }