def ScanPrefabFile(self, dir, filejson): if not os.path.exists(dir): return listFile = [] dirsave = FileUtil.GetLastDirofDir(filejson) FileUtil.CreateDir((dirsave)) FileUtil.GetFileList(dir, "prefab", listFile) dataRoot = json.loads("{}") # "BtnIconPlay" : { # "path" : "App/UI/Common/Button/BtnIconPlay.png" # }, for fileimage in listFile: # item= json.loads("{}") filepath = fileimage.replace( mainResource.GetRootUnityAssets() + "/", "") # item["path"]=filepath name = FileUtil.GetPathNameWithoutExt(fileimage) dataRoot[name] = filepath json_str = json.dumps(dataRoot, ensure_ascii=False, indent=4, sort_keys=True) FileUtil.SaveString2File(json_str, filejson)
def ConfigiOSAdkitCode(self,source_ad): dirRoot = mainResource.GetRootUnityAssets()+"/Plugins/iOS" dirCodeAdkitPlatform = dirRoot+"/Common/AdKit/Platform" FileUtil.RemoveDir(dirCodeAdkitPlatform+"/"+source_ad) if not self.IsNoIDFASDK(): zipfile = dirCodeAdkitPlatform+"/"+source_ad+".zip" ZipUtil.un_zip(zipfile,dirCodeAdkitPlatform)
def SaveCommonScript(self): listname = {"AppBase", "Common"} for name in listname: src = mainResource.GetRootUnityAssets()+"/Script/"+name dst = mainResource.GetDirProductCommon()+"/ProjectUnity/Assets/Script/"+name print(src) print(dst) FileUtil.CopyDir(src, dst)
def ScanImageFile(self, dir, filejson): # if not os.path.exists(dir): # return listFile = [] if os.path.exists(dir): FileUtil.GetFileList(dir, "png", listFile) FileUtil.GetFileList(dir, "jpg", listFile) print("listFile len=" + str(len(listFile))) dataRootOld = None if os.path.exists(filejson) == True: print("filejson = " + filejson) strfile = FileUtil.GetFileString(filejson) # print("strfile = "+strfile) dataRootOld = json.loads(strfile) if dataRootOld is None: print("dataRootOld is none") print("strfile = " + strfile) # remove os.remove(filejson) dataRoot = json.loads("{}") # "BtnIconPlay" : { # "path" : "App/UI/Common/Button/BtnIconPlay.png" # }, for fileimage in listFile: item = json.loads("{}") filepath = fileimage.replace( mainResource.GetRootUnityAssets() + "/", "") filepath = filepath.replace(self.dirCloudResHead, "") item["path"] = filepath name = FileUtil.GetPathNameWithoutExt(fileimage) # 从原来的json中恢复board if dataRootOld is not None: # print("dataRootOld is not none") if name in dataRootOld: # print("dataRootOld name="+name) dataitem = dataRootOld[name] key = "board" # key = "path" # if name =="BtnCommon": # # key = "board" # print("dataitem[key] = "+dataitem[key]+" name="+name) if key in dataitem: print("key = " + key + " name=" + name) item[key] = dataitem[key] dataRoot[name] = item json_str = json.dumps(dataRoot, ensure_ascii=False, indent=4, sort_keys=True) FileUtil.SaveString2File(json_str, filejson)
def ConfigiOSLib(self,source_lib): dirRoot = mainResource.GetRootUnityAssets()+"/Plugins/iOS" dirLib = dirRoot+"/ThirdParty" FileUtil.RemoveDir(dirLib+"/"+source_lib) if not self.IsNoIDFASDK(): zipfile = dirLib+"/"+source_lib+".zip" ZipUtil.un_zip(zipfile,dirLib) self.DeleteMACOSX(dirLib)
def CopyPlugins(self): dirname = "Plugins" dir1 = mainResource.GetDirProductCommon()+"/"+dirname dir2 = mainResource.GetRootUnityAssets()+"/"+dirname flag = os.path.exists(dir2) if not flag: # shutil.rmtree(dir2) shutil.copytree(dir1,dir2) self.ConfigiOSPluginsCode()
def ConfigiOSPluginsCode(self): dirRoot = mainResource.GetRootUnityAssets()+"/Plugins/iOS" dirCodeCommon = dirRoot+"/Common" dirCodeAdkit = dirRoot+"/Common/AdKit" # tongji FileUtil.RemoveDir(dirCodeCommon+"/Tongji") zipfile = dirCodeCommon+"/Tongji.zip" if self.IsNoIDFASDK(): zipfile = dirCodeCommon+"/Tongji_NoSDK.zip" flag = os.path.exists(zipfile) if flag: ZipUtil.un_zip(zipfile,dirCodeCommon) # share FileUtil.RemoveDir(dirCodeCommon+"/Share") zipfile = dirCodeCommon+"/Share.zip" if self.IsNoIDFASDK(): zipfile = dirCodeCommon+"/Share_NoSDK.zip" flag = os.path.exists(zipfile) if flag: ZipUtil.un_zip(zipfile,dirCodeCommon) # adconfig FileUtil.RemoveDir(dirCodeAdkit+"/AdConfig") zipfile = dirCodeAdkit+"/AdConfig.zip" if self.IsNoIDFASDK(): zipfile = dirCodeAdkit+"/AdConfig_NoSDK.zip" flag = os.path.exists(zipfile) if flag: ZipUtil.un_zip(zipfile,dirCodeAdkit) # adkit self.ConfigiOSLib(Source.GDT) self.ConfigiOSLib(Source.BAIDU) self.ConfigiOSLib(Source.ADMOB) self.ConfigiOSLib(Source.CHSJ) self.ConfigiOSLib(Source.UNITY) self.ConfigiOSLib(Source.UMENG) self.ConfigiOSAdkitCode(Source.GDT) self.ConfigiOSAdkitCode(Source.BAIDU) self.ConfigiOSAdkitCode(Source.ADMOB) self.ConfigiOSAdkitCode(Source.CHSJ) self.ConfigiOSAdkitCode(Source.UNITY)
def MakeCodeDoc(self, isHd): title = mainAppInfo.GetAppName(Source.ANDROID, isHd, Source.LANGUAGE_CN) + "V1.0.0" codedir = "/Users/moon/sourcecode/LearnWord" codedir = mainResource.GetRootUnityAssets( ) + "/Script/Apps/" + mainResource.getGameType() # codedir = mainResource.GetRootUnityAssets()+"/Script/Apps/"+mainResource.getGameType()+"/Base" outputdir = mainResource.GetProjectOutPutApp() FileUtil.CreateDir(outputdir) docoutput = outputdir + "/" + mainResource.getGameType() + ".docx" if isHd: docoutput = outputdir + "/" + mainResource.getGameType( ) + "_HD.docx" os.system("pyerz -e cs -i " + codedir + " -o " + docoutput + " -t " + title) self.WordToPdf(docoutput)