Advertisement
xN0tiCx

MySummerCar SceneObjects Source

Jan 24th, 2018
2,530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.97 KB | None | 0 0
  1. using MSCLoader;
  2. using UnityEngine;
  3.  
  4. /*
  5.  DONT FORGET TO ADD REFERENCE TO:
  6.     MSCLoader
  7.     PlayMaker
  8.     UnityEngine
  9.     UnityEngine.UI
  10.  
  11.  I always use this too:
  12.     Assenbly.CSharp
  13. */
  14.  
  15. namespace SceneObjects
  16. {
  17.     public class SceneObjects : Mod
  18.     {
  19.         public override string ID => "SceneObjects";
  20.         public override string Name => "SceneObjects";
  21.         public override string Author => "N0tiC";
  22.         public override string Version => "1.0";
  23.  
  24.         //Set this to true if you will be load custom assets from Assets folder.
  25.         //This will create subfolder in Assets folder for your mod.
  26.         public override bool UseAssetsFolder => false;
  27.  
  28.         //Make a keybind
  29.         private Keybind create_Object_Dump = new Keybind("objectDump", "Create dump of all objects in scene.", KeyCode.F5); // Create a keybind..
  30.  
  31.         //Called when mod is loading
  32.         public override void OnLoad()
  33.         {
  34.             //Print out  console message.
  35.             ModConsole.Print("SceneObjects: Loaded");
  36.         }
  37.  
  38.         // Update is called once per frame
  39.         public override void Update()
  40.         {
  41.             //If pressed..
  42.             if (create_Object_Dump.IsDown())
  43.                 dumpObjects(); // Run this
  44.         }
  45.  
  46.         /* "Debug" */
  47.         private void dumpObjects()
  48.         {
  49.             //We put it in a try block.
  50.             try
  51.             {
  52.                 //Path to debug.txt dump. (Same folder as mysummercar.exe)
  53.                 string file_path = "SceneObjects.txt";
  54.  
  55.                 //Declare an array and define its name.
  56.                 GameObject[] allObjects;
  57.  
  58.                 //Declare an StreamWriter and define its name but also initialize it with given parmiters
  59.                 System.IO.StreamWriter sr = System.IO.File.CreateText(file_path);
  60.  
  61.                 //We Initialize allObjects and give it the array values of GameObjects
  62.                 allObjects = Object.FindObjectsOfType<GameObject>();
  63.  
  64.                 //We write first line of the document to give it a "header" like appearance.
  65.                 sr.WriteLine("SceneObjects=>FindObjectsOfType<GameObject>:");
  66.  
  67.                 //For every GameObject in allObjects we print the name of the object in to the file "SceneObjects.txt"
  68.                 foreach (GameObject obj in allObjects)
  69.                 {
  70.                     sr.WriteLine(obj.name);
  71.                 }
  72.  
  73.                 //We close the StreamWriter...
  74.                 sr.Close();
  75.  
  76.                 //Clean up console..
  77.                 ModConsole.Clear();
  78.  
  79.                 //Print out a success message in console.
  80.                 ModConsole.Print("SceneObjects: Success creating " + file_path);
  81.                 ModConsole.Print(""); // For spacing..
  82.                 ModConsole.Print(""); // For spacing..
  83.                 ModConsole.Print(""); // For spacing..
  84.             } catch (System.Exception) { ModConsole.Print("Something went wrong..."); }
  85.  
  86.  
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement