Ejemplo n.º 1
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽gameobject管理∽-★-∽--------∽-★-∽------∽-★-∽--------//

        public GameObject CreateGo(string url_, CALLBACK_GO onComplete_)
        {
            url_ = url_.ToLower();

            GameObject prefab = m_assetCache.GetAsset(url_) as GameObject;

            if (prefab == null)
            {
                Log.Assert("gameobject未加载:" + url_);
                return(null);
            }

            GameObject go = GameObjUtil.CreateGameObj(prefab);

            GameObjUtil.DontDestroyOnLoad(go);  //所有加载出来的go都是默认不销毁

            AddGo(url_, go);

            if (onComplete_ != null)
            {
                onComplete_(go);
            }

            return(go);
        }
Ejemplo n.º 2
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽static∽-★-∽--------∽-★-∽------∽-★-∽--------//

        static public CallFunc Create(CALLBACK_GO func_)
        {
            CallFunc action = new CallFunc();

            action.InitWithFunc(func_);
            return(action);
        }
Ejemplo n.º 3
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽LoadItem∽-★-∽--------∽-★-∽------∽-★-∽--------//

        LoadItem AddLoadItem(string url_, CALLBACK_GO onComplete_, string referId_)
        {
            LoadItem item = m_itemPool.Pop();

            item.Init(url_, onComplete_, referId_);

            m_itemList.Add(item);

            if (referId_ != null)
            {
                Refer.AttachDeactive(referId_, onDeactive); //监听沉默
            }

            return(item);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 异步加载
        /// </summary>
        /// <param name="url_"></param>
        /// <param name="onComplete_"></param>
        /// <param name="refer_">只影响onComplete,不会用来持有资源</param>
        public void LoadAsync(string url_, CALLBACK_GO onComplete_, object refer_)
        {
            url_ = url_.ToLower();
            m_assetCache.RetainByUrl(this, url_);
            //m_assetCache.Retain(refer_, url_);    //引用者只用this

            if (m_assetCache.HasAsset(url_))
            {
                CreateGo(url_, onComplete_);
                return;
            }

            string referId = Refer.Format(refer_);

            AddLoadItem(url_, onComplete_, referId);

            m_assetCache.LoadAsync(url_, OnLoaded, this);   //已自己作为引用者,在ReleaseUnused时才有可能释放
        }
Ejemplo n.º 5
0
        protected override void OnClear()
        {
            base.OnClear();

            m_func = null;
        }
Ejemplo n.º 6
0
        public void InitWithFunc(CALLBACK_GO func_)
        {
            Init();

            m_func = func_;
        }
Ejemplo n.º 7
0
        public void LoadAsync_Prefab(string resId_, string resName_, CALLBACK_GO onComplete_, object refer)
        {
            string url = ResConfig.GetResUrl(resId_, resName_, ""); //去除后缀名

            GameObjCache.me.LoadAsync(url, onComplete_, refer);
        }
Ejemplo n.º 8
0
 public void Clear()
 {
     url        = null;
     onComplete = null;
     referId    = null;
 }
Ejemplo n.º 9
0
 public void Init(string url_, CALLBACK_GO onComplete_, string referId_)
 {
     url        = url_;
     onComplete = onComplete_;
     referId    = referId_;
 }