void OnGUI() { if (!ShowGUI) // if it doesn't show a gui { return; // Get the frick out of here if ShowGUI is not true } if (fontSize == null) { fontSize = new GUIStyle(GUI.skin.button); // if you want to use it for a button fontSize.fontSize = 22; //How big you want the text, fill it out here fontSize.alignment = TextAnchor.MiddleLeft; // This is an optional change with what you would like| oh yeah I used that in my thing fontSize.normal.textColor = Color.white; } if (GUI.Button(new Rect(Screen.width * .7f, Screen.height * .8f - 30f /* Offset button to near bottom of the screen */, 500, 30), "Save current tech as .xml", fontSize)) { Tank playerTank = Singleton.playerTank; ExundXMLHandler.SaveTechAsXML(playerTank, QPatch.XMLPath); // Save XML when button is pressed } }
static void Postfix(PopulationTable __instance) // Called after { foreach (var thing in __instance.m_FolderTechs) //a system operator that does a thing for each of the specified things in the parenthesis { Debug.Log(thing.m_FolderName); // what the foreach does } if (Directory.Exists(XMLPath)) //tests to see if the XMLpath directory exists { //does magical loading stuff below var directory = new DirectoryInfo(XMLPath); // Create a new DirectoryInfo based off of XML path that can be used for later purposes var files = directory.GetFiles(); // Get all the files from directory and return an array //A simpler way is to one-line it, such as `foreach(var file in new DirectoryInfo(XMLPath).GetAllFiles())` foreach (FileInfo file in files) // Iterate through the array; Use every object in the array one after the other until all are used { var tech = ExundXMLHandler.LoadXMLAsTech(file.FullName, Vector3.down * 1000f, Quaternion.Euler(0f, 0f, 0f)); //makes a new variable called "tech" derived from the TerraTech "Tank" class and gives it the value deserialized from the xml info,henmovest var tankPreset = TankPreset.CreateInstance(); tankPreset.SaveTank(tech, false, false); __instance.m_FolderTechs[0].m_Presets.Add(tankPreset); tech.visible.RemoveFromGame(); try { UnityEngine.GameObject.DestroyImmediate(tech.gameObject); } catch { Debug.Log("Could not remove XML GameObject!"); } } } else { Debug.Log("XML folder does not exist! " + XMLPath); } }