static public Transform CloneUI(Transform t) { GameObject obj = GameObject.Instantiate(t.gameObject) as GameObject; obj.transform.SetParent(t.parent); obj.transform.localScale = t.localScale; obj.transform.localPosition = t.localPosition; obj.layer = t.gameObject.layer; OnClickInt f = obj.GetComponent <OnClickInt> (); if (f != null) { f.enabled = false; } OnDragInt f2 = obj.GetComponent <OnDragInt> (); if (f2 != null) { f2.enabled = false; } return(obj.transform); }
static public void SetPaiEx(Transform t, int type) { if (t != null) { Transform child; if (t.childCount > 0) { child = t.GetChild(0); } else { Image img = t.GetComponent <Image> (); string key = img.sprite.name.Substring(0, 3); GameObject obj = GameObject.Instantiate(t.gameObject); obj.transform.SetParent(t); child = obj.transform; RectTransform rt = t as RectTransform; RectTransform rtChild = child as RectTransform; child.localScale = Vector3.one; float d = rt.sizeDelta.x / img.sprite.texture.width; rtChild.sizeDelta = new Vector2(d * 31 * 1.1f, d * 35 * 1.1f); Image childImg = child.GetComponent <Image> (); childImg.color = new Color32(255, 255, 255, 200); childImg.raycastTarget = false; OnClickInt cnClick = child.GetComponent <OnClickInt> (); if (cnClick != null) { cnClick.enabled = false; } if (key == "p4b") { child.localPosition = new Vector3(-20, 15, 0) * d; child.localEulerAngles = new Vector3(0, 0, 0); } else if (key == "p4s") { child.localPosition = new Vector3(-20, 45, 0) * d; child.localEulerAngles = new Vector3(30, 0, 0); } else if (key == "p1s") { child.localPosition = new Vector3(-14, 4, 0) * d; child.localEulerAngles = new Vector3(30, 0, 90); child.localScale *= 0.5f; } else if (key == "p2s") { child.localPosition = new Vector3(-20, 45, 0) * d; child.localEulerAngles = new Vector3(30, 0, 00); } else if (key == "p3s") { child.localPosition = new Vector3(14, 12, 0) * d; child.localEulerAngles = new Vector3(30, 0, 270); child.localScale *= 0.5f; } else { type = 4; } } if (type == 1) { child.gameObject.SetActive(true); SetImage(child, "lai"); } else if (type == 2) { child.gameObject.SetActive(true); SetImage(child, "pi"); } else { child.gameObject.SetActive(false); } } }