private static void CopyStoredPlayerSettingsOverCurrent(string TargetDirectory) { string[] SourceFilesPaths = Directory.GetFiles(TargetDirectory); if (SourceFilesPaths.Length > 0) { Debug.Log("Overriding player settings with data from " + TargetDirectory + "..."); foreach (string SourceFilePath in SourceFilesPaths) { string DestFilePath = SourceFilePath.Replace(TargetDirectory, "ProjectSettings"); DestFilePath = Path.ChangeExtension(DestFilePath, ".asset"); IgorRuntimeUtils.CopyFile(SourceFilePath, DestFilePath, true); Debug.Log("Replaced " + Path.GetFileName(DestFilePath)); // We need to find the ProjectSettings file and locate the defines text manually because otherwise // the recompile (if it even triggers; it's inconsistent) won't use the new defines. const string ScriptingDefineSymbolsTag = "scriptingDefineSymbols:\n"; if (DestFilePath.Contains("ProjectSettings.asset")) { string ProjectSettingsText = File.ReadAllText(SourceFilePath); int StartIndex = ProjectSettingsText.IndexOf(ScriptingDefineSymbolsTag) + ScriptingDefineSymbolsTag.Length; string StartOfDefinesBlock = ProjectSettingsText.Substring(StartIndex); HashSet <BuildTargetGroup> MatchedBuildTargetGroups = new HashSet <BuildTargetGroup>(); string NextLine; StringReader StringReader = new StringReader(StartOfDefinesBlock); bool bContinue = true; do { NextLine = StringReader.ReadLine(); if (NextLine != null) { NextLine = NextLine.Trim(); if (NextLine.Length > 0 && char.IsNumber(NextLine[0])) { int IndexOfColon = NextLine.IndexOf(':'); string BuildGroupText = NextLine.Substring(0, IndexOfColon); string Define = NextLine.Substring(IndexOfColon + 1); int BuildGroupAsInt = 0; Int32.TryParse(BuildGroupText, out BuildGroupAsInt); BuildTargetGroup TargetGroup = (BuildTargetGroup)BuildGroupAsInt; if (TargetGroup != BuildTargetGroup.Unknown) { PlayerSettings.SetScriptingDefineSymbolsForGroup(TargetGroup, Define); MatchedBuildTargetGroups.Add(TargetGroup); } } else { bContinue = false; } } }while(bContinue); // Make sure we wipe out defines on any other build targets. BuildTargetGroup[] AllTargetGroups = System.Enum.GetValues(typeof(BuildTargetGroup)) as BuildTargetGroup[]; foreach (BuildTargetGroup Group in AllTargetGroups) { if (!MatchedBuildTargetGroups.Contains(Group)) { PlayerSettings.SetScriptingDefineSymbolsForGroup(Group, string.Empty); } } } } AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); } }
public static void Load(string FileName) { string NextLine; cfg.Clear(); try { if (File.Exists(FileName)) { StreamReader sr = new StreamReader(FileName, System.Text.Encoding.GetEncoding(1251)); while ((NextLine = sr.ReadLine()) != null) { if (NextLine.Trim() == "") { continue; } if (NextLine.Trim().Substring(0, 1) == "#") { continue; } int pos = NextLine.IndexOf(' '); if (pos != -1) //NextLine[pos] = '\t'; { NextLine = NextLine.Remove(pos, 1).Insert(pos, "\t"); } //NextLine = NextLine.Replace(" ", " "); //NextLine = NextLine.Replace(" ", " "); string[] a = NextLine.Trim().Split('\t'); if (a.Length > 1) { cfg.Add(a[0].Trim(), a[1].Trim()); } } sr.Close(); commandMySQLTimeout = Convert.ToInt32(GetValue("MySQL_Timeout", "1000")); } else { WriteLog("Нет файла конфигурации"); Environment.Exit(-1); } } catch (Exception e) { WriteLog(String.Format("The process Parse CFG failed: {0}", e.ToString())); Environment.Exit(-1); } if (!cfg.ContainsKey("TimeoutWriteKKM")) { cfg.Add("TimeoutWriteKKM", "30"); } if (!cfg.ContainsKey("TimeoutReadKKM")) { cfg.Add("TimeoutReadKKM", "30"); } if (!cfg.ContainsKey("SMS_Server")) { cfg.Add("SMS_Server", ""); } if (!cfg.ContainsKey("SMS_User")) { cfg.Add("SMS_User", ""); } if (!cfg.ContainsKey("SMS_Passwd")) { cfg.Add("SMS_Passwd", ""); } if (!cfg.ContainsKey("SMS_Baza")) { cfg.Add("SMS_Baza", ""); } if (!cfg.ContainsKey("MySQL_Server")) { cfg.Add("MySQL_Server", ""); } if (!cfg.ContainsKey("MySQL_User")) { cfg.Add("MySQL_User", ""); } if (!cfg.ContainsKey("MySQL_Passwd")) { cfg.Add("MySQL_Passwd", ""); } if (!cfg.ContainsKey("Shop_Export")) { cfg.Add("Shop_Export", "20"); } }