static void _ConvertBoxCollider2Dto3D(GameObject o) { o.layer = GK.LayerId("UI"); var rb = o.GetComponent <Rigidbody>(); if (rb) { GK.Destroy(rb); } var co = o.GetComponent <BoxCollider2D>(); if (co) { Vector4 v4 = new Vector4(co.size.x, co.size.y, co.offset.x, co.offset.y); GK.Destroy(co); o.AddComponent <BoxCollider>(); o.GetComponent <BoxCollider>().size = new Vector3(v4.x, v4.y, 1); o.GetComponent <BoxCollider>().center = new Vector3(v4.z, v4.w, 1); } foreach (Transform t in o.transform) { _ConvertBoxCollider2Dto3D(t.gameObject); } }
// Create UI node. static public GameObject CreateNode(string name, GameObject parent, string layerName) { GameObject go = new GameObject(name); GK.SetParent(go, parent, false); go.layer = GK.LayerId(layerName); return(go); }
public GameObject GetOrAddGroup(string name) { var o = GK.FindChild(gameObject, name, true, false); if (!o) { o = new GameObject(name); GK.SetParent(o, gameObject, false); o.layer = GK.LayerId("UI"); } return(o); }