示例#1
0
        // Awake is called when the script instance is being loaded.
        void Awake()
        {
            for (int i = 0; i < m_audioClipTable.Length; ++i)
            {
                AudioClip clip = m_audioClipTable[i];
                if (clip == null)
                {
                    XLogger.LogWarning("AudioClipTable[" + i.ToString() + "]: Exception null reference", gameObject);
                }
            }

            if ((m_maxVolume < 0.0f) || (m_maxVolume > 1.0f))
            {
                XLogger.LogWarning("MaxVolume: Exception out of range: " + m_maxVolume.ToString(), gameObject);
            }

            m_audioSource = this.GetComponent <AudioSource>();
            XLogger.LogValidObject(m_audioSource, LibConstants.ErrorMsg.GetMsgNotBoundComponent("AudioSource"), gameObject);

            if (m_audioClipTable.Length > 0)
            {
                m_audioSource.clip = m_audioClipTable[0];
                if (m_audioSource.volume > m_maxVolume)
                {
                    m_audioSource.volume = m_maxVolume;
                }
                if (m_audioSource.playOnAwake)
                {
                    this.Play();
                }
            }
        }
示例#2
0
 public static UnityEngine.GameObject FindSingleObjectWithTag(string tag)
 {
     GameObject[] table = GameObject.FindGameObjectsWithTag(tag);
     if (table.Length != 1)
     {
         if (table.Length == 0)
         {
             XLogger.LogWarning("No instance object Tag:" + tag);
             return(null);
         }
         else
         {
             XLogger.LogWarning("No single instance object Tag:" + tag);
         }
     }
     return(table[0]);
 }
示例#3
0
 void Awake()
 {
     XLogger.LogWarning("Instantiate BlankPrefab", gameObject);
 }