public static void enablePromptAfterInstall(bool enable) { // find all the config.plist files in plugin directories string basePath = Path.Combine(Application.dataPath, "Editor"); var dirInfo = new DirectoryInfo(basePath); var pluginDirs = from dir in dirInfo.GetDirectories() let files = dir.GetFiles("config.plist") where files.Length == 1 select files[0]; // loop through our pluginDirs foreach (var dir in pluginDirs) { if (!File.Exists(dir.FullName)) { continue; } // initialize the hashtable and plistKeys Hashtable plistContents = new Hashtable(); PListEditor.loadPlistFromFile(dir.FullName, plistContents); if (plistContents.ContainsKey("neverShowCompletedMessage")) { plistContents["neverShowCompletedMessage"] = !enable; PListEditor.savePlistToFile(dir.FullName, plistContents); } } }
// grabs the contents of the plist and sets them in the ivar public void getPlistContents() { // initialize the hashtable and plistKeys plistContents = new Hashtable(); // get the contents of the plist file if it exists filePath = Path.Combine(Application.dataPath, "Editor/Prime31/" + plistFileName); if (File.Exists(filePath)) { PListEditor.loadPlistFromFile(filePath, plistContents); // set any keys that we have present var t = typeof(Prime31PlistHelperWizard); foreach (var info in t.GetFields()) { if (plistContents.ContainsKey(info.Name)) { // special case for orientations if (info.Name == "UISupportedInterfaceOrientations") { var list = new List <UIInterfaceOrientationEnum>(); var values = plistContents[info.Name]; // parse out the strings to enums foreach (var orientation in (ArrayList)values) { var fixedOrient = (UIInterfaceOrientationEnum)Enum.Parse(typeof(UIInterfaceOrientationEnum), orientation.ToString()); list.Add(fixedOrient); } // set the list to the ivar UISupportedInterfaceOrientations = list.ToArray(); } else { info.SetValue(this, plistContents[info.Name]); } } else if (plistContents.ContainsKey("CFBundleURLTypes")) // special case for url schemes { var values = (ArrayList)plistContents["CFBundleURLTypes"]; var ht = values[0] as Hashtable; var listOfSchemes = ht["CFBundleURLSchemes"] as ArrayList; var extractedSchemes = new List <string>(); foreach (string scheme in listOfSchemes) { extractedSchemes.Add(scheme); } CFBundleURLSchemes = extractedSchemes.ToArray(); } } } }
// Called when the 'save changes' button is pressed void OnWizardCreate() { // fill out the hashtable with the new values var ht = new Hashtable(); // add an entry with all the key names var plistKeys = getAllPublicIvarNames(); ht["plistKeys"] = plistKeys; ht["UIApplicationExitsOnSuspend"] = this.UIApplicationExitsOnSuspend; if (MinimumOSVersion != string.Empty) { ht["MinimumOSVersion"] = MinimumOSVersion; } ht["UIFileSharingEnabled"] = this.UIFileSharingEnabled; if (UISupportedInterfaceOrientations != null && UISupportedInterfaceOrientations.Length > 0) { var list = new ArrayList(); // grab all the orientations as strings foreach (var orientation in UISupportedInterfaceOrientations) { list.Add(orientation.ToString()); } ht["UISupportedInterfaceOrientations"] = list; } if (CFBundleURLSchemes != null && CFBundleURLSchemes.Length > 0) { var scheme = new Hashtable(); scheme["CFBundleURLName"] = string.Empty; scheme["CFBundleURLSchemes"] = new ArrayList(CFBundleURLSchemes); var urlTypes = new ArrayList(); urlTypes.Add(scheme); ht["CFBundleURLTypes"] = urlTypes; } PListEditor.savePlistToFile(filePath, ht); }