private static void ProcessUIPrefab(GameObject gameObject) { if (null == gameObject) { return; } if (gameObject.CompareTag(Constants.UIViewTag)) { UICollection = gameObject.AddSingleComponent <UIComponentCollection>(); UICollection.Clear(); } foreach (Transform transform in gameObject.transform) { if (transform.CompareTag(Constants.UIIgnoreTag)) { continue; } ProcessUIPrefab(transform.gameObject); bool isHandled = false; foreach (var type in ExportComponentTypes) { var UIComp = transform.GetComponent(type); if (null != UIComp) { UIComponentIndex++; UICollection.Add(UIComp); var componentName = "m_" + transform.name; uiExportElementDic[componentName] = UIComponentIndex; isHandled = true; break; } } if (isHandled) { continue; } foreach (var type in ExportPropertyTypes) { var UIComp = transform.GetComponent(type); if (null != UIComp && transform.CompareTag(Constants.UIPropertyTag)) { UIComponentIndex++; UICollection.Add(UIComp); var componentName = "m_" + transform.name; uiExportElementDic[componentName] = UIComponentIndex; isHandled = true; break; } } } }
private static void ProcessUIPrefab(GameObject gameObject) { if (null == gameObject) { return; } if (gameObject.CompareTag(Constants.UIViewTag)) { UICollection = gameObject.AddSingleComponent <UIComponentCollection>(); UICollection.Clear(); } foreach (Transform transform in gameObject.transform) { if (transform.CompareTag(Constants.UIIgnoreTag)) { continue; } //处理UITableview if (transform.GetComponent <UITableViewCell>() != null) { var info = new ExportInfo(); nestExportInfoList.Add(info); var uiTableview = transform.gameObject.GetComponentInParent <UITableView>(); info.name = "m_" + uiTableview.transform.name; var collection = transform.gameObject.AddSingleComponent <UIComponentCollection>(); collection.Clear(); info.uicollection = collection; ProceseUITableview(transform.gameObject, info); } else { ProcessUIPrefab(transform.gameObject); } bool isHandled = false; foreach (var type in ExportComponentTypes) { var UIComp = transform.GetComponent(type); if (null != UIComp) { UIComponentIndex++; UICollection.Add(UIComp); var componentName = "m_" + transform.name; uiExportElementDic[componentName] = UIComponentIndex; isHandled = true; break; } } if (isHandled) { continue; } foreach (var type in ExportPropertyTypes) { var UIComp = transform.GetComponent(type); if (null != UIComp && transform.CompareTag(Constants.UIPropertyTag)) { UIComponentIndex++; UICollection.Add(UIComp); var componentName = "m_" + transform.name; uiExportElementDic[componentName] = UIComponentIndex; isHandled = true; break; } } } }