Example #1
0
        /*! \endcond */

        /// <summary>
        /// Sets the group's volume. During startup (Awake event), the Master Audio prefab will assign any Sound Groups that match to the levels you specify here. This will also set the Group's Volume in the current Scene's Master Audio prefab, if a match exists.
        /// </summary>
        /// <param name="grpName">Group name</param>
        /// <param name="vol">Volume</param>
        public static void SetGroupVolume(string grpName, float vol)
        {
            var groupKey = GetGroupKey(grpName);

            PlayerPrefs.SetFloat(groupKey, vol);

            var ma = MasterAudio.SafeInstance;

            if (ma == null)
            {
                return;
            }

            if (MasterAudio.GrabGroup(grpName, false) != null)
            {
                MasterAudio.SetGroupVolume(grpName, vol);
            }

            if (GroupsUpdatedKeys.Contains(Separator + grpName + Separator))
            {
                return;
            }

            GroupsUpdatedKeys += grpName + Separator;
        }
Example #2
0
        /*! \endcond */

        /// <summary>
        /// Sets the bus's volume. During startup (Awake event), the Master Audio prefab will assign any buses that match to the levels you specify here. This will also set the Bus's Volume in the current Scene's Master Audio prefab, if a match exists.
        /// </summary>
        /// <param name="busName">Bus name</param>
        /// <param name="vol">Volume</param>
        public static void SetBusVolume(string busName, float vol)
        {
            var busKey = MakeBusKey(busName);

            PlayerPrefs.SetFloat(busKey, vol);

            var ma = MasterAudio.SafeInstance;

            if (ma == null)
            {
                return;
            }
            if (MasterAudio.GrabBusByName(busName) != null)
            {
                MasterAudio.SetBusVolumeByName(busName, vol);
            }

            if (BusesUpdatedKeys.Contains(Separator + busName + Separator))
            {
                return;
            }

            BusesUpdatedKeys += busName + Separator;
        }