예제 #1
0
 /// <summary>
 /// 根据指定的资源类型,查找游戏资源
 /// </summary>
 /// <returns>返回资源对象</returns>
 /// <param name="name">资源名称</param>
 public static T findRes <T>(string name) where T : Object
 {
     T[] objs = Resources.FindObjectsOfTypeAll <T>();
     if (objs != null && objs.Length > 0)
     {
         foreach (Object obj in objs)
         {
             if (obj.name == name)
             {
                 return(obj as T);
             }
         }
     }
     objs = AssetBundle.FindObjectsOfType <T>();
     if (objs != null && objs.Length > 0)
     {
         foreach (Object obj in objs)
         {
             if (obj.name == name)
             {
                 return(obj as T);
             }
         }
     }
     return(default(T));
 }
예제 #2
0
 public static T FindResource <T>(string name) where T : Object
 {
     //寻找资源目录下的T类型的物体
     Object[] objs = Resources.FindObjectsOfTypeAll <T> ();
     if (objs != null && objs.Length > 0)
     {
         foreach (Object obj in objs)
         {
             if (obj.name == name)
             {
                 return(obj as T);
             }
         }
     }
     //寻找AssetBundle中的T类型的物体
     objs = AssetBundle.FindObjectsOfType <T> ();
     if (objs != null && objs.Length > 0)
     {
         foreach (Object obj in objs)
         {
             if (obj.name == name)
             {
                 return(obj as T);
             }
         }
     }
     //没有找到返回默认的T类型
     return(default(T));
 }
예제 #3
0
        private void InitializeSettings()
        {
            if (sheepSettings != null)
            {
                return;
            }
            var sheepSetts = AssetBundle.FindObjectsOfType <SheepSettings>();

            if (sheepSetts.Length > 1)
            {
                Debug.LogWarning("Enemy State ambiguity: None sheep settings was provided and there are more then one in project!");
            }
            if (sheepSetts.Length == 0)
            {
                Debug.LogError("Enemy State Problem: None Sheep settings were found!");
                return;
            }
            sheepSettings = sheepSetts[0];
        }
예제 #4
0
        private void InitializeSettings()
        {
            soundSettings.SetBGMVolume(soundSettings.initialVolumes);
            soundSettings.SetSFXVolume(soundSettings.initialVolumes);
            if (soundSettings != null)
            {
                return;
            }
            var soundSetts = AssetBundle.FindObjectsOfType <SoundSettings>();

            if (soundSetts.Length > 1)
            {
                Debug.LogWarning(
                    "Sound settings ambiguity: sound settings was provided and there are more then one in project!");
            }
            if (soundSetts.Length == 0)
            {
                Debug.LogError("Sound settings Problem: No sound settings were found!");
                return;
            }
            soundSettings = soundSetts[0];
        }
예제 #5
0
        private void Start()
        {
            spawnersManager = GetComponent <SpawnersManager>();

            Cycles.CyclesManager.Instance.EclipseSettings.OnCycleStart.Register(gameObject, OnEclipseStart_Listener);
            Cycles.CyclesManager.Instance.EclipseSettings.OnCycleEnd.Register(gameObject, OnEclipseEnd_Listener);

            if (sheepSettings != null)
            {
                return;
            }
            var sheepSetts = AssetBundle.FindObjectsOfType <SheepSettings>();

            if (sheepSetts.Length > 1)
            {
                Debug.LogWarning("Mushroom Spawner ambiguity: None sheep settings was provided and there are more then one in project!");
            }
            if (sheepSetts.Length == 0)
            {
                Debug.LogError("Mushroom Spawner Problem: None Sheep settings were found!");
                return;
            }
            sheepSettings = sheepSetts[0];
        }