Beispiel #1
0
 protected virtual void Awake()
 {
     if (!isRegistered)
     {
         RegisteredComponentController._Register(this);
         isRegistered   = true;
         isUnregistered = false;
     }
     else
     {
         Debug.LogWarning("RegisteredComponent: Awake() / OnDestroy() not correctly called. Object: " + name);
     }
 }
Beispiel #2
0
    private void _ApplyVolumeChange()
    {
        // TODO: change Volume into a property and call ApplyVolumeChange automatically (requires editor inspector adaption!)

        AudioObject[] objs = RegisteredComponentController.GetAllOfType <AudioObject>();

        foreach (AudioObject o in objs)
        {
            if (o.category == this)
            {
                //if ( o.IsPlaying() )
                {
                    o._ApplyVolume();
                }
            }
        }
    }
Beispiel #3
0
    protected virtual void OnDestroy()
    {
        if (isRegistered && !isUnregistered)
        {
            RegisteredComponentController._Unregister(this);
            isRegistered   = false;
            isUnregistered = true;
        }
        else
        {
            bool alreadyUnregisteredProperly = !isRegistered && isUnregistered;

            if (!alreadyUnregisteredProperly)   // for poolable objects OnDestroy() can get called multiple times
            {
                Debug.LogWarning("RegisteredComponent: Awake() / OnDestroy() not correctly called. Object: " + name + " isRegistered:" + isRegistered + " isUnregistered:" + isUnregistered);
            }
        }
    }
Beispiel #4
0
    static public List <string> GetUsedAudioClipNames()
    {
        matchesListString.Clear();

        object[] objs = RegisteredComponentController.GetAllOfType(typeof(SoundObject));
        for (int i = 0; i < objs.Length; i++)
        {
            var sound = objs[i] as SoundObject;
            if (sound.IsPlaying || sound.IsPaused)
            {
                if (sound.SubItem.SubItemType == SoundClipType.StreamingClip)
                {
                    matchesListString.Add(sound.SubItem.Name);
                }
            }
        }

        return(matchesListString);
    }
Beispiel #5
0
    public static SoundObject[] GetPlayingAudioObjects(string soundID, bool includePausedAudio = false)
    {
        matchesList.Clear();

        object[] objs = RegisteredComponentController.GetAllOfType(typeof(SoundObject));
        for (int i = 0; i < objs.Length; i++)
        {
            var sound = objs[i] as SoundObject;
            if (sound.IsPlaying || (includePausedAudio && sound.IsPaused))
            {
                if (string.IsNullOrEmpty(soundID) || sound.SoundID.Equals(soundID))
                {
                    matchesList.Add(sound);
                }
            }
        }

        return(matchesList.ToArray());
    }
 protected virtual void OnDestroy()
 {
     if (isRegistered && !isUnregistered)
     {
         RegisteredComponentController._Unregister(this);
         isRegistered   = false;
         isUnregistered = true;
     }
     else if (isRegistered || !isUnregistered)
     {
         Debug.LogWarning(String.Concat(new Object[]
         {
             "RegisteredComponent: Awake() / OnDestroy() not correctly called. Object: ",
             name,
             " isRegistered:",
             isRegistered,
             " isUnregistered:",
             isUnregistered
         }));
     }
 }