mirror of
https://github.com/BepInEx/DeveloperConsole.git
synced 2026-11-23 03:39:28 -10:00
Add project files
This commit is contained in:
1 parent
ca59f56bb8
commit
bd97fcc195
6 files changed
+298
No files matched your search
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29020.237
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BepInEx.DeveloperConsole", "BepInEx.DeveloperConsole\BepInEx.DeveloperConsole.csproj", "{3C7BB8A4-13FD-4F27-BF26-BF908E06D628}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3C7BB8A4-13FD-4F27-BF26-BF908E06D628}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3C7BB8A4-13FD-4F27-BF26-BF908E06D628}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3C7BB8A4-13FD-4F27-BF26-BF908E06D628}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3C7BB8A4-13FD-4F27-BF26-BF908E06D628}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {521B1E47-9429-4670-8741-51CD93A77909}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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>{3C7BB8A4-13FD-4F27-BF26-BF908E06D628}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BepInEx.DeveloperConsole</RootNamespace>
|
||||
<AssemblyName>BepInEx.DeveloperConsole</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\BepInEx\plugins\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\BepInEx\plugins\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BepInEx">
|
||||
<HintPath>..\lib\BepInEx.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<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="UnityEngine">
|
||||
<HintPath>..\lib\UnityEngine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DeveloperConsole.cs" />
|
||||
<Compile Include="DeveloperConsole.LogListener.cs" />
|
||||
<Compile Include="DeveloperConsole.SceneDumper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,17 @@
|
||||
using BepInEx.Logging;
|
||||
|
||||
namespace BepInEx
|
||||
{
|
||||
public partial class DeveloperConsole
|
||||
{
|
||||
private sealed class LogListener : ILogListener
|
||||
{
|
||||
public void Dispose() { }
|
||||
|
||||
public void LogEvent(object sender, LogEventArgs eventArgs)
|
||||
{
|
||||
OnEntryLogged(eventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using BepInEx.Logging;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace BepInEx
|
||||
{
|
||||
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)
|
||||
{
|
||||
DeveloperConsole.Logger.Log(LogLevel.Debug, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach (Transform t in obj.transform)
|
||||
{
|
||||
PrintRecursive(sw, t.gameObject, d + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Logging;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BepInEx
|
||||
{
|
||||
[BepInPlugin(GUID, PluginName, Version)]
|
||||
public partial class DeveloperConsole : BaseUnityPlugin
|
||||
{
|
||||
public const string GUID = "com.bepis.bepinex.developerconsole";
|
||||
public const string PluginName = "Developer Console";
|
||||
public const string Version = "1.0";
|
||||
internal static new ManualLogSource Logger;
|
||||
|
||||
private bool showingUI = false;
|
||||
private static string TotalLog = "";
|
||||
private Rect UI = new Rect(20, 20, 400, 400);
|
||||
private static Vector2 scrollPosition = Vector2.zero;
|
||||
|
||||
public static ConfigFile BepinexConfig { get; } = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, "BepInEx.cfg"), false);
|
||||
|
||||
public static ConfigWrapper<int> LogDepth { get; private set; }
|
||||
public static ConfigWrapper<bool> LogUnity { get; private set; }
|
||||
|
||||
public DeveloperConsole()
|
||||
{
|
||||
LogDepth = Config.Wrap("Config", "Log buffer size", "Size of the log buffer in characters", 16300);
|
||||
LogUnity = BepinexConfig.Wrap("Logging", "UnityLogListening", "Enables showing unity log messages in the BepInEx logging system.", true);
|
||||
|
||||
Logging.Logger.Listeners.Add(new LogListener());
|
||||
Logger = base.Logger;
|
||||
}
|
||||
|
||||
private static void OnEntryLogged(LogEventArgs logEventArgs)
|
||||
{
|
||||
string current = $"{TotalLog}\r\n{logEventArgs.Data?.ToString()}";
|
||||
if (current.Length > LogDepth.Value)
|
||||
{
|
||||
var trimmed = current.Remove(0, 1000);
|
||||
|
||||
// Trim until the first newline to avoid partial line
|
||||
var newlineHit = false;
|
||||
trimmed = new string(trimmed.SkipWhile(x => !newlineHit && !(newlineHit = (x == '\n'))).ToArray());
|
||||
|
||||
current = "--LOG TRIMMED--\n" + trimmed;
|
||||
}
|
||||
TotalLog = current;
|
||||
|
||||
scrollPosition = new Vector2(0, float.MaxValue);
|
||||
}
|
||||
|
||||
protected void OnGUI()
|
||||
{
|
||||
if (showingUI)
|
||||
UI = GUILayout.Window(589, UI, WindowFunction, "Developer Console");
|
||||
}
|
||||
|
||||
protected void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Pause))
|
||||
showingUI = !showingUI;
|
||||
}
|
||||
|
||||
private void WindowFunction(int windowID)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
if (GUILayout.Button("Clear console"))
|
||||
TotalLog = "Log cleared";
|
||||
if (GUILayout.Button("Dump scene"))
|
||||
SceneDumper.DumpScene();
|
||||
|
||||
LogUnity.Value = GUILayout.Toggle(LogUnity.Value, "Unity");
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginVertical(GUI.skin.box);
|
||||
{
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.TextArea(TotalLog, GUI.skin.label);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUI.DragWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
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("BepInEx.DeveloperConsole")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BepInEx.DeveloperConsole")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[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("3c7bb8a4-13fd-4f27-bf26-bf908e06d628")]
|
||||
|
||||
// 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(BepInEx.DeveloperConsole.Version)]
|
||||
Reference in new issue
Block a user