internal static string GetDirPath(System.Type t) { var attr = ConfigLoader.GetConfigAttribute(t); string path = string.Format("{0}/{1}", UTIL_DIR, attr.filename); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } return(path); }
private void ApplyToTypeInfo(Utility.TypeAndAttr info) { this.currentTypeInfo = info; object obj = null; bool loadResult = ConfigLoader.LoadData(out obj, info.type); if (!loadResult) { obj = System.Activator.CreateInstance(info.type); } ApplyCurrentValue(obj); }
private static void UpdateInfo(Utility.TypeAndAttr typeAndAttr) { object obj = null; ConfigLoader.LoadData(out obj, typeAndAttr.type); if (obj == null) { obj = System.Activator.CreateInstance(typeAndAttr.type); } IConfigUpdateOnBuild config = obj as IConfigUpdateOnBuild; config.OnPreprocessBuild(); Utility.SaveDataToStreamingAssets(config); }
internal static List <TypeAndAttr> GetTypeList() { List <TypeAndAttr> list = new List <TypeAndAttr>(); var domain = System.AppDomain.CurrentDomain; foreach (var asm in domain.GetAssemblies()) { var types = asm.GetTypes(); foreach (var type in types) { var customAttr = ConfigLoader.GetConfigAttribute(type); if (customAttr == null) { continue; } list.Add(new TypeAndAttr(type, customAttr)); } } return(list); }
public static void SaveDataToStreamingAssets(object obj) { System.Type type = obj.GetType(); var customAttr = ConfigLoader.GetConfigAttribute(type); if (customAttr == null) { return; } string path = ConfigLoader.GetConfigDataPath(customAttr); if (System.IO.File.Exists(path)) { bool res = EditorUtility.DisplayDialog("Overwrite?", "File is already exist.Overwrite?", "ok", "cancel"); if (!res) { return; } } string json = JsonUtility.ToJson(obj); System.IO.File.WriteAllText(path, json); }