public void OnResLoaded() { string layerName = mLayerName; if (string.IsNullOrEmpty(layerName) == true) { layerName = "InterObject"; } int parentLayer = LayerMask.NameToLayer("InterObject"); int layer = LayerMask.NameToLayer(layerName); Transform trans = this.transform; for (int i = 0; i < trans.childCount; ++i) { Transform child = trans.GetChild(i); child.gameObject.layer = parentLayer; UGUITools.SetChildLayer(child, layer); } Collider collider = gameObject.GetComponentInChildren <Collider>(); if (collider != null) { collider.isTrigger = true; } }