Exemplo n.º 1
0
		public static void SaveTextResource(FileResource file, string value) {

			if(!isSet) {
				
				Set();

			}

			#if UNITY_EDITOR

			if(!knownTrilleonResourceFiles.FindAll(x => x.Key == file).Any()) {
				
				Debug.Log("The supplied file could not be found. Make sure you are referencing a file stored outside of the Unity project."); //No usage of string.Format with file name data. Using Enum.GetName here causes exceptions on compile "Recursive Serialization is not supported. You can't dereference a PPtr while loading.".
			
			}

			string filePath = string.Format("{0}{1}.txt", BASE_RESOURCE_PATH, knownTrilleonResourceFiles.Find(x => x.Key == file).Value);
			File.WriteAllText(filePath, value);

			AssetDatabase.Refresh();
			if(file == FileResource.TrilleonConfig) {

				ConfigReader.Refresh();

			}

			#endif

		}
Exemplo n.º 2
0
		public static void SaveConfig(string key, string value){

			if(!isSet) {
				
				Set();

			}

			#if UNITY_EDITOR
			string[] currentKeyVals = GetTextResource(FileResource.TrilleonConfig).Split('\n');
			StringBuilder textInfo = new StringBuilder();

			for(int kv = 0; kv < currentKeyVals.Length; kv++) {
				
				string[] keyVal = currentKeyVals[kv].Split('=');
				if(keyVal.Length == 1) {

					textInfo.AppendLine(keyVal[0]);

				} else if(keyVal[0] == key) {
					
					textInfo.AppendLine(string.Format("{0}={1}", keyVal[0], value));

				} else {
					
					textInfo.AppendLine(string.Format("{0}={1}", keyVal[0], keyVal[1]));

				}

			}

			//Overwrite and save settings to file.
			SaveTextResource(FileResource.TrilleonConfig, textInfo.ToString());

			AssetDatabase.Refresh();
			ConfigReader.Refresh();
			#endif

		}