private static void LoadResourceToViewLayer(string viewPath, UIViewLayer viewLayer, Action <GameObject> callback) { ResourcesDatabase.Load(viewPath, _object => { GameObject viewGo = GameObject.Instantiate(_object) as GameObject; RectTransform rectTrans = viewGo.GetComponent <RectTransform>(); rectTrans.SetParent(canvasGo.transform.Find(viewLayer.ToString()), false); callback(viewGo); }); }
private static UIBaseWidget FindWidgetInLayers(UIViewLayer viewLayer, Type type) { Transform layerRect = canvasGo.transform.Find(viewLayer.ToString()); if (layerRect) { for (int i = 0; i < layerRect.childCount; i++) { Transform childRect = layerRect.GetChild(i); Component component = childRect.GetComponent(type); if (component) { return(component.GetComponent <UIBaseWidget>()); } } } return(null); }