Example #1
0
        private void CleanResources()
        {
            mName = null;

            mPlayCount        = 0;
            mIsPause          = false;
            mOnFinishListener = null;
            mLeftDelayTime    = -1;
            mCustomEventID    = -1;

            if (mTimeItem != null)
            {
                mTimeItem.Cancel();
                mTimeItem = null;
            }

            if (mAudioSource != null)
            {
                if (mAudioSource.clip == mAudioClip)
                {
                    mAudioSource.Stop();
                    mAudioSource.clip = null;
                }
            }

            mAudioClip = null;

            if (mLoader != null)
            {
                mLoader.Recycle2Cache();
                mLoader = null;
            }
        }
Example #2
0
        private UIRoot LoadUIRoot()
        {
            ResLoader loader = ResLoader.Allocate(null);

            loader.Add2Load(ProjectPathConfigTemp.UI_ROOT_PATH);
            loader.LoadSync();

            IRes res = ResMgr.Instance.GetRes(ProjectPathConfigTemp.UI_ROOT_PATH, false);

            if (res == null || res.asset == null)
            {
                return(null);
            }

            GameObject prefab = res.asset as GameObject;

            if (prefab == null)
            {
                return(null);
            }

            GameObject uiRoot = GameObject.Instantiate(prefab);

            loader.ReleaseAllRes();
            loader.Recycle2Cache();
            return(uiRoot.GetComponent <UIRoot>());
        }
Example #3
0
 /// <summary>
 /// 关闭
 /// </summary>
 void IUI.Close(bool destroy = true)
 {
     OnClose();
     if (destroy)
     {
         GameObject.Destroy(gameObject);
     }
     mResLoader.ReleaseAllRes();
     mResLoader.Recycle2Cache();
     mResLoader = null;
 }
Example #4
0
        public bool LoadBuildInSceneSync(string sceneName, LoadSceneMode mode = LoadSceneMode.Single)
        {
            if (m_CurrentLoader != null)
            {
                m_CurrentLoader.ReleaseAllRes();
                m_CurrentLoader.Recycle2Cache();
                m_CurrentLoader = null;
            }

            try
            {
                SceneManager.LoadScene(sceneName, mode);
            }
            catch (Exception e)
            {
                Log.e("SceneManager LoadBuildInSceneSysn Failed! SceneName:" + sceneName);
                Log.e(e);
                return(false);
            }

            return(true);
        }
Example #5
0
        public void SetAudio(GameObject root, string name, bool loop)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (mName == name)
            {
                return;
            }

            if (mSource == null)
            {
                mSource = root.AddComponent <AudioSource>();
            }

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

            mLoader = null;
            CleanResources();

            mLoader = ResLoader.Allocate();

            mIsLoop = loop;
            mName   = name;

            mLoader.Add2Load(name, OnResLoadFinish);

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

            if (mLoader != null)
            {
                mLoader.LoadAsync();
            }
        }
Example #6
0
 public void Unload()
 {
     mResLoader.Recycle2Cache();
     mResLoader = null;
 }