Beispiel #1
0
        public void DetachBy_Type_Refer(string type_, object refer_)
        {
            List <Observer> arr = GetObsArr(type_);

            if (arr == null)
            {
                return;
            }

            Refer.Assert(refer_);

            if (arr.Count > 0)
            {
                Observer obs;
                for (int i = arr.Count - 1; i >= 0; --i)
                {
                    obs = arr[i];
                    if (obs != null)
                    {
                        if (obs.refer == refer_)
                        {
                            obs.Clear();
                            __obsPool.Push(obs);

                            if (m_invalid > 0)
                            {
                                arr[i] = null;
                            }
                            else
                            {
                                arr.RemoveAt(i);
                            }

                            m_objNum--;
                            //break;    可能会有多个
                        }
                    }
                }
            }


            if (arr.Count == 0)
            {
                RemoveObsArr(type_);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 设置图片(同步加载)
        /// </summary>
        /// <param name="image_">是否需要保持引用,等go失效时设置为移除引用?</param>
        /// <param name="url_"></param>
        /// <param name="spriteName"></param>
        /// <param name="refer_"></param>
        /// <param name="nativeSize_">重置尺寸</param>
        public void SetSprite(object refer_, Image image_, string url_, string spriteName, bool nativeSize_ = false)
        {
            string real_url_ = FormatPath(url_);

            if (m_itemQueue.Count > 0 && m_image2item.ContainsKey(image_))
            {
                //image在加载队列中,从队列移除
                LoadItem item = m_image2item[image_];
                RemoveLoadItem(item);
            }

            Refer.Assert(refer_);
            string referId = Refer.Format(refer_);

            RetainImage(image_, referId);

            __SetSprite(referId, image_, real_url_, spriteName, nativeSize_);
        }
Beispiel #3
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽加载操作∽-★-∽--------∽-★-∽------∽-★-∽--------//


        /// <summary>
        /// 加载图片
        /// </summary>
        /// <param name="image_"></param>
        /// <param name="url_"></param>
        /// <param name="spriteName"></param>
        /// <param name="refer_"></param>
        /// <param name="nativeSize_">重置图片尺寸</param>
        public void LoadSprite(object refer_, Image image_, string url_, string spriteName, bool nativeSize_ = false)
        {
            string real_url_ = FormatPath(url_);

            if (m_assetCache.HasAsset(real_url_))
            {
                //资源已加载
                SetSprite(refer_, image_, url_, spriteName, nativeSize_);
                return;
            }

            Refer.Assert(refer_);
            string referId = Refer.Format(refer_);

            RetainImage(image_, referId);

            image_.sprite = null;   //设置为透明图片

            AddLoadItem(referId, image_, real_url_, spriteName, nativeSize_);

            m_assetCache.LoadAsync(real_url_, OnLoaded, refer_); //用refer_作引用者,直到它deactive才释放

            //(这里有bug, 如果先来异步再来同步,异步回来会顶掉正确的那个)
        }