private bool checkNeedExport(TransformInfo info) { if (info.needExport) { return(true); } if (!_treeMap.ContainsKey(info.luaName)) { return(false); } var list = _treeMap[info.luaName]; foreach (var item in list) { if (checkNeedExport(item)) { return(true); } } return(false); }
private Tuple <bool, string> WriteComponent(string parentClassName, TransformInfo info, bool parentIsSelf) { var list = info.transform.gameObject.GetComponents <Component>(); string className = info.luaName; bool hasExportNode = false; bool isSelf = true; string nodeName = null; parentClassName = ComponentNameHelper.changeFirstToSmall(parentClassName); if (parentIsSelf) { parentClassName = "self." + parentClassName; } foreach (var comp in list) { if (_componentMap.ContainsKey(comp.GetType().Name)) { string prefix = _componentMap[comp.GetType().Name]; DoWriteComponent(parentClassName, prefix + className, info.transform.gameObject.name, comp.GetType().Name, info.needExport); } if (_nodeMap.ContainsKey(comp.GetType().Name) && !hasExportNode) { string prefix = _nodeMap[comp.GetType().Name]; DoWriteComponent(parentClassName, prefix + className, info.transform.gameObject.name, info.needExport); hasExportNode = true; nodeName = prefix + className; } } if (!info.needExport && !hasExportNode) { isSelf = false; DoWriteComponent(parentClassName, ComponentNameHelper.changeFirstToSmall(className), info.transform.gameObject.name, info.needExport); } return(new Tuple <bool, string>(isSelf, nodeName)); }
private void DoTravel(string parentClassName, TransformInfo info, bool parentIsSelf = false) { if (!checkNeedExport(info)) { return; } var result = WriteComponent(parentClassName, info, parentIsSelf); if (!_treeMap.ContainsKey(info.luaName)) { return; } var list = _treeMap[info.luaName]; var className = result.Item2; if (className == null) { className = info.luaName; } foreach (var item in list) { DoTravel(className, item, result.Item1); } }