示例#1
0
        public void TestResLoader()
        {
            m_Loader = ResLoader.Allocate();
            m_Loader.Add2Load("Bench_A");
            m_Loader.LoadAsync(ResLoaderCallback);
            //GameObject go = m_Loader.LoadSync("Bench_A") as GameObject;
            //GameObject.Instantiate(go);

            //回收资源
            //m_Loader.Recycle2Cache();
        }
示例#2
0
        public void SetAudio(GameObject root, string name, bool loop, bool isEnable)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (m_Name == name)
            {
                return;
            }

            if (m_Source == null)
            {
                m_Source = root.AddComponent <AudioSource>();
                if (!isEnable)
                {
                    m_Source.enabled = isEnable;
                }
            }

            //防止卸载后立马加载的情况
            ResLoader preLoader = m_Loader;

            m_Loader = null;
            CleanResources();

            RegisterActiveAudioUnit(this);

            m_Loader = ResLoader.Allocate();

            m_IsLoop = loop;
            m_Name   = name;

            m_Loader.Add2Load(name, OnResLoadFinish);

            if (preLoader != null)
            {
                preLoader.Recycle2Cache();
                preLoader = null;
            }

            if (m_Loader != null)
            {
                m_Loader.LoadAsync();
            }
        }
示例#3
0
        private void CleanResources()
        {
            if (m_OnStopListener != null)
            {
                m_OnStopListener(m_ID);
            }

            UnRegisterActiveAudioUnit(this);
            m_Name             = null;
            m_PlayCount        = 0;
            m_IsPause          = false;
            m_OnFinishListener = null;
            m_OnStopListener   = null;
            m_LeftDelayTime    = -1;

            if (m_TimeItemID > 0)
            {
                Timer.S.Cancel(m_TimeItemID);
                m_TimeItemID = -1;
            }

            if (m_Source != null)
            {
                if (m_Source.clip == m_AudioClip)
                {
                    if (m_Source.enabled)
                    {
                        m_Source.Stop();
                    }
                    m_Source.clip = null;
                }
                m_Source.volume = 1.0f;
                m_Source.pitch  = 1.0f;
            }

            m_AudioClip = null;

            if (m_Loader != null)
            {
                m_Loader.Recycle2Cache();
                m_Loader = null;
            }
        }
示例#4
0
        private static SDKConfig LoadInstance()
        {
            ResLoader loader = ResLoader.Allocate();

            UnityEngine.Object obj = loader.LoadSync("Resources/Config/SDKConfig");
            if (obj == null)
            {
                loader.Recycle2Cache();
                return(null);
            }

            instance = obj as SDKConfig;

            SDKConfig newAB = GameObject.Instantiate(instance);

            instance = newAB;

            loader.Recycle2Cache();

            return(instance);
        }
示例#5
0
        private static AppConfig LoadInstance()
        {
            ResLoader loader = ResLoader.Allocate();

            UnityEngine.Object obj = loader.LoadSync("Resources/Config/AppConfig");
            if (obj == null)
            {
                loader.Recycle2Cache();
                return(null);
            }

            instance = obj as AppConfig;

            // // AppConfig newAB = GameObject.Instantiate(instance);

            // // instance = newAB;

            //loader.Recycle2Cache();

            //简易写法
            //instance = Resources.Load<AppConfig>("Config/AppConfig");

            return(instance);
        }
示例#6
0
        public static ResLoader Allocate()
        {
            ResLoader loader = ObjectPool <ResLoader> .S.Allocate();

            return(loader);
        }
示例#7
0
 public override void OnSingletonInit()
 {
     m_UILoader = ResLoader.Allocate();
     m_UIRoot   = GameObject.FindObjectOfType <UIRoot>();
 }