mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Merge scene dumper with console
This commit is contained in:
1 parent
8f8facf68e
commit
8a7cc69be9
7 files changed
+75
-193
No files matched your search
@@ -15,8 +15,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicTranslationLoader",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InputUnlocker", "Plugins\InputUnlocker\InputUnlocker.csproj", "{379BA41B-9944-4B5A-8732-EEBAA7F05B04}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SceneDumper", "Plugins\SceneDumper\SceneDumper.csproj", "{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorCorrector", "Plugins\ColorCorrector\ColorCorrector.csproj", "{6809B5DC-358C-45C5-B04C-0B7027596A8B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SliderUnlocker", "Plugins\SliderUnlocker\SliderUnlocker.csproj", "{9DB058D4-CF5A-4280-9150-A62C22FC3CB0}"
|
||||
@@ -54,10 +52,6 @@ Global
|
||||
{379BA41B-9944-4B5A-8732-EEBAA7F05B04}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{379BA41B-9944-4B5A-8732-EEBAA7F05B04}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{379BA41B-9944-4B5A-8732-EEBAA7F05B04}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -85,7 +79,6 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{6FE9DE86-F466-49FD-BCCA-ADD512C8DCE8} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{379BA41B-9944-4B5A-8732-EEBAA7F05B04} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{6809B5DC-358C-45C5-B04C-0B7027596A8B} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{9DB058D4-CF5A-4280-9150-A62C22FC3CB0} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
{6A9D08C0-4482-4D1A-9368-9F41B7126F9E} = {FF8CE2C8-C185-4EA9-8D63-E2542F0C2FCF}
|
||||
|
||||
@@ -90,6 +90,11 @@ namespace DeveloperConsole
|
||||
}
|
||||
});
|
||||
|
||||
if (GUI.Button(new Rect(295, 20, 100, 20), "Dump scene"))
|
||||
{
|
||||
SceneDumper.DumpScene();
|
||||
}
|
||||
|
||||
GUI.DragWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DeveloperConsole.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SceneDumper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace DeveloperConsole
|
||||
{
|
||||
static class SceneDumper
|
||||
{
|
||||
public static void DumpScene()
|
||||
{
|
||||
var objects = SceneManager.GetActiveScene().GetRootGameObjects();
|
||||
|
||||
var fname = Path.GetTempFileName();
|
||||
using (var f = File.OpenWrite(fname))
|
||||
using (var sw = new StreamWriter(f, Encoding.UTF8))
|
||||
{
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
PrintRecursive(sw, obj);
|
||||
}
|
||||
}
|
||||
Process.Start("notepad.exe", fname);
|
||||
}
|
||||
|
||||
private static void PrintRecursive(StreamWriter sw, GameObject obj)
|
||||
{
|
||||
PrintRecursive(sw, obj, 0);
|
||||
}
|
||||
|
||||
private static void PrintRecursive(StreamWriter sw, GameObject obj, int d)
|
||||
{
|
||||
//Console.WriteLine(obj.name);
|
||||
var pad1 = new string(' ', 3 * d);
|
||||
var pad2 = new string(' ', 3 * (d + 1));
|
||||
var pad3 = new string(' ', 3 * (d + 2));
|
||||
sw.WriteLine(pad1 + obj.name + "--" + obj.GetType().FullName);
|
||||
|
||||
foreach (Component c in obj.GetComponents<Component>())
|
||||
{
|
||||
sw.WriteLine(pad2 + "::" + c.GetType().Name);
|
||||
|
||||
var ct = c.GetType();
|
||||
var props = ct.GetProperties(System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
|
||||
foreach (var p in props)
|
||||
{
|
||||
try
|
||||
{
|
||||
var v = p.GetValue(c, null);
|
||||
sw.WriteLine(pad3 + "@" + p.Name + "<" + p.PropertyType.Name + "> = " + v);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach (Transform t in obj.transform)
|
||||
{
|
||||
PrintRecursive(sw, t.gameObject, d + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("SceneDumper")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SceneDumper")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("c42bd13e-b5e4-4b73-b21b-e34b9dfa9108")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,86 +0,0 @@
|
||||
using BepInEx;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace SceneDumper
|
||||
{
|
||||
class SceneDumper : BaseUnityPlugin
|
||||
{
|
||||
public override string Name => "Scene Dumper";
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
if (UnityEngine.Event.current.Equals(Event.KeyboardEvent("f8")))
|
||||
{
|
||||
DumpScene();
|
||||
}
|
||||
}
|
||||
|
||||
static List<string> lines;
|
||||
|
||||
|
||||
public static void DumpScene()
|
||||
{
|
||||
lines = new List<string>();
|
||||
|
||||
string filename = @"M:\unity-scene.txt";
|
||||
|
||||
Debug.Log("Dumping scene to " + filename + " ...");
|
||||
using (StreamWriter writer = new StreamWriter(filename, false))
|
||||
{
|
||||
foreach (GameObject gameObject in GameObject.FindObjectsOfType<GameObject>())
|
||||
{
|
||||
if (gameObject.activeInHierarchy)
|
||||
DumpGameObject(gameObject, writer, "");
|
||||
|
||||
}
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
writer.WriteLine(line);
|
||||
}
|
||||
}
|
||||
Debug.Log("Scene dumped to " + filename);
|
||||
}
|
||||
|
||||
private static void DumpGameObject(GameObject gameObject, StreamWriter writer, string indent)
|
||||
{
|
||||
//writer.WriteLine("{0}+{1}+{2}", indent, gameObject.name, gameObject.GetType().FullName);
|
||||
|
||||
foreach (Component component in gameObject.GetComponents<Component>())
|
||||
{
|
||||
DumpComponent(component, writer, indent + " ");
|
||||
}
|
||||
|
||||
foreach (Transform child in gameObject.transform)
|
||||
{
|
||||
DumpGameObject(child.gameObject, writer, indent + " ");
|
||||
}
|
||||
}
|
||||
|
||||
private static void DumpComponent(Component component, StreamWriter writer, string indent)
|
||||
{
|
||||
//writer.WriteLine("{0}{1}", indent, (component == null ? "(null)" : component.GetType().FullName));
|
||||
if (component is TextMeshProUGUI)
|
||||
{
|
||||
string text = ((TextMeshProUGUI)component).text;
|
||||
|
||||
if (text.Trim() != ""
|
||||
&& !text.Contains("Reset")
|
||||
&& Regex.Replace(text, @"[\d-]", string.Empty).Trim() != "")
|
||||
{
|
||||
if (!lines.Contains(text))
|
||||
lines.Add(text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C42BD13E-B5E4-4B73-B21B-E34B9DFA9108}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SceneDumper</RootNamespace>
|
||||
<AssemblyName>SceneDumper</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>K:\BepInEx\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>K:\BepInEx\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="TextMeshPro-1.0.55.56.0b12">
|
||||
<HintPath>..\..\lib\TextMeshPro-1.0.55.56.0b12.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\lib\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>..\..\lib\UnityEngine.UI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="SceneDumper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\BepInEx\BepInEx.csproj">
|
||||
<Project>{4ffba620-f5ed-47f9-b90c-dad1316fd9b9}</Project>
|
||||
<Name>BepInEx</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Reference in new issue
Block a user