Exemple #1
0
        private void RemovePhotoFrame()
        {
            if (mShowingInfo == null)
            {
                return;
            }
            ObjCachePoolMgr.Instance.RecyclePrefab(mShowingInfo.mPhotoFrameObject, ObjCachePoolType.UI_PREFAB, mShowingInfo.mFileName);
            mShowingInfo = null;

            //Debug.Log("UIPhotoFrameWidget RemovePhotoFrame ");
        }
Exemple #2
0
        IEnumerator Load(string fileName)
        {
            RemovePhotoFrame();
            ObjectWrapper ow = new ObjectWrapper();

            yield return(ResourceLoader.Instance.StartCoroutine(ObjCachePoolMgr.Instance.LoadPrefab(fileName, ObjCachePoolType.UI_PREFAB, fileName, ow)));

            GameObject photoFrameGO = ow.obj as GameObject;

            if (photoFrameGO == null)
            {
                //Debug.Log("UIPhotoFrameWidget photoFrameGO null ");
                yield break;
            }
            RectTransform rect = photoFrameGO.GetComponent <RectTransform>();

            if (rect == null)
            {
                //Debug.Log("UIPhotoFrameWidget photoFrameGO rect ");
                yield break;
            }
            GameObject.DontDestroyOnLoad(photoFrameGO);
            if (this == null || gameObject == null || transform == null || fileName != mShowingFileName)
            {
                //Debug.Log("UIPhotoFrameWidget photoFrameGO return ");
                ObjCachePoolMgr.Instance.RecyclePrefab(photoFrameGO, ObjCachePoolType.UI_PREFAB, fileName);
                yield break;
            }

            RemovePhotoFrame();
            rect.parent = transform;
            rect.SetAsFirstSibling();
            rect.localEulerAngles = Vector3.zero;
            float scale = mRect.sizeDelta.x / DefaultSize;

            rect.localScale = new Vector3(scale, scale, 1);
            //rect.anchorMin = new Vector2(0, 1);
            //rect.anchorMax = new Vector2(0, 1);
            //rect.pivot = new Vector2(0.5f, 0.5f);
            rect.anchoredPosition3D = Vector3.zero;

            mShowingInfo = new PhotoFrameInfo(fileName, photoFrameGO);
            mShowingInfo.SetGrey(mIsGrey);


            StopLoadCoroutine();
        }