// Use this for initialization public void Init() { GameObject GameInfo = GameObject.Find("GameInfo"); if (GameInfo == null) { Invoke("Start", 0.5f); return; } SkillInfo SkillThis = GameInfo.GetComponent <GameInfo> ().SkillList [SkillNum]; Name = SkillThis.Name; Description = SkillThis.Description; GoldRequire = SkillThis.GoldRequire; Unlocked = SkillThis.Unlocked; Used = SkillThis.Used; if (Name_UI == null) { Name_UI = (GameObject)Instantiate(UI_Text_Black, transform.position, Quaternion.identity); Name_UI.transform.SetParent(GameObject.Find("Canvas").transform); Name_UI.GetComponent <Text> ().text = Name; Name_UI.transform.localPosition = Camera.main.WorldToScreenPoint(transform.position) - new Vector3(Screen.width / 2, Screen.height / 2, 0); Name_UI.transform.localPosition = Camera.main.WorldToScreenPoint(transform.position) - new Vector3(Screen.width / 2, Screen.height / 2, 0); } if (Description_UI == null) { Description_UI = (GameObject)Instantiate(UI_Text_White, transform.position, Quaternion.identity); Description_UI.transform.SetParent(GameObject.Find("Canvas").transform); Description_UI.GetComponent <Text> ().text = Description; Vector3 offsetColor = new Vector3(55, 0, 0); Description_UI.transform.localPosition = Camera.main.WorldToScreenPoint(transform.position) - new Vector3(Screen.width / 2, Screen.height / 2, 0) + offsetColor; Description_UI.transform.localPosition = Camera.main.WorldToScreenPoint(transform.position) - new Vector3(Screen.width / 2, Screen.height / 2, 0) + offsetColor; if (Unlocked == false) { Description_UI.GetComponent <Text> ().text += "(花费" + GoldRequire.ToString() + "解锁)"; } } if (Used) { gameObject.GetComponent <SpriteRenderer>().sprite = images[1]; } else { gameObject.GetComponent <SpriteRenderer>().sprite = images[0]; } if (Unlocked) { Color a = new Color(255f / 255f, 255f / 255f, 255f / 255f, 1f); gameObject.GetComponent <SpriteRenderer> ().color = a; } else { Color a = new Color(141f / 255f, 141f / 255f, 141f / 255f, 1f); gameObject.GetComponent <SpriteRenderer> ().color = a; } }
public void Init(string name, string description) { Name_UI = (GameObject)Instantiate(UI_Text, transform.position, Quaternion.identity); Name_UI.transform.SetParent(GameObject.Find("Canvas").transform); Name_UI.transform.localPosition = Camera.main.WorldToScreenPoint(transform.position) - new Vector3(Screen.width / 2, Screen.height / 2, 0); Name_UI.GetComponent <Text> ().text = name; Vector3 offsetColor = new Vector3(20, 55, 0); Description_UI = (GameObject)Instantiate(UI_Text, transform.position, Quaternion.identity); Description_UI.transform.SetParent(GameObject.Find("Canvas").transform); Description_UI.transform.localPosition = Camera.main.WorldToScreenPoint(transform.position) - new Vector3(Screen.width / 2, Screen.height / 2, 0) + offsetColor; Description_UI.GetComponent <Text> ().text = description; Description_UI.SetActive(false); }
void OnMouseExit() { // Debug.Log("鼠标离开该模型区域时"); Description_UI.SetActive(false); }
void OnMouseEnter() { // Debug.Log("鼠标进入该对象区域时"); Description_UI.SetActive(true); }