public void init(GUIWorld ui) { this.ui = ui; sr = gameObject.AddComponent <SpriteRenderer> (); sr.sprite = GetSprite(); textObj = new GameObject("UI Text"); textObj.transform.parent = transform; textObj.transform.localPosition = new Vector3(0, 0, -0.5f); tm = textObj.AddComponent <TextMesh>(); tm.color = Color.black; tm.alignment = TextAlignment.Center; tm.anchor = TextAnchor.MiddleCenter; tm.fontSize = 148; tm.characterSize = 0.04f; tm.font = UIManager.font; tm.GetComponent <Renderer>().material = UIManager.font.material; tm.text = GetText(); coll = gameObject.AddComponent <PolygonCollider2D> (); coll.isTrigger = true; tooltip = new GameObject("UI Tooltip").AddComponent <UITooltip> (); tooltip.init(GetTooltip()); tooltip.transform.parent = transform; tooltip.gameObject.SetActive(false); }
public void init(GUIWorld ui) { this.ui = ui; this.gameObject.layer = LayerMask.NameToLayer("UI"); sr = gameObject.AddComponent <SpriteRenderer> (); sr.sprite = Resources.Load <Sprite> ("Sprites/UI/T_MainPanelNoIcons"); // HEALTH FEATURE hf = new GameObject("Health Feature").AddComponent <UIHealthFeature>(); hf.init(ui); hf.transform.parent = transform; hf.transform.localPosition = new Vector3(0, -0.3f, -1); hf.transform.localScale = new Vector3(0.75f, 0.75f, 1); // CARDS cards = new List <UICard> (); for (int i = 0; i < 5; i++) { UICard c = new GameObject("Card").AddComponent <UICard> (); c.init(ui, i); c.transform.localPosition = new Vector3(0, 1, 0); c.transform.parent = transform; cards.Add(c); } }
public void init(GUIWorld ui, int idx) { this.ui = ui; this.idx = idx; this.tag = "Card"; this.gameObject.layer = LayerMask.NameToLayer("CardLayer"); this.transform.localPosition = new Vector3(0, 0, -1); sr = gameObject.AddComponent <SpriteRenderer> (); sr.sprite = Resources.Load <Sprite> ("Sprites/UI/T_CardBaseHand"); sr.material = new Material(Shader.Find("Sprites/Default")); sr.color = Color.white; bc = gameObject.AddComponent <BoxCollider2D> (); bc.size = new Vector3(1.0f, 1.33f, 0); bc.isTrigger = true; textObj = new GameObject("Card Text"); textObj.transform.parent = transform; textObj.transform.localPosition = new Vector3(-0.40f, 0.5f, -0.1f); tm = textObj.AddComponent <TextMesh>(); tm.text = card.GetName(); tm.fontSize = 148; tm.characterSize = 0.008f; tm.color = Color.black; tm.font = UIManager.GetFont(); tm.GetComponent <Renderer>().material = UIManager.GetFont().material; var artObj = new GameObject("Card Art"); artObj.transform.parent = transform; artObj.transform.localPosition = new Vector3(-0.008f, 0.079f, -0.3f); artObj.transform.localScale = new Vector3(0.5561915f, 0.547473f, 0.5f); artSr = artObj.AddComponent <SpriteRenderer>(); }