private void SetStarImage(StarType starType, UISprite spStar) { string starSpriteName = "fb_xing_yidengdao"; switch(starType) { case StarType.StarType1: { starSpriteName = "zs"; spStar.atlas = MogoUIManager.Instance.GetAtlasByIconName(starSpriteName); spStar.spriteName = starSpriteName; spStar.MakePixelPerfect(); }break; case StarType.StarType2: { starSpriteName = "hg_h"; spStar.atlas = MogoUIManager.Instance.GetAtlasByIconName(starSpriteName); spStar.spriteName = starSpriteName; spStar.MakePixelPerfect(); }break; case StarType.StarType3: { starSpriteName = "hg"; spStar.atlas = MogoUIManager.Instance.GetAtlasByIconName(starSpriteName); spStar.spriteName = starSpriteName; spStar.MakePixelPerfect(); }break; } }
/// <summary> /// Draw the atlas and sprite selection fields. /// </summary> protected override bool OnDrawProperties() { mSprite = mWidget as UISprite; ComponentSelector.Draw<UIAtlas>(mSprite.atlas, OnSelectAtlas); if (mSprite.atlas == null) return false; string spriteName = SpriteField(mSprite.atlas, mSprite.spriteName); if (mSprite.spriteName != spriteName) { Undo.RegisterUndo(mSprite, "Sprite Change"); mSprite.spriteName = spriteName; mSprite.MakePixelPerfect(); EditorUtility.SetDirty(mSprite.gameObject); } return true; }
// Update is called once per frame void Update() { if (eggModel != null && eggModel.ovulationTime != 0) { if ((Time.time - eggModel.ovulationTime) > 20) { eggModel.Hatch(); } if ((Time.time - eggModel.ovulationTime) > 10) { UISprite spr = gameObject.GetComponent <UISprite>(); spr.spriteName = "Egg3"; spr.MakePixelPerfect(); } else if ((Time.time - eggModel.ovulationTime) > 5) { UISprite spr = gameObject.GetComponent <UISprite>(); spr.spriteName = "Egg2"; spr.MakePixelPerfect(); } } }
static public void AddSprite() { GameObject go = NGUIEditorTools.SelectedRoot(true); if (go != null) { //Undo.RegisterSceneUndo("Add a Sprite"); Undo.DestroyObjectImmediate(go); Undo.RegisterCreatedObjectUndo(go, "Add a Sprite"); UISprite sprite = NGUITools.AddWidget <UISprite>(go); sprite.name = "Sprite"; sprite.atlas = NGUISettings.atlas; if (sprite.atlas != null) { string sn = EditorPrefs.GetString("NGUI Sprite", ""); UIAtlas.Sprite sp = sprite.atlas.GetSprite(sn); if (sp != null) { sprite.spriteName = sn; if (sp.inner != sp.outer) { sprite.type = UISprite.Type.Sliced; } } } sprite.pivot = NGUISettings.pivot; sprite.cachedTransform.localScale = new Vector3(100f, 100f, 1f); sprite.MakePixelPerfect(); Selection.activeGameObject = sprite.gameObject; } else { Debug.Log("You must select a game object first."); } }
private void SetBackgroundSize() { UISprite m_back_sprite = GetComponent <UISprite>(); if (m_back_sprite != null && UISprite.Type.Simple == m_back_sprite.type) { m_back_sprite.MakePixelPerfect(); float back_width = m_back_sprite.transform.localScale.x; float back_height = m_back_sprite.transform.localScale.y; float standard_aspect = standard_width / standard_height; float device_aspect = device_width / device_height; float extend_aspect = 0f; float scale = 0f; if (device_aspect > standard_aspect) { scale = device_aspect / standard_aspect; extend_aspect = back_width / standard_width; } else { scale = standard_aspect / device_aspect; extend_aspect = back_height / standard_height; } if (extend_aspect >= scale) { } else { scale /= extend_aspect; m_back_sprite.transform.localScale *= scale; } } }
static public void AddSprite() { GameObject go = NGUIEditorTools.SelectedRoot(true); if (go != null) { #if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 Undo.RegisterSceneUndo("Add a Sprite"); #endif UISprite sprite = NGUITools.AddWidget <UISprite>(go); sprite.name = "Sprite"; sprite.atlas = NGUISettings.atlas; if (sprite.atlas != null) { string sn = EditorPrefs.GetString("NGUI Sprite", ""); UISpriteData sp = sprite.atlas.GetSprite(sn); if (sp != null) { sprite.spriteName = sn; if (sp.hasBorder) { sprite.type = UISprite.Type.Sliced; } } } sprite.pivot = NGUISettings.pivot; sprite.width = 100; sprite.height = 100; sprite.MakePixelPerfect(); Selection.activeGameObject = sprite.gameObject; } else { Debug.Log("You must select a game object first."); } }
public void ShowDialog(int materialIndex) { base.transform.localPosition = Vector3.zero; ArsenalTaskManager._clsConstruct.dialogPopUp.Open(base.gameObject, 0f, 0f, 1f, 1f); this.SafeGetTweenAlpha(0f, 1f, 0.125f, 0f, UITweener.Method.Linear, UITweener.Style.Once, base.gameObject, "compShowDialog"); UISprite component = ((Component)base.transform.FindChild("Icon")).GetComponent <UISprite>(); UILabel component2 = ((Component)base.transform.FindChild("Label")).GetComponent <UILabel>(); component.spriteName = ArsenalTaskManager._clsConstruct._uiMaterialIcon[materialIndex].spriteName; component.MakePixelPerfect(); if (component.spriteName != "icon_item4") { component.transform.localPosition = Vector3.left * 40f + Vector3.up * 119f; component2.transform.localPosition = Vector3.right * 40f + Vector3.up * 119f; component2.spacingX = 7; if (component.spriteName == "icon_item1") { component2.text = "燃料"; } else if (component.spriteName == "icon_item2") { component2.text = "弾薬"; } else if (component.spriteName == "icon_item3") { component2.text = "鋼材"; } } else { component.transform.localPosition = Vector3.left * 110f + Vector3.up * 119f; component2.transform.localPosition = Vector3.right * 40f + Vector3.up * 119f; component2.spacingX = -1; component2.text = "ボ\u30fcキサイト"; } UpdateFrameSelect(); ArsenalTaskManager._clsConstruct.UpdateDialogMaterialCount(); }
public void SetCardTemplateID(int id) { if (TableManager.GetCardByID(id) == null || TableManager.GetAppearanceByID(TableManager.GetCardByID(id).Appearance) == null) { Debug.LogError("SetCardTemplateID(), no such template id: " + id); return; } AtlasManager.Instance.setBodyByTempletID(cardIcon, id); cardFrame.spriteName = UserCardItem.cardFrameName[TableManager.GetCardByID(id).Star]; cardFrame.MakePixelPerfect(); category.spriteName = UserCardItem.elementTypeName[TableManager.GetCardByID(id).Element]; category.MakePixelPerfect(); cardBorder.spriteName = UserCardItem.largeCardBorderName[TableManager.GetCardByID(id).Star]; cardBorder.MakePixelPerfect(); cardNameBg.spriteName = UserCardItem.largeCardNameBg[TableManager.GetCardByID(id).Star]; cardNameBg.MakePixelPerfect(); cardName.text = LanguageManger.GetWords(TableManager.GetAppearanceByID(TableManager.GetCardByID(id).Appearance).Name); }
public void ViewFriendshipStatus(int upFriendshipValue) { int num = upFriendshipValue; this.statusPart.spriteName = "Common02_Friendship"; this.statusPart.MakePixelPerfect(); int num2 = 1; foreach (char c in num.ToString()) { GameObject gameObject = new GameObject(); gameObject.transform.SetParent(this.statusPart.transform.parent); gameObject.transform.localScale = Vector3.one; GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(this.statusPart.gameObject); gameObject2.SetActive(true); gameObject2.transform.SetParent(gameObject.transform); UISprite component = gameObject2.GetComponent <UISprite>(); component.spriteName = "Common02_FriendshipN_" + c; component.MakePixelPerfect(); gameObject.transform.localPosition = new Vector3((float)this.statusPart.width - this.statusPart.transform.localPosition.x + (float)(component.width * num2), 0f, 0f); num2++; } }
public void Init(int pageCount) { this.pageCount = pageCount; Utils.DestoryChilds(gameObject); buttons = new UISprite[pageCount]; float width = 0; for (int i = 0; i < pageCount; i++) { UISprite us = NGUITools.AddChild <UISprite>(gameObject); us.atlas = atlas; us.spriteName = normalSpriteName; us.depth = spriteDepth; us.MakePixelPerfect(); if (width == 0) { width = (us.width + space) * pageCount - space; } float x = (us.width + space) * i - width / 2 + us.width / 2; us.transform.localPosition = new Vector3(x, 0, 0); buttons[i] = us; } }
void Update() { if (playing) { TimeSpan span = DateTime.Now - startTime; float delta = (float)(span.TotalMilliseconds / 1000); if (loop) { delta = delta % duration; } if (delta > duration) { delta = duration; playing = false; } currFrame = (int)(beginFrame + delta * frameRate); sprite.spriteName = spritePrefix + currFrame; if (makePixelPerfect) { sprite.MakePixelPerfect(); } } }
/// <summary> /// 设置扑克显示成扑克 /// </summary> public void SetCardFront() { SetSprite(); if (Id == 81 || Id == 97 || Id == 113) { Num.gameObject.SetActive(false); SmallColor.gameObject.SetActive(false); BigColor.gameObject.SetActive(false); } else { Num.gameObject.SetActive(true); SmallColor.gameObject.SetActive(true); BigColor.gameObject.SetActive(true); Num.spriteName = GetCardShowNumStr(); Num.MakePixelPerfect(); SmallColor.spriteName = "s_" + Colour + "_0"; SmallColor.MakePixelPerfect(); BigColor.spriteName = GetBigColorStr(); BigColor.MakePixelPerfect(); } }
protected override void OnFreshView() { base.OnFreshView(); var localData = Data as PludoGameResultItemData; if (localData != null) { IsSelf = localData.IsSelf; var score = localData.ScoreNum; RankSprite.TrySetComponentValue(string.Format(RankSpriteFormat, IdCode)); if (RankSprite) { RankSprite.MakePixelPerfect(); } IsWinner = score >= ConstantData.IntValue; StarNum.TrySetComponentValue(string.Format(StarScoreFormat, localData.FinishNum, localData.TotalFinishNum)); if (ScoreLabel) { ScoreLabel.UpdateView(YxUtiles.GetShowNumber(score)); } Player.UpdateView(localData.Info); } }
/// <summary> /// 设置警告遮罩 /// </summary> /// <param name="enable"></param> public void SetWarningMask(bool enable, bool circleStyle = false) { if (null != m_sp_warningMask && m_sp_warningMask.gameObject.activeSelf != enable) { m_sp_warningMask.gameObject.SetActive(enable); if (enable) { if (circleStyle) { m_sp_warningMask.spriteName = "biankuang_zhezhao_yuan"; m_sp_warningMask.type = UIBasicSprite.Type.Simple; m_sp_warningMask.MakePixelPerfect(); } else { m_sp_warningMask.spriteName = "biankuang_hongkuang"; m_sp_warningMask.type = UIBasicSprite.Type.Sliced; m_sp_warningMask.width = 80; m_sp_warningMask.height = 80; } } } }
public void Localize() { UIWidget component = GetComponent <UIWidget>(); UILabel uilabel = component as UILabel; UISprite uisprite = component as UISprite; if (mLanguage == SystemLanguage.Unknown && String.IsNullOrEmpty(loca_key) && uilabel != null) { loca_key = uilabel.text; } String text = (!String.IsNullOrEmpty(loca_key)) ? LocaManager.GetText(loca_key) : LocaManager.GetText(component.name); if (uilabel != null) { uilabel.text = text; } else if (uisprite != null) { uisprite.spriteName = text; uisprite.MakePixelPerfect(); } mLanguage = LocaManager.Language; }
public void freshDailyCell(MDDailyReward dr, int day, int curDay) { labGotNum.text = dr.got_num.ToString(); spRewardIcon.spriteName = dr.icon; spRewardIcon.MakePixelPerfect(); labDaily.text = dr.day; if (curDay > day) { spCanGet.ESetActive(true); spRewardIcon.color = Color.white; } else if (curDay == day) { spRewardIcon.color = Color.white; spCanGet.ESetActive(false); } else { spRewardIcon.color = Color.gray; spCanGet.ESetActive(false); } }
/// <summary> /// Convenience method -- add a sprite. /// </summary> static public UISprite AddSprite(GameObject go) { UISprite w = NGUITools.AddWidget <UISprite>(go); w.name = "Sprite"; w.atlas = atlas; w.spriteName = selectedSprite; if (w.atlas != null && !string.IsNullOrEmpty(w.spriteName)) { UISpriteData sp = w.atlas.GetSprite(w.spriteName); if (sp != null && sp.hasBorder) { w.type = UISprite.Type.Sliced; } } w.pivot = pivot; w.width = 100; w.height = 100; w.MakePixelPerfect(); return(w); }
public void SetItem(float angel, PrizeInfo data, ActivityBigWheelConfig config) { id = data.prizeId; objTran.transform.localPosition = Vector3.zero; objTran.localRotation = Quaternion.Euler(0, 0, angel); if (!data.type.Equals("nowinning")) { label_bet.gameObject.SetActive(true); label_bet.text = string.Format("x {0}", data.num); iconBG.gameObject.SetActive(true); iconBG.spriteName = config.iconUrl; iconBG.MakePixelPerfect(); labelName.text = string.Empty; } else { iconBG.gameObject.SetActive(false); label_bet.gameObject.SetActive(false); labelName.text = data.name; } label_bet.color = Color.red; }
public void SetData(DailyMustDoInfo _data) { CurMustDoInfo = _data; if (labName != null) { labName.text = "[u]" + _data.Name; } if (labDes != null) { labDes.text = _data.Des; } //if(labBtnReward != null)labBtnReward.text = _data.ButtonName; if (icon != null) { icon.spriteName = _data.IconName; icon.MakePixelPerfect(); } //if(itemReward != null)itemReward.FillInfo(_data.RewardItem); if (labFinishTimes != null) { labFinishTimes.enabled = (_data.TotalTimes != 0); labFinishTimes.text = _data.FinishTimes.ToString() + "/" + _data.TotalTimes.ToString(); } string str = ConfigMng.Instance.GetUItext(137); if (addLivelyNum != null) { addLivelyNum.text = str + "+" + _data.StaticLivelyCount.ToString(); addLivelyNum.enabled = !(_data.MustDoState == DailyMustDoInfo.RewardState.CANGET); } //if(btnReward != null)btnReward.isEnabled = (_data.MustDoState == DailyMustDoInfo.RewardState.CANGET); if (blackMask != null) { blackMask.SetActive(_data.MustDoState == DailyMustDoInfo.RewardState.CANGET); } //if(btnGo != null)btnGo.gameObject.SetActive(_data.UISort != 0); }
protected override GameObject createIconObj(int currentIconObjCount, int i) { Transform transform = base.get_transform().FindChild("ammo" + currentIconObjCount); GameObject gameObject; if (transform == null) { gameObject = base.InstantiateIconObj(); UISprite component = gameObject.get_transform().FindChild("IconObject/Icon").GetComponent <UISprite>(); component.get_transform().set_localEulerAngles(new Vector3(0f, 0f, (float)(Random.Range(0, 51) - 25))); component.spriteName = this.textureNames[Random.Range(0, this.textureNames.Length)]; component.MakePixelPerfect(); } else { gameObject = base.ResetSmoke(transform.get_gameObject()); } int num = (int)Math.Floor((double)currentIconObjCount / 7.0); int num2 = currentIconObjCount - 7 * num; int num3; if ((i >= 0 && i <= 1) || (i >= 6 && i <= 7)) { num3 = Random.Range(0, 6); } else { num3 = Random.Range(0, 16); } Vector3 localPosition = new Vector3((float)(45 - 15 * num2), (float)(205 - num3 + 5 * num)); gameObject.get_transform().set_localPosition(localPosition); int num4 = (int)Math.Floor((double)i / 7.0); base.SetIconAnimation(gameObject, i - 7 * num4); return(gameObject); }
/// <summary> /// Force-localize the widget. /// </summary> public void Localize() { Localization loc = Localization.instance; UIWidget w = GetComponent <UIWidget>(); UILabel lbl = w as UILabel; UISprite sp = w as UISprite; // If no localization key has been specified, use the label's text as the key if (string.IsNullOrEmpty(mLanguage) && string.IsNullOrEmpty(key) && lbl != null) { key = lbl.text; } // If we still don't have a key, leave the value as blank string val = string.IsNullOrEmpty(key) ? "" : loc.Get(key); if (lbl != null) { // If this is a label used by input, we should localize its default value instead UIInput input = NGUITools.FindInParents <UIInput>(lbl.gameObject); if (input != null && input.label == lbl) { input.defaultText = val; } else { lbl.text = val; } } else if (sp != null) { sp.spriteName = val; sp.MakePixelPerfect(); } mLanguage = loc.currentLanguage; }
void OnGetAtlas(IUIAtlas cmatlas, object param1, object param2, object param3) { if (null == cmatlas) { return; } UIAtlas atlas = cmatlas.GetAtlas(); if (null == atlas) { return; } if (null != param1 && param1 is UISprite) { UISprite sprite = (UISprite)param1; UIAtlas atl = (null != atlas) ? cmatlas.GetAtlas() : null; sprite.atlas = atl; if (null != param2 && param2 is string) { sprite.spriteName = (string)param2; } if (null != param3 && param3 is bool) { bool makePerfect = (bool)param3; if (null != sprite && makePerfect) { sprite.MakePixelPerfect(); } } } if (ani != null) { ani.RebuildSpriteList(); ani.Play(); } }
private void UpdateAllyIcon() { string iconName = "Null"; AllyType type = VATownGenerator.Instance.GetAllyType(m_AllianceID); int index = VATownGenerator.Instance.GetAllyNum(m_AllianceID); if (index >= 0) { switch (type) { case AllyType.Npc: case AllyType.Player: if (index < AllyIcon.HummanIcon.Length) { iconName = AllyIcon.HummanIcon[index]; } break; case AllyType.Puja: if (index < AllyIcon.PujaIcon.Length) { iconName = AllyIcon.PujaIcon[index]; } break; case AllyType.Paja: if (index < AllyIcon.PajaIcon.Length) { iconName = AllyIcon.PajaIcon[index]; } break; } } m_IconSpr.spriteName = iconName; m_IconSpr.MakePixelPerfect(); }
/// <summary> /// Advance the sprite animation process. /// </summary> void Update() { if (mActive && mSpriteNames.Count > 1 && Application.isPlaying && mFPS > 0f) { mDelta += Time.deltaTime; float rate = 1f / mFPS; if (rate < mDelta) { mDelta = (rate > 0f) ? mDelta - rate : 0f; if (++mIndex >= mSpriteNames.Count) { mIndex = 0; mActive = loop; } if (mActive) { mSprite.spriteName = mSpriteNames[mIndex]; mSprite.MakePixelPerfect(); } } } }
// ------------------------------------------------------------------ void RefreshIcon(DBFReward pReward) { pS_Icon.gameObject.SetActive(true); if (pReward.Reward == (int)ENUM_Reward.Looks) { pS_Icon.gameObject.SetActive(false); GameObject ObjHuman = UITool.pthis.CreateRole(G_Icon, pReward.Value); ToolKit.AddWeaponTo2DSprite(ObjHuman, ENUM_Weapon.Null, 15); ObjHuman.transform.localPosition = new Vector3(0, 90, 0); } else if (pReward.Reward == (int)ENUM_Reward.Currency) { pS_Icon.spriteName = "ui_027"; } else if (pReward.Reward == (int)ENUM_Reward.Battery) { pS_Icon.spriteName = "ui_com_001_full"; } else if (pReward.Reward == (int)ENUM_Reward.LightAmmo) { pS_Icon.spriteName = "ui_wpn_001"; } else if (pReward.Reward == (int)ENUM_Reward.HeavyAmmo) { pS_Icon.spriteName = "ui_wpn_002"; } else if (pReward.Reward == (int)ENUM_Reward.Bomb) { pS_Icon.spriteName = "ui_013"; } pS_Icon.MakePixelPerfect(); }
private void OnLocalize(Localization loc) { if (this.mLanguage != loc.currentLanguage) { UIWidget component = base.GetComponent <UIWidget>(); UILabel label = component as UILabel; UISprite sprite = component as UISprite; if ((string.IsNullOrEmpty(this.mLanguage) && string.IsNullOrEmpty(this.key)) && (label != null)) { this.key = label.text; } string str = !string.IsNullOrEmpty(this.key) ? loc.Get(this.key) : loc.Get(component.name); if (label != null) { label.text = str; } else if (sprite != null) { sprite.spriteName = str; sprite.MakePixelPerfect(); } this.mLanguage = loc.currentLanguage; } }
public void OnClick() { UISprite sprite = this.gameObject.GetComponent <UISprite>(); if (sprite.atlas) { GameObject captianobj = GameObject.Find("Upside/Left/Captain").gameObject; UISprite herosprite = captianobj.transform.FindChild("Sprite").GetComponent <UISprite>(); if (herosprite.atlas == null && sprite.atlas) { herosprite.atlas = Resources.Load("HeadPic/HeadPic", typeof(UIAtlas)) as UIAtlas; herosprite.spriteName = sprite.spriteName; herosprite.MakePixelPerfect(); sprite.atlas = null; // sprite.MakePixelPerfect(); } } else { return; } }
public void SetDamage(int num) { if (num == 0) { return; } SetBezier(_startPos, _endPos, _midPos); _numberSp.Clear(); gameObject.SetActive(true); _numberGrid.gameObject.SetActive(true); RED.RemoveChildsImmediate(_numberGrid.transform); string numstr = num > 0 ? "+" + num : num.ToString(); char[] numstrlist = numstr.ToCharArray(); string pr = num > 0 ? "g" : "r"; int j = 0; foreach (char i in numstrlist) { GameObject numObj = NGUITools.AddChild(_numberGrid.gameObject, GoHurtNum); UISprite item = numObj.GetComponent <UISprite> (); item.spriteName = pr + i.ToString(); item.MakePixelPerfect(); item.transform.localScale = Vector3.one * 2; _numberSp.Add(item); item.depth = 10; numObj.name = "0" + j.ToString(); j++; } _numberGrid.Reposition(); }
public override void initButton(int i) { if (nodeList [i] == null) { nodeList [i] = NGUITools.AddChild(gameObject, cardChooseWin.cardButtonPrefab); RoleView view = nodeList [i].GetComponent <RoleView> (); view.transform.localScale = new Vector3(0.9f, 0.9f, 1); view.init(cards [i] as Card, cardChooseWin, (roleView) => { OnButtonClick(roleView); }); if (view.tempGameObj == null) { UISprite us = NGUITools.AddChild <UISprite> (view.gameObject); us.depth = 50; us.atlas = view.qualityBg.atlas; us.spriteName = "gou_3"; us.MakePixelPerfect(); us.transform.localScale = new Vector3(2, 2, 1); us.gameObject.SetActive(resolveWin.isSelect(view.card)); view.tempGameObj = us.gameObject; } } }
/// <summary> /// 显示黑杰克 /// </summary> public void ShowBalckJackMark() { if (_playing) { return; } _playing = true; UISprite stateSprite = GetComponent <UISprite>(); stateSprite.spriteName = "blackjack"; stateSprite.alpha = 0; stateSprite.MakePixelPerfect(); stateSprite.transform.localScale = Vector3.one * 16; gameObject.SetActive(true); //设置游戏动画 TweenScale ts = GetComponent <TweenScale>() ?? gameObject.AddComponent <TweenScale>(); ts.from = Vector3.one * 4; ts.to = Vector3.one; ts.duration = BlackjackTime; ts.ResetToBeginning(); ts.PlayForward(); TweenPosition tp = GetComponent <TweenPosition>() ?? gameObject.AddComponent <TweenPosition>(); tp.from = new Vector3(0, 480, 0); tp.to = new Vector3(0, 140, 0); tp.duration = BlackjackTime; tp.ResetToBeginning(); tp.PlayForward(); TweenAlpha.Begin(gameObject, BlackjackTime, 1); }
void ShowMonster(Monster _data) { if (_data != null) { _Name.text = _data.config.name; AtlasMgr.mInstance.SetHeadSprite(_Head, _data.config.ID.ToString()); _Attr.gameObject.SetActive(true); int attr = (int)(_data.RTData.Attribute); m_StarNum = _data.Star; starsObj.SetStar(_data.Star); if (Core.Data.monManager.IsExpMon(_data.num)) { _Attr.spriteName = "common-1055"; _Circle.spriteName = "star6"; } else { _Circle.spriteName = "star" + _data.RTData.m_nAttr.ToString(); _Attr.spriteName = "Attribute_" + attr.ToString(); } _Attr.MakePixelPerfect(); } }
public void ShowMonster(Monster data) { AtlasMgr.mInstance.SetHeadSprite(m_spIcon, data.num.ToString()); m_spAttr.MakePixelPerfect(); m_star.SetStar(data.Star); int level = 1; if (data.RTData.curLevel <= 0) { level = 1; } else { level = data.RTData.curLevel; } m_txtLvl.text = "Lv" + level.ToString(); RED.SetActive(true, m_star.gameObject, m_spAttr.gameObject); m_spProp.spriteName = "Attribute_" + ((int)(data.RTData.Attribute)).ToString(); m_spBg.spriteName = "star" + ((int)(data.RTData.m_nAttr)).ToString(); }
// Used to position the sprite correctly within the item boundaries. In // general this does two things: centers the sprite vertically and adjusts // for the sprite padding. Not sure why the latter should be necessary, but... // it seems to be. Vector3 PositionSprite(Vector3 pos, UISprite sprite, float itemHeight, float scaleX, float scaleY) { pos.y -= (itemHeight - scaleY) * 0.5f; // <-- Center sprite vertically. /* Seems this is no longer needed in NGUI 3.0... * UIAtlas.Sprite sp = sprite.GetAtlasSprite(); float spX = sp.inner.xMin - sp.outer.xMin + sp.paddingLeft * scaleX; float spY = sp.inner.yMin - sp.outer.yMin + sp.paddingTop * scaleY; pos.x -= spX; pos.y += spY; /**/ sprite.cachedTransform.localPosition = pos; sprite.MakePixelPerfect(); return pos; }
protected override void AwakeImpl() { base.AwakeImpl(); if ( m_widget != null ) { sprite = m_widget.GetComponent<UISprite>(); if ( sprite != null ) { sprite.spriteName = m_spriteName; sprite.color = m_spriteColor; if ( m_AutoSize ) { sprite.MakePixelPerfect(); } } } }
/// <summary> /// Called on during creation /// </summary> public virtual void Start() { sprite = this.gameObject.GetComponent<UISprite>(); sprite.MakePixelPerfect(); }