예제 #1
0
        /// <summary>
        /// Load a ModInfo.
        /// </summary>
        /// <param name="path">The path to load the ModInfo from.</param>
        /// <returns>The loaded Modinfo, if succeeded. Null otherwise.</returns>
        public static ModInfo Load(string path)
        {
            path = Path.GetFullPath(path);

            if (File.Exists(path))
            {
                try
                {
                    string json = File.ReadAllText(path);

                    ModInfo modInfo = JsonUtility.FromJson <ModInfo>(json);

                    modInfo.path = path;

                    return(modInfo);
                }
                catch (Exception e)
                {
                    LogUtility.LogWarning("There was an issue while loading the ModInfo from " + path + " - " + e.Message);
                }
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Save a ModInfo.
        /// </summary>
        /// <param name="path">The path to save the ModInfo to.</param>
        /// <param name="modInfo">The ModInfo to save.</param>
        public static void Save(string path, ModInfo modInfo)
        {
            string json = JsonUtility.ToJson(modInfo, true);

            File.WriteAllText(path, json);
        }