Advertisement
Guest User

GameObjcetDumpList.cs

a guest
Aug 6th, 2015
1,235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.39 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using UnityEngine;
  7. using UnityInjector;
  8. using UnityInjector.Attributes;
  9.  
  10. namespace CM3D2GameObjcetDumpListPlugin
  11. {
  12.     [PluginFilter("CM3D2x64"),
  13.     PluginFilter("CM3D2x86"),
  14.     PluginName("GameObjcet Dump List Plugin"),
  15.     PluginVersion("1.0.0.0")]
  16.  
  17.     public class GameObjcetDumpList : PluginBase
  18.     {
  19.         private int sceneLevel = -1;
  20.         private bool execituig = false;
  21.  
  22.         void Awake()
  23.         {
  24.             GameObject.DontDestroyOnLoad(this);
  25.         }
  26.  
  27.         void OnLevelWasLoaded(int level)
  28.         {
  29.             sceneLevel = level;
  30.         }
  31.  
  32.         void Update()
  33.         {
  34.             if ((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) && Input.GetKey(KeyCode.L))
  35.             {
  36.                 if (!execituig)
  37.                 {
  38.                     execituig = true;
  39.                     DumpList();
  40.                 }
  41.             }
  42.             else
  43.             {
  44.                 execituig = false;
  45.             }
  46.  
  47.         }
  48.  
  49.         private void DumpList()
  50.         {
  51.             GameObject[] rootArray = Array.FindAll(UnityEngine.Object.FindObjectsOfType<GameObject>(),(item) => item.transform.parent == null);
  52.  
  53.             String now = DateTime.Now.ToString("yyyyMMdd_HHmmss");
  54.  
  55.             string filename = (@".\MaidObjectList_Level_" + sceneLevel.ToString() + "_" + now + ".txt");
  56.             string rootname = "miss hit";
  57.  
  58.             ArrayList gameObjectList = new ArrayList();
  59.  
  60.             foreach (var root in rootArray)
  61.             {
  62.                     rootname = root.name;
  63.                     gameObjectList.Add(rootname);
  64.  
  65.                     foreach (Transform t in root.transform)
  66.                     {
  67.                         Search(gameObjectList, t, 1);
  68.                     }
  69.             }
  70.             System.IO.File.WriteAllLines(filename, gameObjectList.Cast<string>().ToArray());
  71.         }
  72.  
  73.         private void Search(ArrayList array, Transform t, int i)
  74.         {
  75.             string space = new string(' ', i);
  76.             array.Add(space + t.name);
  77.  
  78.             if (t.IsChildOf(t))
  79.             {
  80.                 i++;
  81.                 foreach (Transform item in t)
  82.                 {
  83.                     Search(array, item, i);
  84.                 }
  85.             }
  86.  
  87.         }
  88.  
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement