private void ReplaceCardsSkin() { if (mCardsAtlas == null) { mCardsAtlas = Resources.Load <GameObject>("CardPrefab/8_UICardsAtlasNew").GetComponent <UIAtlas>(); } UISprite[] cards = CacheTrans.GetComponentsInChildren <UISprite>(true); foreach (UISprite sprite in cards) { if (sprite.atlas.name == "8_UICardsAtlas") { /* * Vector2 tempSize = sprite.localSize; * string tempSpriteName = sprite.spriteName; * GameObject spriteObject = sprite.gameObject; * GameObject.Destroy(sprite); * * UISprite newSprite = spriteObject.AddComponent<UISprite>(); * newSprite.atlas = mCardsAtlas; * newSprite.spriteName = tempSpriteName; * newSprite.SetRect(0, 0, tempSize.x, tempSize.y); * Debug.Log(tempSize.x.ToString() + " " + tempSize.y.ToString()); */ sprite.atlas = mCardsAtlas; } } }
protected override void OnAwakeInitUI() { mUIMainModel = UIModelMgr.Instance.GetModel <UIMainModel>(); CacheTrans.GetUIEventListener("Root/BtnClose").onClick += OnCloseClick; ExpressionItem[] expressionItems = CacheTrans.GetComponentsInChildren <ExpressionItem>(); foreach (var item in expressionItems) { item.OnCloseClick += OnCloseClick; } }