bool LoadPresetFile(string fileName, ScreenshotHelper ssh) { if (string.IsNullOrEmpty(fileName)) { return(false); } if (!File.Exists(fileName)) { return(false); } SSHPreset sshPreset = SSHPreset.Load(fileName); if (sshPreset != null) { if (sshPreset.sizes.Count > 0) { ssh.shotInfo = sshPreset.sizes; ssh.savePath = sshPreset.lastSavePath; ssh.orientation = sshPreset.orientation; return(true); } } return(false); }
void OnApplicationQuit() { ScreenshotHelper myTarget = (ScreenshotHelper)target; SSHPreset sshPreset = new SSHPreset(); sshPreset.Save(myTarget); }
void PathChange(string newPath) { Debug.Log("PathChange to " + newPath); ScreenshotHelper myTarget = (ScreenshotHelper)target; myTarget.savePath = newPath; SSHPreset sshPreset = new SSHPreset(); sshPreset.Save(myTarget); }
string SavePreset(ScreenshotHelper ssh) { string file = EditorUtility.SaveFilePanel("Save your presets", Directory.GetCurrentDirectory(), "screenshot_helper_preset", "xml"); SSHPreset preset = new SSHPreset(); preset.Save(file, ssh); return(file); }
void OnEnable() { ScreenshotHelper ssHelper = (ScreenshotHelper)target; bool loadConfig = false; if (ssHelper.shotInfo.Count == 0 || !string.IsNullOrEmpty(ssHelper.configFile)) { if (!string.IsNullOrEmpty(ssHelper.configFile)) { if (File.Exists(ssHelper.configFile)) { loadConfig = true; } } if (loadConfig) { LoadPresetFile(ssHelper.configFile, ssHelper); } else { ssHelper.SetDefaults(); } } if (!loadConfig) { LoadPresetFile(SSHPreset.DefaultSavePath(), ssHelper); if (File.Exists(SSHPreset.DefaultSavePath())) { File.Delete(SSHPreset.DefaultSavePath()); } } ssHelper.PathChange = PathChange; //myTarget.DefaultsSet = SaveSettings; }