public void GenData(IDataReadable reader, string outputPath = null) { IDataReadable exReader = reader; XDocument xDoc = new XDocument(); XElement root = new XElement("Root"); xDoc.Add(root); List <Dictionary <string, string> > rows = exReader.GetRows(); for (int i = 0; i < rows.Count; i++) { XElement item = new XElement("item"); root.Add(item); foreach (KeyValuePair <string, string> pair in rows[i]) { item.Add(new XElement(pair.Key, pair.Value)); } } if (outputPath == null) { outputPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Xml) + Path.GetFileNameWithoutExtension(reader.currentDataTypeName) + XmlData.m_fileExtention; } if (!Directory.Exists(Path.GetDirectoryName(outputPath))) { Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); } xDoc.Save(outputPath); AssetDatabase.Refresh(); }
public void GenCS(IDataReadable reader) { string className = reader.currentDataTypeName; CodeGener protobufBaseGener = new CodeGener(ProtobufData.nameSpace, className); protobufBaseGener.newClass.AddMemberCostomAttribute("ProtoBuf.ProtoContract"); protobufBaseGener.AddImport("System", "ProtoBuf"); List <string> comment = reader.GetComment(); protobufBaseGener .AddBaseType("ProtobufData<" + className + ">") .AddMemberField(typeof(string), "fileName", (member) => { member.AddFieldMemberInit("\"" + className + "\""); }, System.CodeDom.MemberAttributes.Static | System.CodeDom.MemberAttributes.Final | System.CodeDom.MemberAttributes.Public); reader.GetTitle().ForEach((i, title) => { string[] titleSplit = title.Split('|'); string varName = titleSplit[0]; string typeName = titleSplit[1]; protobufBaseGener.AddMemberProperty(typeName.GetTypeByString(), varName, (member) => { member.AddComment(comment[i], true); member.AddMemberCostomAttribute("ProtoBuf.ProtoMember", (i + 1).ToString()); }); }); PathEx.MakeFileDirectoryExist(PathConfig.GetLoaclGameDataClassPath(PathConfig.DataType.Protobuf)); protobufBaseGener.GenCSharp(PathConfig.GetLoaclGameDataClassPath(PathConfig.DataType.Protobuf)); }
private void ShowExportTools() { GUILayout.Label("文件导出工具"); if (GUILayout.Button("将文件导出到本地服务器", GUILayout.Width(200))) { string localBundleResourcesFolder = PathConfig.GetLocalBundleResourcesFolderByVersion(resVersion); if (Directory.Exists(localBundleResourcesFolder)) { Directory.Delete(localBundleResourcesFolder, true); } DirectoryEx.DirectoryCopy(PathConfig.GetExportPathByVersion(resVersion), localBundleResourcesFolder, true); string[] versionResFolderList = Directory.GetDirectories(PathConfig.localUpdateBundleUrl); XDocument xDoc = new XDocument(); XElement root = new XElement("Root"); xDoc.Add(root); foreach (string path in versionResFolderList) { string versionFolder = Path.GetFileName(path.Replace("\\", "/")); root.Add(new XElement("version", versionFolder)); } xDoc.SafeSaveWithoutDeclaration(PathConfig.localVersionInfoUrl); } }
private void OnEnable() { dataPath = Application.dataPath.Replace("\\", "/"); singlePathConfig = new PathConfig(dataPath, "SingleExcelPathPrefsKey", "SingleScriptPathPrefsKey", "SingleDbPathPrefsKey"); multiPathConfig = new PathConfig(dataPath, "MultiExcelPathPrefsKey", "MultiScriptPathPrefsKey", "MultiDbPathPrefsKey"); selectPrefsKey = "SingleOrMultiSelectPrefsKey"; isSingleFile = preSelect = EditorPrefs.GetBool(selectPrefsKey, true); centerTittleStyle = new GUIStyle(); centerTittleStyle.fontStyle = FontStyle.Bold; centerTittleStyle.alignment = TextAnchor.MiddleCenter; centerTittleStyle.normal = new GUIStyleState(); centerTittleStyle.normal.textColor = EditorGUIUtility.isProSkin ? new Color(.7f, .7f, .7f) : Color.black; leftTittleStyle = new GUIStyle(); leftTittleStyle.fontStyle = FontStyle.Bold; leftTittleStyle.alignment = TextAnchor.MiddleLeft; leftTittleStyle.normal = new GUIStyleState(); leftTittleStyle.normal.textColor = EditorGUIUtility.isProSkin ? new Color(.7f, .7f, .7f) : Color.black; btnStyle = new GUIStyle(); btnStyle.alignment = TextAnchor.MiddleCenter; }
void OnEnable() { //_target = (VesselsInstantiator)target; _objects = Resources.LoadAll("Vessels", typeof(GameObject)).ToList(); _vesselsSaved = (VesselsSaved)Resources.Load("VesselsConfig"); if (_vesselsSaved == null) { ScriptableObjectsCreator.CreateVesselsConfig(); _vesselsSaved = (VesselsSaved)Resources.Load("VesselsConfig"); } EditorUtility.SetDirty(_vesselsSaved); _pathsSaved = (PathConfig)Resources.Load("PathConfig"); if (_pathsSaved == null) { ScriptableObjectsCreator.CreatePathConfig(); _pathsSaved = (PathConfig)Resources.Load("PathConfig"); } editModeStyle.fontSize = 20; insideVesselLimitStyle.fontSize = 20; }
//获取每个版本包的信息 private VersionData DownloadVersionData(Version version) { //下载版本信息 infoAct("Download VersionInfo " + version.ToString()); string versionDataPath = Path.Combine(PathConfig.GetBundleResourcesFolderByVersion(version), PathConfig.VersionDataName + ".xml"); string versionData = DownloadManager.instance.DownLoadText(versionDataPath, errorAct); if (versionData == null) { infoAct("Download VersionInfo Fail"); Debug.logger.LogError("Download Fail", "Download VersionInfo Fail"); return(null); } VersionData data = VersionData.ParseXml(XDocument.Parse(versionData)); //检查应用版本信息 if (!CheckAppVersion(data)) { infoAct("You need update your app"); appUpdateAct(data.appVersion); return(null); } return(data); }
void OnEnable() { _target = (Seed)target; _target.gameObject.tag = "Seed"; pathsSaved = (PathConfig)Resources.Load("PathConfig"); if (pathsSaved == null) { ScriptableObjectsCreator.CreatePathConfig(); pathsSaved = (PathConfig)Resources.Load("PathConfig"); } _sceneButtonsConfig = (SceneButtonsConfig)Resources.Load("SceneButtonsConfig"); if (_sceneButtonsConfig == null) { ScriptableObjectsCreator.CreateSceneButtonsConfig(); _sceneButtonsConfig = (SceneButtonsConfig)Resources.Load("SceneButtonsConfig"); } EditorUtility.SetDirty(_sceneButtonsConfig); ConfigurateButtonsByDefault(); pathsSaved.objectsToInstantiate.Clear(); ConfigurateObjects(); }
public override bool IsMatch(string path) { bool pathMatch = PathConfig.IsTexture(path) && base.IsMatch(path); if (!pathMatch) { return(false); } TextureImporter texureImporter = AssetImporter.GetAtPath(path) as TextureImporter; #pragma warning disable 0618 if (TexType == TextureImporterType.Cubemap) { #pragma warning restore 0618 if (texureImporter.textureShape != TextureImporterShape.TextureCube) { return(false); } else { return(true); } } else { if (texureImporter.textureShape == TextureImporterShape.TextureCube) { return(false); } } return(texureImporter.textureType == TexType); }
public static void GenPref(ExcelReader excelReader, string outputPath = null) { ExcelReader exReader = excelReader; XDocument xDoc = new XDocument(); XElement root = new XElement("Root"); xDoc.Add(root); List <string> name = exReader.GetMemberNames(); List <string> value = exReader.GetLine(2); for (int i = 0; i < name.Count; i++) { XElement item = new XElement(name[i], value[i]); root.Add(item); } if (outputPath == null) { outputPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Pref) + Path.GetFileNameWithoutExtension(excelReader.currentSheetName) + PrefData.m_fileExtention; } if (!Directory.Exists(Path.GetDirectoryName(outputPath))) { Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); } xDoc.Save(outputPath); AssetDatabase.Refresh(); }
public Program(ISecretStorage secretStorage, IAccessTokenSerializer accessTokenSerializer, IPasswordGenerator passwordGenerator, IOptions <PathConfig> pathConfig) { _secretStorage = secretStorage; _accessTokenSerializer = accessTokenSerializer; _passwordGenerator = passwordGenerator; _pathConfig = pathConfig.Value; }
public Dictionary <int, T> FormatData(string fileName) { TextAsset asset = Resources.Load <TextAsset>(PathConfig.GetLocalGameDataResourcesPath(PathConfig.DataType.Protobuf) + fileName); if (asset == null) { Debug.logger.LogError("Load Assets", "Cant find the file:" + fileName); return(null); } MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(asset.text)); Dictionary <int, T> resDict = new Dictionary <int, T>(); //Type listType = typeof(List<T>); List <T> resList = ProtoBuf.Serializer.Deserialize <List <T> >(ms); int listCount = resList.Count; for (int i = 0; i < listCount; i++) { resDict.Add(i + 1, resList[i]); } return(resDict); }
//加载Json public static bool LoadIntMap(string fileName, out Dictionary <int, Dictionary <string, string> > dicFromXml, string rootPath = null) { TextAsset textAsset = null; dicFromXml = new Dictionary <int, Dictionary <string, string> >(); if (rootPath == null) { textAsset = Resources.Load <TextAsset>(PathConfig.GetLocalGameDataResourcesPath(PathConfig.DataType.Json) + fileName); } else { textAsset = Resources.Load <TextAsset>(Path.Combine(rootPath, fileName).Replace("\\", "/")); } if (textAsset == null) { Debug.logger.LogError("XMLParser", fileName + " 文本加载失败"); } JsonData data = JsonMapper.ToObject(textAsset.text); List <Dictionary <string, string> > strList = JsonMapper.ToObject <List <Dictionary <string, string> > >(data[fileName].ToJson()); for (int i = 0; i < strList.Count; i++) { dicFromXml.Add(i + 1, strList[i]); } return(true); }
internal App() { MainViewModel = new ScavengerViewModel { ServiceStatus = false, PathConfig = PathConfig.GetPathsConfigModel() }; }
private static void GetPropString(string className, Type baseType, string path) { importNameSpaces = new string[] { "System", "System.Collections.Generic", "UnityEngine" }; DataClassesGener.className = className; baseClassName = baseType.Name + "<" + className + ">"; if (baseType == typeof(XmlData)) { nameSpace = XmlData.nameSpace; string classPath = PathConfig.GetLoaclGameDataClassPath(PathConfig.DataType.Xml); if (!Directory.Exists(classPath)) { Directory.CreateDirectory(classPath); } outputFile = classPath + className + ".cs"; } else if (baseType == typeof(ObjData)) { nameSpace = ObjData.nameSpace; string classPath = PathConfig.GetLoaclGameDataClassPath(PathConfig.DataType.Obj); if (!Directory.Exists(classPath)) { Directory.CreateDirectory(classPath); } outputFile = classPath + className + ".cs"; } else if (baseType == typeof(PrefData)) { nameSpace = PrefData.nameSpace; string prefDataClassPath = PathConfig.GetLoaclGameDataClassPath(PathConfig.DataType.Pref); if (!Directory.Exists(prefDataClassPath)) { Directory.CreateDirectory(prefDataClassPath); } outputFile = prefDataClassPath + className + ".cs"; } else if (baseType == typeof(JsonData)) { nameSpace = JsonData.nameSpace; string jsonDataClassPath = PathConfig.GetLoaclGameDataClassPath(PathConfig.DataType.Json); if (!Directory.Exists(jsonDataClassPath)) { Directory.CreateDirectory(jsonDataClassPath); } outputFile = jsonDataClassPath + className + ".cs"; } else { Debug.logger.LogError("GameData", "无效的数据类型"); } //自定义Path if (path != null) { outputFile = path; } }
static void CommitList(List <string> keyList) { Init(); foreach (string key in keyList) { PathConfig config = _configs[key]; Commit(config); } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (base.LoginUser == null) { filterContext.Result = new RedirectResult("/AdminLogin"); } HTools.CacheObj obj = base.cacheService.Get(Constant.CacheKey.PowerConfigCacheKey); if (obj != null && obj.value != null) { if (obj.value is Newtonsoft.Json.Linq.JObject) { PowerAdmin power = obj.value.ParseJSON <PowerAdmin>(); this.Power = power; } else { this.Power = (PowerAdmin)obj.value; } } else { this.Power = null; } if (this.Power == null) { this.Power = powerConfigService.LoadConfig(Constant.PowerConfigPath); base.cacheService.Add(Constant.CacheKey.PowerConfigCacheKey, new HTools.CacheObj() { value = this.Power, AbsoluteExpiration = new TimeSpan(1, 0, 0, 0) }); } if (this.pathConfig == null) { this.pathConfig = pathConfigService.LoadConfig(Constant.PathConfigPath); base.cacheService.Add(Constant.CacheKey.PathConfigCacheKey, new HTools.CacheObj() { value = this.pathConfig, AbsoluteExpiration = new TimeSpan(1, 0, 0, 0) }); } if (this.pathConfig != null) { ViewData["_PathConfig"] = this.pathConfig; } if (base.LoginUser != null) { ViewData["_LoginUser"] = base.LoginUser; } if (this.Power != null) { ViewData["_Power"] = this.Power; } }
public void GenData(IDataReadable reader, string outputPath = null) { string className = reader.currentDataTypeName; Type protobufDataType = Type.GetType(ProtobufData.nameSpace + "." + className + ",Assembly-CSharp"); //Debug.Log(ProtobufData.nameSpace + "." + className + ",Assembly-CSharp" + " 是否存在" + protobufDataType.ToString()); if (protobufDataType == null) { GenCS(reader); protobufDataType = Type.GetType(ProtobufData.nameSpace + "." + className + ",Assembly-CSharp"); Debug.unityLogger.Log("Gen the CS File Please"); } List <Dictionary <string, object> > rowObjs = reader.GetRowObjs(); List <object> result = new List <object>(); for (int i = 0; i < rowObjs.Count; i++) { object item = Activator.CreateInstance(protobufDataType); PropertyInfo[] propertys = protobufDataType.GetProperties(); foreach (KeyValuePair <string, object> pair in rowObjs[i]) { PropertyInfo prop = propertys.First((pro) => { return(pro.Name == pair.Key); }); prop.SetValue(item, pair.Value, null); Debug.unityLogger.Log(pair.ConverToString()); } result.Add(item); } string protoPath = PathConfig.GetLocalGameDataPath(PathConfig.DataType.Protobuf); PathEx.MakeFileDirectoryExist(protoPath); if (ProtoBuf.Serializer.NonGeneric.CanSerialize(protobufDataType)) { string resPath = protoPath + className + ProtobufData.ex; if (outputPath != null) { resPath = outputPath; } string root = Path.GetDirectoryName(resPath); PathEx.MakeFileDirectoryExist(root); using (var file = System.IO.File.Create(resPath)) { ProtoBuf.Serializer.NonGeneric.Serialize(file, result); Debug.unityLogger.Log(resPath + "导出成功"); } } else { Debug.unityLogger.LogError("序列化", protobufDataType.FullName + "不可序列化!"); } }
private void ShowValues() { pathsSaved = (PathConfig)Resources.Load("PathConfig"); ConfigurateObjects(); _target.selectedIndex = EditorGUILayout.Popup("Path to create", _target.selectedIndex, pathsSaved.objectsToInstantiate.Select(x => x.name).ToArray()); ShowPreview(); }
private void InstantiateGameplayObj() { GameObject go = ResourceManager.Singleton.LoadResource <GameObject>(PathConfig.ObjPath("Map")); map = Instantiate(go, UIManager.Singleton.UICanvas.transform); map.transform.SetSiblingIndex(1); go = ResourceManager.Singleton.LoadResource <GameObject>(PathConfig.ObjPath("PirateTracker")); pirateTracker = Instantiate(go).GetComponent <PirateTracker>(); }
public static bool HasCfg(string cfgName) { if (File.Exists(PathConfig.getFilePath(ConfigType.XML, cfgName, true))) { return(true); } TextAsset asset = Resources.Load("data/" + cfgName, typeof(TextAsset)) as TextAsset; return(asset != null); }
private Dictionary <int, Dictionary <string, string> > GetLanguageDict() { var result = new Dictionary <int, Dictionary <string, string> >(); if (!XMLParser.LoadIntMap(Path.GetFileNameWithoutExtension(PathConfig.LanguageDataPath), out result, PathConfig.GetLocalGameDataResourcesPath(PathConfig.DataType.Localization))) { return(result); } return(result); }
public IEnumerator Init() { LocalResVerison = new Dictionary <string, string>(); ServerResVersion = new Dictionary <string, string>(); NeedDownFiles = new List <string>(); //加载本地配置version文件 _localUrl = PathConfig.localUrl + "/" + PathConfig.GetManifestFileName() + "/"; yield return(null); }
public bool GetPath(string pathName, ref PathConfig outConfig) { init(); if (dicPathCofig.ContainsKey(pathName)) { outConfig = dicPathCofig[pathName]; return(true); } Utils.LogSys.LogError("GetPath Error: not find the path " + pathName + "!"); return(false); }
public static void getImg(string fileName, OnLoadResResult <Texture> call) { Texture2D ret = null; string str = PathConfig.getFilePath(ConfigType.IMAGE, fileName, true); if (string.IsNullOrEmpty(str) && (call != null)) { call(null, false); } if (File.Exists(str)) { FileStream stream = null; MemoryStream stream2 = null; ret = new Texture2D(4, 4); try { stream = File.Open(str, FileMode.Open); stream2 = new MemoryStream(); int count = -1; int num2 = 0xc800; byte[] buffer = new byte[num2]; while ((count = stream.Read(buffer, 0, num2)) > 0) { stream2.Write(buffer, 0, count); } stream2.Flush(); ret.LoadImage(stream2.GetBuffer()); } catch { ret = null; File.Delete(str); } finally { if (stream2 != null) { stream2.Close(); } if (stream != null) { stream.Close(); } } } if (ret == null) { ret = Resources.Load(fileName, typeof(Texture)) as Texture2D; } if (call != null) { call(ret, false); } }
/// <summary> /// isStartFromCurPos:为true时表示创建的路径将以当前镜头位置为起点; 为false时表示完全按配置好的路径创建。 /// </summary> /// <param name="name"></param> /// <param name="isStartFromCurPos"></param> public void CreatePath(string name, bool isStartFromCurPos = false) { PathConfig config = new PathConfig(); if (!PathXMLMgr.getInstance().GetPath(name, ref config)) { return; } CreatePath(name, config, isStartFromCurPos); }
private void DownloadWithHistory(PathConfig path) { if (!path.HistoryEnabled) { return; } // Setup session options SessionOptions sessionOptions = _config.Options; using (Session session = new Session()) { // Connect session.Open(sessionOptions); // Download files TransferOptions transferOptions = new TransferOptions { TransferMode = path.TransferMode, PreserveTimestamp = path.PreserveTimestamp }; TransferOperationResult transferResult = null; var histFolder = Path.Combine(path.LocalFolder, _historyFolderName); var histDi = new DirectoryInfo(histFolder); var histFileNames = histDi.GetFiles().Select(fi => fi.Name); var rf = session.EnumerateRemoteFiles(path.RemoteFolder, path.RemoteMask, EnumerationOptions.None); List <RemoteFileInfo> remoteFiles = rf.Where(rfi => !histFileNames.Contains(rfi.Name)).Select(rfi => rfi).ToList(); foreach (var rfi in remoteFiles) { try { transferResult = session.GetFiles(rfi.FullName, path.LocalFolder, path.DeleteSourceFiles, transferOptions); transferResult.Check(); File.WriteAllText(Path.Combine(histFolder, rfi.Name), ""); _log.Info($"Download SUCCESS '{rfi.FullName}'"); MoveRemoteFile(session, rfi.FullName, path); } catch (Exception ex) { _log.Error($"Can not download '{rfi.FullName}'", ex); } } } }
private static void GenVersionInfo(string MD5) { //TODO 设置应用版本 VersionManager.Instance.versionData.appVersion = appVersion; VersionManager.Instance.versionData.resVersion = resVersion; VersionManager.Instance.versionData.MD5 = MD5; AssetDatabase.SaveAssets(); string versionDataFilePath = PathConfig.GetExportPathByVersion(resVersion) + PathConfig.VersionDataName + ".xml"; VersionManager.Instance.versionData.GenXml(versionDataFilePath); }
public void ValidatePathConfigPayload() { PathConfig pc = new PathConfig("folder", "path"); string expectedPayload = @"{ ""label"": ""path"", ""pathFilter"": [ ""folder"" ], ""exclude"": [ """" ] }"; AreJsonEquivalent(expectedPayload, pc.ToString()); }
private void ShowValues() { _pathsSaved = (PathConfig)Resources.Load("PathConfig"); _target.currentIndex = EditorGUILayout.Popup("Actual type", _target.currentIndex, _pathsSaved.vesselsToInstantiate.Select(x => x.name).ToArray()); ShowPreview(); //_target.id = EditorGUILayout.IntField("ID", _target.id); SwitchType(); }
private void ShowValues() { pathsSaved = (PathConfig)Resources.Load("PathConfig"); _seed = GameObject.FindGameObjectWithTag("Seed").GetComponent <Seed>(); _target.currentIndex = EditorGUILayout.Popup("Path to create", _target.currentIndex, pathsSaved.objectsToInstantiate.Select(x => x.name).ToArray()); //_target.id = EditorGUILayout.IntField("ID", _target.id); SwitchType(); }