Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UISprite fg = NGUITools.Draw<UISprite>("fg", delegate(UISprite sp)
- {
- sp.depth = 1;
- sp.atlas = Resources.Load<UIAtlas>("UI/Atlas - Windward");
- sp.spriteName = "Flat";
- sp.type = UISprite.Type.Sliced;
- sp.color = new Color(0.25f, 1f, 0f, 1f);
- sp.pivot = UIWidget.Pivot.TopLeft;
- sp.SetAnchor(0.5f, -200,
- 0.8f, -10,
- 0.5f, 200,
- 0.8f, 10);
- UISprite bg = sp.gameObject.AddWidget<UISprite>(0);
- bg.atlas = sp.atlas;
- bg.spriteName = "Flat";
- bg.type = UISprite.Type.Sliced;
- bg.color = new Color(0.2f, 0.2f, 0.2f, 1f);
- bg.pivot = UIWidget.Pivot.TopLeft;
- bg.SetAnchor(0f, 0,
- 0f, 0,
- 1f, 0,
- 1f, 0);
- UILabel lbl = sp.gameObject.AddWidget<UILabel>(2);
- lbl.name = "Name";
- lbl.pivot = UIWidget.Pivot.BottomLeft;
- lbl.bitmapFont = Resources.Load<UIFont>("UI/Font - Qlassik22");
- lbl.fontSize = lbl.bitmapFont.defaultSize;
- lbl.effectStyle = UILabel.Effect.Shadow;
- lbl.gradientBottom = new Color(0.5f, 0.5f, 0.5f, 1f);
- lbl.SetAnchor(0f, 5,
- 1f, 2,
- 0f, sp.width - 10,
- 1f, 30);
- UISlider slider = sp.gameObject.AddComponent<UISlider>();
- slider.backgroundWidget = bg;
- slider.foregroundWidget = sp;
- });
- RuntimeBehaviour.Create().onUpdate = delegate(RuntimeBehaviour rb)
- {
- if (UILoadingScreen.isVisible) return;
- UISlider slider = fg.GetComponent<UISlider>();
- for (int i = 0; i < GameShip.list.size; ++i)
- {
- GameShip ship = GameShip.list[i];
- if (ship != null && ship.isActive && ship.bossTier == 4 && ship.factionID == 0)
- {
- slider.value = ship.health;
- Transform child = slider.transform.FindChild("Name");
- if (child != null)
- {
- UILabel lbl = child.GetComponent<UILabel>();
- if (lbl != null) lbl.text = ship.name;
- }
- return;
- }
- }
- UnityEngine.Object.Destroy(fg.gameObject);
- rb.onUpdate = null;
- };
Advertisement
Add Comment
Please, Sign In to add comment