private static void SaveDependencies() { Objects = new List<KeyValuePair<string, string>>(); Dependencies = new List<KeyValuePair<string, List<string>>>(); foreach (var obj in Selection.objects) { List<string> deps = new List<string>(); string objPath = AssetDatabase.GetAssetPath(obj); objPath = objPath.Replace("Assets/Resources/", ""); int fileExtPos = objPath.LastIndexOf('.'); objPath = objPath.Substring(0, fileExtPos); Objects.Add(new KeyValuePair<string, string>(obj.name, objPath)); var dependencies = EditorUtility.CollectDependencies(new[] { obj }); foreach (var d in dependencies) { string path = AssetDatabase.GetAssetPath(d); if (path.Contains("Assets/Resources/")) { path = path.Replace("Assets/Resources/", ""); fileExtPos = path.LastIndexOf('.'); path = path.Substring(0, fileExtPos); if (d is Texture2D || d is Material || d is Shader) { deps.Add(path); } } } Dependencies.Add(new KeyValuePair<string, List<string>>(obj.name, deps)); } JsonRoot root = new JsonRoot(); int count = 0; foreach (var obj in Objects) { JsonClass jsonObject = new JsonClass(count.ToString()); jsonObject.AddObjects(new JsonValue(ObjectFromCache.JsonName, obj.Key)); jsonObject.AddObjects(new JsonValue(ObjectFromCache.JsonPath, obj.Value)); jsonObject.AddObjects(new JsonArray(ObjectFromCache.JsonDependencies, Dependencies.Find((d)=> obj.Key == d.Key).Value)); root.AddObjects(jsonObject); count++; } string filepath = EditorUtility.SaveFilePanel("Save dependencies for selected objects", "Assets", "Dependencies", "json"); File.WriteAllText(filepath, root.ToString(), Encoding.UTF8); }
public static void SaveData() { var root = new JsonRoot(); root.AddObjects(new JsonValue("Sound", _sound)); root.AddObjects(new JsonValue("Music", _music)); root.AddObjects(new JsonValue("LoginType", _loginType)); root.AddObjects(new JsonValue("Gender", _gender)); root.AddObjects(new JsonValue("Language", _language)); string saveString = root.ToString(); var bf = new BinaryFormatter(); Debug.LogError("Save string = " + saveString); Debug.LogError(Application.persistentDataPath + _saveName); var file = File.Open(Application.persistentDataPath + _saveName, FileMode.Create); bf.Serialize(file, saveString); file.Close(); OnDataSaved(); }
public static void SaveData(string userIdentifier) { var root = new JsonRoot(); root.AddObjects(new JsonValue("MaxScore", MaxScore)); string saveString = root.ToString(); PlayerPrefs.SetString("login_type", _loginType.ToString()); PlayerPrefs.SetString(_saveName + "_" + userIdentifier, saveString); PlayerPrefs.SetString(GameController.UserIdentifier, GameController.UserIdentifier); OnDataSaved(); }
public static JsonRoot GetJson() { var root = new JsonRoot(); root.AddObjects(new JsonValue("last_project", _lastProject)); return root; }