├── .github
└── workflows
│ └── nuget.yml
├── .gitignore
├── .gitmodules
├── Directory.Build.props
├── LICENSE
├── README.md
├── RuntimeUnityEditor.Bepin5
├── LogViewer
│ ├── LogViewerEntry.cs
│ ├── LogViewerListener.cs
│ └── LogViewerWindow.cs
├── RuntimeUnityEditor.Bepin5.csproj
└── RuntimeUnityEditor5.cs
├── RuntimeUnityEditor.Bepin6.IL2CPP
├── LogViewer
│ ├── LogViewerEntry.cs
│ ├── LogViewerListener.cs
│ └── LogViewerWindow.cs
├── RuntimeUnityEditor.Bepin6.IL2CPP.csproj
└── RuntimeUnityEditorPluginIL2CPP.cs
├── RuntimeUnityEditor.Core.IL2CPP
├── Libs
│ └── Unity.InputSystem.dll
├── RuntimeUnityEditor.Core.IL2CPP.csproj
└── RuntimeUnityEditor.Core.IL2CPP.nuspec
├── RuntimeUnityEditor.Core.Mono
├── RuntimeUnityEditor.Core.Mono.csproj
├── RuntimeUnityEditor.Core.Mono.nuspec
└── packages.config
├── RuntimeUnityEditor.Core
├── AssemblyInfo.cs
├── FeatureBase.cs
├── Features
│ ├── ContextMenu.cs
│ ├── CursorUnlocker.cs
│ ├── Gizmos
│ │ ├── GizmoDrawer.cs
│ │ └── lib
│ │ │ ├── Constants.cs
│ │ │ ├── Drawer.cs
│ │ │ ├── Drawers
│ │ │ ├── ArcDrawer.cs
│ │ │ ├── CubeDrawer.cs
│ │ │ ├── LineDrawer.cs
│ │ │ ├── PolygonDrawer.cs
│ │ │ └── SquareDrawer.cs
│ │ │ ├── Element.cs
│ │ │ ├── Gizmos.cs
│ │ │ └── GizmosInstance.cs
│ ├── MouseInspect.cs
│ └── WireframeFeature.cs
├── RuntimeUnityEditor.Core.projitems
├── RuntimeUnityEditor.Core.shproj
├── RuntimeUnityEditorCore.cs
├── ScreenPartition.cs
├── Utils
│ ├── Abstractions
│ │ ├── AssetBundleManagerHelper.cs
│ │ ├── DataUtility.cs
│ │ ├── DnSpyHelper.cs
│ │ ├── IL2CppAbstractions.cs
│ │ ├── IL2CppExtensions.cs
│ │ ├── ILoggerWrapper.cs
│ │ ├── InitSettings.cs
│ │ ├── LogLevel.cs
│ │ ├── OpenFileDialog.cs
│ │ ├── UnityFeatureHelper.cs
│ │ └── UnityInput.cs
│ ├── ComboBox.cs
│ ├── Extensions.cs
│ ├── IMGUIUtils.cs
│ ├── ImguiComboBox.cs
│ ├── MovingAverage.cs
│ ├── ObjectDumper
│ │ ├── Dumper.cs
│ │ ├── MeshExport.cs
│ │ └── ObjectDumperExtensions.cs
│ ├── OrderedSet.cs
│ ├── ReflectionUtils.cs
│ ├── ResourceUtils.cs
│ ├── TextureUtils.cs
│ ├── ThreadingExtensions.cs
│ ├── TomlTypeConverter.cs
│ ├── TypeNameExtensions.cs
│ └── UI
│ │ ├── InterfaceMaker.cs
│ │ ├── guisharp-box.png
│ │ ├── guisharp-box.xcf
│ │ ├── guisharp-window.png
│ │ └── guisharp-window.xcf
├── WindowBase.cs
├── WindowManager.cs
└── Windows
│ ├── Breakpoints
│ ├── BreakpointHit.cs
│ ├── BreakpointHitException.cs
│ ├── BreakpointPatchInfo.cs
│ ├── Breakpoints.cs
│ ├── BreakpointsWindow.cs
│ └── DebuggerBreakType.cs
│ ├── ChangeHistory
│ ├── Change.cs
│ ├── ChangeAction.cs
│ ├── ChangeAssignment.cs
│ ├── ChangeHistoryWindow.cs
│ └── IChange.cs
│ ├── Clipboard
│ └── ClipboardWindow.cs
│ ├── Inspector
│ ├── Entries
│ │ ├── Contents
│ │ │ ├── CacheEntryBase.cs
│ │ │ ├── CallbackCacheEntey.cs
│ │ │ ├── EventCacheEntry.cs
│ │ │ ├── FieldCacheEntry.cs
│ │ │ ├── ICacheEntry.cs
│ │ │ ├── ListCacheEntry.cs
│ │ │ ├── MethodCacheEntry.cs
│ │ │ ├── PropertyCacheEntry.cs
│ │ │ ├── ReadonlyCacheEntry.cs
│ │ │ └── ReadonlyListCacheEntry.cs
│ │ └── Inspector
│ │ │ ├── InspectorStackEntryBase.cs
│ │ │ ├── InstanceStackEntry.cs
│ │ │ └── StaticStackEntry.cs
│ ├── Inspector.InspectorTab.cs
│ ├── Inspector.cs
│ ├── InspectorHelpObject.cs
│ ├── ToStringConverter.cs
│ └── VariableFieldDrawer.cs
│ ├── ObjectTree
│ ├── ObjectTreeViewer.cs
│ └── RootGameObjectSearcher.cs
│ ├── ObjectView
│ └── ObjectViewWindow.cs
│ ├── Profiler
│ └── ProfilerWindow.cs
│ ├── REPL
│ ├── MCS
│ │ └── ScriptEvaluator.cs
│ ├── REPL.cs
│ ├── REPLWindow.cs
│ ├── ReplHelper.cs
│ ├── Suggestion.cs
│ ├── SuggestionKind.cs
│ └── TypeHelper.cs
│ └── Taskbar.cs
├── RuntimeUnityEditor.UMM
├── Info.json
├── Repository.json
├── RuntimeUnityEditor.UMM.csproj
├── RuntimeUnityEditorSettings.cs
└── RuntimeUnityEditorUMM.cs
├── RuntimeUnityEditor.sln
├── install.ps1
├── modules
└── Directory.Build.props
└── nuget.config
/.github/workflows/nuget.yml:
--------------------------------------------------------------------------------
1 | name: Push to nuget feed on release
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | workflow_dispatch:
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: windows-latest
13 |
14 | env:
15 | NUGET_ENABLE_LEGACY_CSPROJ_PACK: true
16 |
17 | steps:
18 | - name: Checkout
19 | uses: actions/checkout@v1
20 | with:
21 | submodules: true
22 |
23 | - name: Setup Nuget
24 | uses: nuget/setup-nuget@v1
25 |
26 | - name: Nuget pack
27 | working-directory: .
28 | run: |
29 | nuget restore
30 | nuget restore modules\mcs\mcs.sln
31 | gci -Recurse -Filter *.nuspec | foreach { nuget pack "$($_.DirectoryName)\$($_.BaseName).csproj" -build -properties Configuration=Release }
32 |
33 | - name: Nuget push
34 | working-directory: .
35 | env:
36 | NUGET_URL: https://pkgs.dev.azure.com/IllusionMods/Nuget/_packaging/IllusionMods/nuget/v3/index.json
37 | NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
38 | run: |
39 | nuget sources update -name "IllusionMods" -username "token" -password ${env:NUGET_TOKEN}
40 | nuget push *.nupkg -apikey key -noninteractive -skipduplicate -src ${env:NUGET_URL}
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
332 | *.DotSettings
333 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "modules/mcs-unity"]
2 | path = modules/mcs-unity
3 | url = https://github.com/aldelaro5/mcs-unity
4 |
--------------------------------------------------------------------------------
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 6.0
5 |
6 |
7 | https://github.com/ManlyMarco/RuntimeUnityEditor
8 |
9 | Copyright GPL-3 © 2018
10 |
11 | RuntimeUnityEditor
12 |
13 | In-game inspector and debugging tools for applications made with Unity3D game engine
14 |
15 | true
16 | true
17 | embedded
18 | 512
19 |
20 |
21 |
22 |
23 | PreserveNewest
24 |
25 |
26 | PreserveNewest
27 |
28 |
29 |
30 |
31 |
32 |
33 | $(OutputPath)\..\TEMP_COPY_$(AssemblyName)
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
59 |
60 | $(IntermediateOutputPath)GeneratedConstantsFile.cs
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Runtime Unity Editor / Debugging Tools
2 | In-game inspector, editor and interactive console for applications made with Unity3D game engine. It's designed for debugging and modding Unity games, but can also be used as a universal trainer. Runs under [BepInEx5](https://github.com/BepInEx/BepInEx), BepInEx6 IL2CPP and [UMM](https://github.com/newman55/unity-mod-manager).
3 |
4 | ## Features
5 | - Works on most games made in Unity 4.x or newer that use either the mono or IL2CPP runtime (currently IL2CPP support is in beta)
6 | - Minimal impact on the game - no GameObjects or Components are spawned (outside of the plugin component loaded by the mod loader) and no hooks are used (except if requested for profiler)
7 | - GameObject and component browser
8 | - Object inspector (allows modifying values of objects in real time) with clipboard
9 | - REPL C# console with autostart scripts
10 | - Simple Profiler
11 | - Object serialization/dumping
12 | - dnSpy integration (navigate to member in dnSpy)
13 | - Mouse inspect (find objects or UI elements by clicking with mouse)
14 | - Gizmos (Transform origin, Renderer bounds, Collider area, etc.)
15 | - All parts are integrated together (e.g. REPL console can access inspected object, inspector can focus objects on GameObject list, etc.)
16 | - Right click on most objects to bring up a context menu with more options
17 | - and many other...
18 |
19 | 
20 |
21 | ## How to use
22 | RUE is available for different mod loaders in separate builds. They are largely the same, although BepInEx version is the most supported and has some extra features. If you don't already have to use a specific mod loader, BepInEx is recommended.
23 |
24 | ### BepInEx (mono)
25 | 1. Install BepInEx v4.x or v5.x if you don't have it already. You can download it [here](https://github.com/BepInEx/BepInEx).
26 | 2. Download the latest BepInEx build (RuntimeUnityEditor_BepInEx5_vX.X.zip) from the [Releases](https://github.com/ManlyMarco/RuntimeUnityEditor/releases) page. Make sure to get the correct version for your BepInEx.
27 | 3. Extract the BepInEx folder from the archive directly into your game directory (you should already have a BepInEx folder there from previous step). Replace files if asked.
28 | 4. To turn on press the F12 key when in-game. A window should appear on top of the game. If it doesn't appear, check logs for errors.
29 |
30 | Note: If the plugin fails to load under BepInEx 4 with a type load exception, move RuntimeUnityEditor.Core.dll to BepInEx/core folder.
31 |
32 | ### BepInEx (IL2CPP)
33 | **WARNING:** This is a beta build that is unstable and with many features broken. It is likely to not work in many (most?) IL2CPP games, as it relies on unstripped UnityEngine.IMGUIModule.dll (and possibly other game-specific differences). It works in HoneyCome if used together with the [IMGUIModule.Il2Cpp.CoreCLR.Patcher](https://github.com/IllusionMods/BepisPlugins/releases/tag/r19.3.2) which can be used with some other games with some degree of success.
34 |
35 | IL2CPP bug reports will be largely ignored, while PRs to fix issues will be greatly appreciated.
36 |
37 | 1. If you don't have it already, install and configure BepInEx v6 (at least be.664). You can download it [here](https://github.com/BepInEx/BepInEx).
38 | 2. Download the latest RUE release for your version of BepInEx from the [Releases](https://github.com/ManlyMarco/RuntimeUnityEditor/releases) page (make sure it's the IL2CPP version).
39 | 3. Extract the release archive from the archive directly into your game directory (you should already have a BepInEx folder there from previous step). Replace files if asked.
40 | 4. To turn on press the F12 key when in-game. A window should appear on top of the game. If it doesn't appear, check game log for errors.
41 |
42 | ### Unity Mod Manager
43 | 1. Install Unity Mod Manager if you don't have it already. You can download it [here](https://www.nexusmods.com/site/mods/21). Select your game from the the dropdown list and then click the Install button.
44 | 2. Download the latest UMM build (RuntimeUnityEditor_UMM_vX.X.zip) from the [Releases](https://github.com/ManlyMarco/RuntimeUnityEditor/releases) page.
45 | 3. Goto the Mods tab in Unity Mod Manager and drag the RuntimeUnityEditor zip file into the Unity Mod Manager GUI at the bottom where it says drop zip file here.
46 | 4. To turn on press the F12 key when in-game. A window should appear on top of the game. If it doesn't appear, check logs for errors.
47 |
48 |
49 | ## Known issues
50 | - Text is invisible, scrambled, not scaled properly or otherwise looks wrong: Most likely the `Arial.ttf` font is missing from the system (Unity UI default font, may be different in some games). This can happen when running a game on Linux with [misconfigured wine](https://github.com/ManlyMarco/RuntimeUnityEditor/issues/55), and on some regional versions of Windows (e.g. Chinese). To resolve this you have to find the Arial font and install it.
51 | - The C# REPL console is only available in a subset of games. This is because mcs (the current REPL backend) does not work with `.NET Standard` runtime used by default in more recent versions of Unity (because of missing features). There is no fix, the backend will have to be changed, possibly to Lua.
52 | - The wireframe toggle might not work in some games because of an incompatible rendering setup.
53 | - The IL2CPP version is broken in `insert your game name here`. At the moment the main issue is stripped IMGUI assemblies, see https://github.com/ManlyMarco/RuntimeUnityEditor/issues/97
54 |
55 |
56 | ## How to build
57 | 1. Get Visual Studio 2019 (or later).
58 | 2. Clone the repository recursively (`git clone --recursive https://github.com/ManlyMarco/RuntimeUnityEditor`, VS 2022 can do it too).
59 | 3. Open the solution in Visual Studio and hit Build All.
60 |
61 | Notes:
62 | - If you already have the repository cloned or want to update the mcs submodule you need to run `git submodule update --init --recursive` on your local repository (if you have VS 2022 you can do it from the source control tab).
63 | - An old version of UnityEngine.dll (pre-2017) is used for compatibility with all Unity versions 4.x and above, because the new UnityEngine.dll in 2017+ forwards all of the split types into their new respective dll files.
64 |
65 | ---
66 |
67 | You can support development of my plugins through my Patreon page: https://www.patreon.com/ManlyMarco
68 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Bepin5/LogViewer/LogViewerListener.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BepInEx.Logging;
3 | using RuntimeUnityEditor.Core;
4 |
5 | namespace RuntimeUnityEditor.Bepin5.LogViewer
6 | {
7 | internal sealed class LogViewerListener : ILogListener
8 | {
9 | private readonly LogViewerWindow _owner;
10 |
11 | public LogViewerListener(LogViewerWindow owner)
12 | {
13 | _owner = owner;
14 | }
15 |
16 | public void Dispose()
17 | {
18 |
19 | }
20 |
21 | public void LogEvent(object sender, LogEventArgs eventArgs)
22 | {
23 | if ((_owner.LogLevelFilter & eventArgs.Level) == 0)
24 | return;
25 |
26 | try
27 | {
28 | _owner.OnLogEvent(sender, eventArgs);
29 | }
30 | catch (Exception e)
31 | {
32 | RuntimeUnityEditorCore.Logger.Log(Core.Utils.Abstractions.LogLevel.Error, $"[{nameof(LogViewerWindow)}] Unexpected crash when trying to parse stack trace, disabling log capture!" + e);
33 | _owner.Capture = false;
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Bepin5/RuntimeUnityEditor.Bepin5.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net35
5 | Library
6 |
7 | ..\bin\BepInEx5\
8 | false
9 |
10 | BepInEx\plugins\RuntimeUnityEditor
11 |
12 |
13 |
14 | true
15 | True
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | compile
29 | all
30 |
31 |
32 |
33 |
34 |
35 |
36 | compile
37 | all
38 |
39 |
40 | compile
41 | all
42 |
43 |
44 | compile
45 | all
46 |
47 |
48 | compile
49 | all
50 |
51 |
52 | compile
53 | all
54 |
55 |
56 | compile
57 | all
58 |
59 |
60 | compile
61 | all
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Bepin5/RuntimeUnityEditor5.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BepInEx;
3 | using BepInEx.Configuration;
4 | using BepInEx.Logging;
5 | using RuntimeUnityEditor.Bepin5.LogViewer;
6 | using RuntimeUnityEditor.Core;
7 | using RuntimeUnityEditor.Core.Utils.Abstractions;
8 | using UnityEngine;
9 |
10 | namespace RuntimeUnityEditor.Bepin5
11 | {
12 | ///
13 | /// This is a loader plugin for BepInEx5.
14 | /// When referencing RuntimeUnityEditor from other code it's recommended to not reference this assembly and instead reference RuntimeUnityEditorCore directly.
15 | /// If you need your code to run after RUE is initialized, add a [BepInDependency(RuntimeUnityEditorCore.GUID)]
attribute to your plugin.
16 | /// You can see if RuntimeUnityEditor has finished loading with RuntimeUnityEditorCore.IsInitialized()
.
17 | ///
18 | [Obsolete("It's recommended to reference RuntimeUnityEditorCore directly")]
19 | [BepInPlugin(RuntimeUnityEditorCore.GUID, "Runtime Unity Editor", RuntimeUnityEditorCore.Version)]
20 | public class RuntimeUnityEditor5 : BaseUnityPlugin
21 | {
22 | private static RuntimeUnityEditorCore Instance { get; set; }
23 |
24 | private void Start()
25 | {
26 | if (!TomlTypeConverter.CanConvert(typeof(Rect)))
27 | {
28 | var converter = RuntimeUnityEditor.Core.Utils.TomlTypeConverter.GetConverter(typeof(Rect));
29 | TomlTypeConverter.AddConverter(typeof(Rect), new TypeConverter { ConvertToObject = converter.ConvertToObject, ConvertToString = converter.ConvertToString });
30 | }
31 |
32 | Instance = new RuntimeUnityEditorCore(new Bep5InitSettings(this));
33 |
34 | Instance.AddFeature(new LogViewerWindow());
35 | }
36 |
37 | private void Update()
38 | {
39 | Instance.Update();
40 | }
41 |
42 | private void LateUpdate()
43 | {
44 | Instance.LateUpdate();
45 | }
46 |
47 | private void OnGUI()
48 | {
49 | Instance.OnGUI();
50 | }
51 |
52 | private sealed class Bep5InitSettings : InitSettings
53 | {
54 | private readonly RuntimeUnityEditor5 _instance;
55 |
56 | public Bep5InitSettings(RuntimeUnityEditor5 instance)
57 | {
58 | _instance = instance;
59 | LoggerWrapper = new Logger5(_instance.Logger);
60 | }
61 |
62 | protected override Action RegisterSetting(string category, string name, T defaultValue, string description, Action onValueUpdated)
63 | {
64 | var s = _instance.Config.Bind(category, name, defaultValue, description);
65 | s.SettingChanged += (sender, args) => onValueUpdated(s.Value);
66 | onValueUpdated(s.Value);
67 | return x => s.Value = x;
68 | }
69 |
70 | public override MonoBehaviour PluginMonoBehaviour => _instance;
71 | public override ILoggerWrapper LoggerWrapper { get; }
72 | public override string ConfigPath => Paths.ConfigPath;
73 | }
74 |
75 | private sealed class Logger5 : ILoggerWrapper
76 | {
77 | private readonly ManualLogSource _logger;
78 |
79 | public Logger5(ManualLogSource logger)
80 | {
81 | _logger = logger;
82 | }
83 |
84 | public void Log(Core.Utils.Abstractions.LogLevel logLevel, object content)
85 | {
86 | _logger.Log((BepInEx.Logging.LogLevel)logLevel, content);
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Bepin6.IL2CPP/LogViewer/LogViewerListener.cs:
--------------------------------------------------------------------------------
1 | using BepInEx.Logging;
2 | using RuntimeUnityEditor.Core;
3 |
4 | namespace RuntimeUnityEditor.Bepin6.LogViewer
5 | {
6 | internal sealed class LogViewerListener : ILogListener
7 | {
8 | private readonly LogViewerWindow _owner;
9 |
10 | public LogViewerListener(LogViewerWindow owner)
11 | {
12 | _owner = owner;
13 | }
14 |
15 | public void Dispose()
16 | {
17 |
18 | }
19 |
20 | public void LogEvent(object sender, LogEventArgs eventArgs)
21 | {
22 | if ((_owner.LogLevelFilter & eventArgs.Level) == 0)
23 | return;
24 |
25 | try
26 | {
27 | _owner.OnLogEvent(sender, eventArgs);
28 | }
29 | catch (Exception e)
30 | {
31 | RuntimeUnityEditorCore.Logger.Log(Core.Utils.Abstractions.LogLevel.Error, $"[{nameof(LogViewerWindow)}] Unexpected crash when trying to parse stack trace, disabling log capture!" + e);
32 | _owner.Capture = false;
33 | }
34 | }
35 |
36 | public LogLevel LogLevelFilter { get; } = LogLevel.All;
37 | }
38 | }
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Bepin6.IL2CPP/RuntimeUnityEditor.Bepin6.IL2CPP.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | Library
6 |
7 | enable
8 | disable
9 |
10 | ..\bin\BepInEx6-IL2CPP\
11 | false
12 |
13 | BepInEx\plugins\RuntimeUnityEditor
14 |
15 |
16 |
17 | true
18 | True
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | compile
29 | all
30 |
31 |
32 |
33 |
34 |
35 |
36 | compile
37 | all
38 |
39 |
40 | compile
41 | all
42 |
43 |
44 | compile
45 | all
46 |
47 |
48 | compile
49 | all
50 |
51 |
52 | compile
53 | all
54 |
55 |
56 | compile
57 | all
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Bepin6.IL2CPP/RuntimeUnityEditorPluginIL2CPP.cs:
--------------------------------------------------------------------------------
1 | using BepInEx;
2 | using BepInEx.Configuration;
3 | using BepInEx.Logging;
4 | using BepInEx.Unity.IL2CPP;
5 | using RuntimeUnityEditor.Bepin6.LogViewer;
6 | using RuntimeUnityEditor.Core;
7 | using RuntimeUnityEditor.Core.Utils.Abstractions;
8 | using UnityEngine;
9 |
10 | namespace RuntimeUnityEditor.Bepin6.IL2CPP
11 | {
12 | ///
13 | /// This is a loader plugin for BepInEx6 (IL2CPP version).
14 | /// When referencing RuntimeUnityEditor from other code it's recommended to not reference this assembly and instead reference RuntimeUnityEditorCore directly.
15 | /// If you need your code to run after RUE is initialized, add a [BepInDependency(RuntimeUnityEditorCore.GUID)]
attribute to your plugin.
16 | /// You can see if RuntimeUnityEditor has finished loading with RuntimeUnityEditorCore.IsInitialized()
.
17 | ///
18 | [Obsolete("It's recommended to reference RuntimeUnityEditorCore directly")]
19 | [BepInPlugin(RuntimeUnityEditorCore.GUID, "Runtime Unity Editor", RuntimeUnityEditorCore.Version)]
20 | public class RuntimeUnityEditorPluginIL2CPP : BasePlugin
21 | {
22 | private static RuntimeUnityEditorCore _coreInstance = null!;
23 |
24 | ///
25 | public override void Load()
26 | {
27 | if (!TomlTypeConverter.CanConvert(typeof(Rect)))
28 | {
29 | var converter = Core.Utils.TomlTypeConverter.GetConverter(typeof(Rect));
30 | TomlTypeConverter.AddConverter(typeof(Rect), new TypeConverter { ConvertToObject = converter.ConvertToObject, ConvertToString = converter.ConvertToString });
31 | }
32 |
33 | _coreInstance = new RuntimeUnityEditorCore(new Bep6InitSettings(this));
34 |
35 | _coreInstance.AddFeature(new LogViewerWindow());
36 | }
37 |
38 | private class RuntimeUnityEditorHelper : MonoBehaviour
39 | {
40 |
41 | private void Update()
42 | {
43 | _coreInstance.Update();
44 | }
45 |
46 | private void LateUpdate()
47 | {
48 | _coreInstance.LateUpdate();
49 | }
50 |
51 | private void OnGUI()
52 | {
53 | _coreInstance.OnGUI();
54 | }
55 | }
56 |
57 | private sealed class Bep6InitSettings : InitSettings
58 | {
59 | private readonly RuntimeUnityEditorPluginIL2CPP _instance;
60 | private readonly RuntimeUnityEditorHelper _helper;
61 |
62 | public Bep6InitSettings(RuntimeUnityEditorPluginIL2CPP instance)
63 | {
64 | _instance = instance ?? throw new ArgumentNullException(nameof(instance));
65 | _helper = instance.AddComponent();
66 | LoggerWrapper = new Logger6(_instance.Log);
67 | }
68 |
69 | protected override Action RegisterSetting(string category, string name, T defaultValue, string description, Action onValueUpdated)
70 | {
71 | var s = _instance.Config.Bind(category, name, defaultValue, description);
72 | s.SettingChanged += (sender, args) => onValueUpdated(s.Value);
73 | onValueUpdated(s.Value);
74 | return x => s.Value = x;
75 | }
76 |
77 | public override MonoBehaviour PluginMonoBehaviour => _helper;
78 | public override ILoggerWrapper LoggerWrapper { get; }
79 | public override string ConfigPath => Paths.ConfigPath;
80 | }
81 |
82 | private sealed class Logger6 : ILoggerWrapper
83 | {
84 | private readonly ManualLogSource _logger;
85 |
86 | public Logger6(ManualLogSource logger)
87 | {
88 | _logger = logger;
89 | }
90 |
91 | public void Log(Core.Utils.Abstractions.LogLevel logLevel, object content)
92 | {
93 | _logger.Log((BepInEx.Logging.LogLevel)logLevel, content);
94 | }
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core.IL2CPP/Libs/Unity.InputSystem.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ManlyMarco/RuntimeUnityEditor/1cb4bc68ece99c0d0b7bdf9149831f8a59ca0dcb/RuntimeUnityEditor.Core.IL2CPP/Libs/Unity.InputSystem.dll
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core.IL2CPP/RuntimeUnityEditor.Core.IL2CPP.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | Library
6 |
7 | RuntimeUnityEditor.Core
8 |
9 | disable
10 | disable
11 | true
12 |
13 | ..\bin\Core-IL2CPP\
14 | false
15 |
16 | $(DefineConstants);IL2CPP
17 |
18 |
19 |
20 | true
21 | True
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | Libs\Unity.InputSystem.dll
38 | False
39 |
40 |
41 |
42 |
43 |
44 | compile
45 | all
46 |
47 |
48 | compile
49 | all
50 |
51 |
52 | compile
53 | all
54 |
55 |
56 | compile
57 | all
58 |
59 |
60 | compile
61 | all
62 |
63 |
64 | compile
65 | all
66 |
67 |
68 | compile
69 | all
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core.IL2CPP/RuntimeUnityEditor.Core.IL2CPP.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | RuntimeUnityEditor.Core.IL2CPP
5 | $version$
6 | ManlyMarco
7 | https://github.com/ManlyMarco/RuntimeUnityEditor
8 | false
9 | In-game inspector and debugging tools for applications made with Unity3D game engine (BepInEx6 IL2CPP version)
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core.Mono/RuntimeUnityEditor.Core.Mono.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net35
5 | Library
6 |
7 | RuntimeUnityEditor.Core
8 | RuntimeUnityEditor.Core
9 |
10 | ..\bin\Core-Mono\
11 | false
12 |
13 |
14 |
15 | true
16 | True
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | compile
32 | all
33 |
34 |
35 | compile
36 | all
37 |
38 |
39 | compile
40 | all
41 |
42 |
43 | compile
44 | all
45 |
46 |
47 | compile
48 | all
49 |
50 |
51 | compile
52 | all
53 |
54 |
55 | compile
56 | all
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core.Mono/RuntimeUnityEditor.Core.Mono.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | RuntimeUnityEditor.Core
5 | $version$
6 | ManlyMarco
7 | https://github.com/ManlyMarco/RuntimeUnityEditor
8 | false
9 | In-game inspector and debugging tools for applications made with Unity3D game engine
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core.Mono/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | [assembly: InternalsVisibleTo("RuntimeUnityEditor.Bepin5")]
4 | [assembly: InternalsVisibleTo("RuntimeUnityEditor.Bepin6.IL2CPP")]
5 | [assembly: InternalsVisibleTo("RuntimeUnityEditor.UMM")]
6 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/CursorUnlocker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using RuntimeUnityEditor.Core.Utils.Abstractions;
4 | using UnityEngine;
5 |
6 | #pragma warning disable CS1591
7 |
8 | namespace RuntimeUnityEditor.Core
9 | {
10 | ///
11 | /// Feature that forces the mouse cursor to stay unlocked/visible. Might cause issues with some games, especially FPSes.
12 | ///
13 | public sealed class CursorUnlocker : FeatureBase
14 | {
15 | private bool _obsoleteCursor;
16 |
17 | private PropertyInfo _curLockState;
18 | private PropertyInfo _curVisible;
19 |
20 | private int _previousCursorLockState;
21 | private bool _previousCursorVisible;
22 |
23 | protected override void Initialize(InitSettings initSettings)
24 | {
25 | // Reflection for compatibility with Unity 4.x
26 | var tCursor = typeof(Cursor);
27 |
28 | _curLockState = tCursor.GetProperty("lockState", BindingFlags.Static | BindingFlags.Public);
29 | _curVisible = tCursor.GetProperty("visible", BindingFlags.Static | BindingFlags.Public);
30 |
31 | if (_curLockState == null || _curVisible == null)
32 | {
33 | _obsoleteCursor = true;
34 |
35 | _curLockState = typeof(Screen).GetProperty("lockCursor", BindingFlags.Static | BindingFlags.Public);
36 | _curVisible = typeof(Screen).GetProperty("showCursor", BindingFlags.Static | BindingFlags.Public);
37 |
38 | if (_curLockState == null || _curVisible == null)
39 | throw new InvalidOperationException("Unsupported Cursor class");
40 | }
41 |
42 | DisplayName = "Unlock cursor";
43 | Enabled = true;
44 | DisplayType = FeatureDisplayType.Hidden;
45 | }
46 |
47 | protected override void Update()
48 | {
49 | if (_obsoleteCursor)
50 | _curLockState.SetValue(null, false, null);
51 | else
52 | _curLockState.SetValue(null, 0, null);
53 |
54 | _curVisible.SetValue(null, true, null);
55 | }
56 |
57 | protected override void LateUpdate()
58 | {
59 | if (_obsoleteCursor)
60 | _curLockState.SetValue(null, false, null);
61 | else
62 | _curLockState.SetValue(null, 0, null);
63 |
64 | _curVisible.SetValue(null, true, null);
65 | }
66 |
67 | protected override void OnGUI()
68 | {
69 | if (_obsoleteCursor)
70 | _curLockState.SetValue(null, false, null);
71 | else
72 | _curLockState.SetValue(null, 0, null);
73 |
74 | _curVisible.SetValue(null, true, null);
75 | }
76 |
77 | protected override void VisibleChanged(bool visible)
78 | {
79 | if (visible)
80 | {
81 | _previousCursorLockState = _obsoleteCursor ? Convert.ToInt32((bool)_curLockState.GetValue(null, null)) : (int)_curLockState.GetValue(null, null);
82 | _previousCursorVisible = (bool)_curVisible.GetValue(null, null);
83 | }
84 | else
85 | {
86 | if (!_previousCursorVisible || _previousCursorLockState != 0)
87 | {
88 | if (_obsoleteCursor)
89 | _curLockState.SetValue(null, Convert.ToBoolean(_previousCursorLockState), null);
90 | else
91 | _curLockState.SetValue(null, _previousCursorLockState, null);
92 |
93 | _curVisible.SetValue(null, _previousCursorVisible, null);
94 | }
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Constants.cs:
--------------------------------------------------------------------------------
1 | namespace RuntimeUnityEditor.Core.Gizmos.lib
2 | {
3 | internal class Constants
4 | {
5 | public const string UniqueIdentifier = "Popcron.Gizmos";
6 | public const string EnabledKey = UniqueIdentifier + ".Enabled";
7 | }
8 | }
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Drawer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using RuntimeUnityEditor.Core.Gizmos.lib.Drawers;
4 | using UnityEngine;
5 |
6 | namespace RuntimeUnityEditor.Core.Gizmos.lib
7 | {
8 | internal abstract class Drawer
9 | {
10 | private static Dictionary typeToDrawer = null;
11 |
12 | public abstract int Draw(ref Vector3[] buffer, params object[] args);
13 |
14 | public Drawer()
15 | {
16 |
17 | }
18 |
19 | public static Drawer Get() where T : class
20 | {
21 | //find all drawers
22 | if (typeToDrawer == null)
23 | {
24 | typeToDrawer = new Dictionary();
25 |
26 | //add defaults
27 | typeToDrawer.Add(typeof(CubeDrawer), new CubeDrawer());
28 | typeToDrawer.Add(typeof(LineDrawer), new LineDrawer());
29 | typeToDrawer.Add(typeof(PolygonDrawer), new PolygonDrawer());
30 | typeToDrawer.Add(typeof(SquareDrawer), new SquareDrawer());
31 | typeToDrawer.Add(typeof(ArcDrawer), new ArcDrawer());
32 |
33 | ////find extras
34 | //var types = AccessTools.AllTypes();
35 | //foreach (Type type in types)
36 | //{
37 | // if (type.IsAbstract)
38 | // {
39 | // continue;
40 | // }
41 | //
42 | // if (type.IsSubclassOf(typeof(Drawer)) && !typeToDrawer.ContainsKey(type))
43 | // {
44 | // try
45 | // {
46 | // Drawer value = (Drawer)Activator.CreateInstance(type);
47 | // typeToDrawer[type] = value;
48 | // }
49 | // catch (Exception e)
50 | // {
51 | // Debug.LogError($"couldnt register drawer of type {type} because {e.Message}");
52 | // }
53 | // }
54 | //}
55 | }
56 |
57 | if (typeToDrawer.TryGetValue(typeof(T), out Drawer drawer))
58 | {
59 | return drawer;
60 | }
61 | else
62 | {
63 | return null;
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Drawers/ArcDrawer.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace RuntimeUnityEditor.Core.Gizmos.lib.Drawers
4 | {
5 | internal class ArcDrawer : Drawer
6 | {
7 | public ArcDrawer()
8 | {
9 |
10 | }
11 |
12 | public override int Draw(ref Vector3[] buffer, params object[] values)
13 | {
14 | Vector3 position = (Vector3)values[0];
15 | int points = (int)values[1];
16 | float radius = (float)values[2];
17 | float offset = (float)values[3];
18 | Quaternion rotation = (Quaternion)values[4];
19 | var angle = (float)values[5];
20 |
21 | float step = 360f / points;
22 | offset *= Mathf.Deg2Rad;
23 |
24 | for (int i = 0; i < points; i++)
25 | {
26 | float cx = Mathf.Cos(Mathf.Deg2Rad * step * i + offset) * radius;
27 | float cy = Mathf.Sin(Mathf.Deg2Rad * step * i + offset) * radius;
28 | Vector3 current = new Vector3(cx, cy);
29 |
30 | float nx = Mathf.Cos(Mathf.Deg2Rad * step * (i + 1) + offset) * radius;
31 | float ny = Mathf.Sin(Mathf.Deg2Rad * step * (i + 1) + offset) * radius;
32 | Vector3 next = new Vector3(nx, ny);
33 |
34 | buffer[i * 2] = position + (rotation * current);
35 | buffer[(i * 2) + 1] = position + (rotation * next);
36 |
37 | if ((angle -= step) <= 0) break;
38 | }
39 |
40 | return points * 2;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Drawers/CubeDrawer.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace RuntimeUnityEditor.Core.Gizmos.lib.Drawers
4 | {
5 | internal class CubeDrawer : Drawer
6 | {
7 | public CubeDrawer()
8 | {
9 |
10 | }
11 |
12 | public override int Draw(ref Vector3[] buffer, params object[] values)
13 | {
14 | Vector3 position = (Vector3)values[0];
15 | Quaternion rotation = (Quaternion)values[1];
16 | Vector3 size = (Vector3)values[2];
17 |
18 | size *= 0.5f;
19 |
20 | Vector3 point1 = new Vector3(position.x - size.x, position.y - size.y, position.z - size.z);
21 | Vector3 point2 = new Vector3(position.x + size.x, position.y - size.y, position.z - size.z);
22 | Vector3 point3 = new Vector3(position.x + size.x, position.y + size.y, position.z - size.z);
23 | Vector3 point4 = new Vector3(position.x - size.x, position.y + size.y, position.z - size.z);
24 |
25 | Vector3 point5 = new Vector3(position.x - size.x, position.y - size.y, position.z + size.z);
26 | Vector3 point6 = new Vector3(position.x + size.x, position.y - size.y, position.z + size.z);
27 | Vector3 point7 = new Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
28 | Vector3 point8 = new Vector3(position.x - size.x, position.y + size.y, position.z + size.z);
29 |
30 | point1 = rotation * (point1 - position);
31 | point1 += position;
32 |
33 | point2 = rotation * (point2 - position);
34 | point2 += position;
35 |
36 | point3 = rotation * (point3 - position);
37 | point3 += position;
38 |
39 | point4 = rotation * (point4 - position);
40 | point4 += position;
41 |
42 | point5 = rotation * (point5 - position);
43 | point5 += position;
44 |
45 | point6 = rotation * (point6 - position);
46 | point6 += position;
47 |
48 | point7 = rotation * (point7 - position);
49 | point7 += position;
50 |
51 | point8 = rotation * (point8 - position);
52 | point8 += position;
53 |
54 | //square
55 | buffer[0] = point1;
56 | buffer[1] = point2;
57 |
58 | buffer[2] = point2;
59 | buffer[3] = point3;
60 |
61 | buffer[4] = point3;
62 | buffer[5] = point4;
63 |
64 | buffer[6] = point4;
65 | buffer[7] = point1;
66 |
67 | //other square
68 | buffer[8] = point5;
69 | buffer[9] = point6;
70 |
71 | buffer[10] = point6;
72 | buffer[11] = point7;
73 |
74 | buffer[12] = point7;
75 | buffer[13] = point8;
76 |
77 | buffer[14] = point8;
78 | buffer[15] = point5;
79 |
80 | //connectors
81 | buffer[16] = point1;
82 | buffer[17] = point5;
83 |
84 | buffer[18] = point2;
85 | buffer[19] = point6;
86 |
87 | buffer[20] = point3;
88 | buffer[21] = point7;
89 |
90 | buffer[22] = point4;
91 | buffer[23] = point8;
92 |
93 | return 24;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Drawers/LineDrawer.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace RuntimeUnityEditor.Core.Gizmos.lib.Drawers
4 | {
5 | internal class LineDrawer : Drawer
6 | {
7 | public LineDrawer()
8 | {
9 |
10 | }
11 |
12 | public override int Draw(ref Vector3[] buffer, params object[] args)
13 | {
14 | buffer[0] = (Vector3)args[0];
15 | buffer[1] = (Vector3)args[1];
16 | return 2;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Drawers/PolygonDrawer.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace RuntimeUnityEditor.Core.Gizmos.lib.Drawers
4 | {
5 | internal class PolygonDrawer : Drawer
6 | {
7 | public PolygonDrawer()
8 | {
9 |
10 | }
11 |
12 | public override int Draw(ref Vector3[] buffer, params object[] values)
13 | {
14 | Vector3 position = (Vector3)values[0];
15 | int points = (int)values[1];
16 | float radius = (float)values[2];
17 | float offset = (float)values[3];
18 | Quaternion rotation = (Quaternion)values[4];
19 |
20 | float step = 360f / points;
21 | offset *= Mathf.Deg2Rad;
22 |
23 | for (int i = 0; i < points; i++)
24 | {
25 | float cx = Mathf.Cos(Mathf.Deg2Rad * step * i + offset) * radius;
26 | float cy = Mathf.Sin(Mathf.Deg2Rad * step * i + offset) * radius;
27 | Vector3 current = new Vector3(cx, cy);
28 |
29 | float nx = Mathf.Cos(Mathf.Deg2Rad * step * (i + 1) + offset) * radius;
30 | float ny = Mathf.Sin(Mathf.Deg2Rad * step * (i + 1) + offset) * radius;
31 | Vector3 next = new Vector3(nx, ny);
32 |
33 | buffer[i * 2] = position + (rotation * current);
34 | buffer[(i * 2) + 1] = position + (rotation * next);
35 | }
36 |
37 | return points * 2;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Drawers/SquareDrawer.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace RuntimeUnityEditor.Core.Gizmos.lib.Drawers
4 | {
5 | internal class SquareDrawer : Drawer
6 | {
7 | public SquareDrawer()
8 | {
9 |
10 | }
11 |
12 | public override int Draw(ref Vector3[] buffer, params object[] values)
13 | {
14 | Vector2 position = default;
15 | if (values[0] is Vector2 p2)
16 | {
17 | position = p2;
18 | }
19 | else if (values[0] is Vector3 p3)
20 | {
21 | position = p3;
22 | }
23 |
24 | Quaternion rotation = (Quaternion)values[1];
25 |
26 | Vector2 size = default;
27 | if (values[2] is Vector2 s2)
28 | {
29 | size = s2;
30 | }
31 | else if (values[2] is Vector3 s3)
32 | {
33 | size = s3;
34 | }
35 |
36 | size *= 0.5f;
37 |
38 | Vector2 point1 = new Vector3(position.x - size.x, position.y - size.y);
39 | Vector2 point2 = new Vector3(position.x + size.x, position.y - size.y);
40 | Vector2 point3 = new Vector3(position.x + size.x, position.y + size.y);
41 | Vector2 point4 = new Vector3(position.x - size.x, position.y + size.y);
42 |
43 | point1 = rotation * (point1 - position);
44 | point1 += position;
45 |
46 | point2 = rotation * (point2 - position);
47 | point2 += position;
48 |
49 | point3 = rotation * (point3 - position);
50 | point3 += position;
51 |
52 | point4 = rotation * (point4 - position);
53 | point4 += position;
54 |
55 | //square
56 | buffer[0] = point1;
57 | buffer[1] = point2;
58 |
59 | buffer[2] = point2;
60 | buffer[3] = point3;
61 |
62 | buffer[4] = point3;
63 | buffer[5] = point4;
64 |
65 | //loop back to start
66 | buffer[6] = point4;
67 | buffer[7] = point1;
68 |
69 | return 8;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/Gizmos/lib/Element.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace RuntimeUnityEditor.Core.Gizmos.lib
4 | {
5 | internal class Element
6 | {
7 | public Vector3[] points = { };
8 | public Color color = Color.white;
9 | public bool dashed = false;
10 | }
11 | }
--------------------------------------------------------------------------------
/RuntimeUnityEditor.Core/Features/MouseInspect.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Text;
4 | using RuntimeUnityEditor.Core.ObjectTree;
5 | using RuntimeUnityEditor.Core.Utils;
6 | using RuntimeUnityEditor.Core.Utils.Abstractions;
7 | using UnityEngine;
8 |
9 | #pragma warning disable CS1591
10 |
11 | namespace RuntimeUnityEditor.Core
12 | {
13 | ///
14 | /// Feature that shows information about GameObjects and Canvas elements located directly under the mouse cursor.
15 | ///
16 | public class MouseInspect : FeatureBase
17 | {
18 | private static readonly StringBuilder _hoverTextSb = new StringBuilder(100);
19 | private static string _hoverText = string.Empty;
20 | private GUIStyle _labelSkin;
21 |
22 | protected override void Initialize(InitSettings initSettings)
23 | {
24 | DisplayName = "Mouse inspect";
25 | }
26 |
27 | protected override void Update()
28 | {
29 | var camera = Camera.main;
30 | var raycastHit = DoRaycast(camera);
31 | var canvasHits = DoCanvas(camera);
32 |
33 | var selectedTransform = ObjectTreeViewer.Instance.SelectedTransform;
34 |
35 | _hoverTextSb.Length = 0;
36 |
37 | if (raycastHit != null)
38 | {
39 | _hoverTextSb.AppendFormat("Raycast hit:\n{0}0: {1} pos={2}\n", selectedTransform == raycastHit ? "> " : "", raycastHit.name, raycastHit.position);
40 | }
41 |
42 | if (canvasHits.Count > 0)
43 | {
44 | _hoverTextSb.AppendLine("Canvas hits:");
45 | for (var index = 0; index < canvasHits.Count && index < 10; index++)
46 | {
47 | var hit = canvasHits[index];
48 | _hoverTextSb.AppendFormat("{0}{1}: {2} pos={3} size={4}\n", selectedTransform == hit ? "> " : "", index + 1, hit.name, hit.position, hit.sizeDelta);
49 | }
50 | }
51 |
52 | if (_hoverTextSb.Length > 0)
53 | {
54 | if (ObjectTreeViewer.Initialized)
55 | {
56 | _hoverTextSb.Append("[ Press Middle Mouse Button to browse to the next object ]");
57 | if (UnityInput.Current.GetMouseButtonDown(2))
58 | {
59 | var all = Enumerable.Repeat(raycastHit, 1).Concat(canvasHits.Cast()).Where(x => x != null).ToList();
60 |
61 | var currentIndex = all.IndexOf(selectedTransform);
62 | // If nothing is selected -1 + 1 = 0 so start from 0
63 | var nextObject = all.Concat(all).Skip(currentIndex + 1).First();
64 |
65 | ObjectTreeViewer.Instance.SelectAndShowObject(nextObject);
66 | }
67 | }
68 |
69 | _hoverText = _hoverTextSb.ToString();
70 | }
71 | else
72 | {
73 | _hoverText = string.Empty;
74 | }
75 | }
76 |
77 | protected override void OnGUI()
78 | {
79 | if (_hoverText.Length > 0)
80 | {
81 | if (_labelSkin == null) _labelSkin = GUI.skin.label.CreateCopy();
82 |
83 | // Figure out which corner of the screen to draw the hover text in
84 | _labelSkin.alignment = TextAnchor.UpperLeft;
85 |
86 | var pos = UnityInput.Current.mousePosition;
87 | var displayRect = new Rect((int)pos.x + 5, Screen.height - (int)pos.y + 20, (int)(Screen.width / 2), 500);
88 |
89 | if ((int)displayRect.x > Screen.width / 2)
90 | {
91 | displayRect.x = (int)(displayRect.x - displayRect.width);
92 | _labelSkin.alignment = TextAnchor.UpperRight;
93 | }
94 |
95 | if ((int)displayRect.y > Screen.height / 2)
96 | {
97 | displayRect.y = (int)(displayRect.y - (displayRect.height + 23));
98 | // Upper -> Lower
99 | _labelSkin.alignment += TextAnchor.LowerRight - TextAnchor.UpperRight;
100 | }
101 |
102 | IMGUIUtils.DrawLabelWithOutline(displayRect, _hoverText, _labelSkin, Color.white, Color.black, 2);
103 | }
104 | }
105 |
106 | private static Transform DoRaycast(Camera camera)
107 | {
108 | if (camera == null) return null;
109 | // Based on https://github.com/sinai-dev/CppExplorer/blob/master/src/Menu/InspectUnderMouse.cs (MIT License)
110 | var ray = camera.ScreenPointToRay(UnityInput.Current.mousePosition);
111 | return Physics.Raycast(ray, out RaycastHit hit, 1000f) ? hit.transform : null;
112 | }
113 |
114 | private static List DoCanvas(Camera camera)
115 | {
116 | Vector2 mousePosition = UnityInput.Current.mousePosition;
117 |
118 | var hits = Object.FindObjectsOfType().Where(rt =>
119 | {
120 | // Only RTs that are visible on screen
121 | if (rt && rt.sizeDelta.x > 0 && rt.sizeDelta.y > 0 && rt.gameObject.activeInHierarchy)
122 | {
123 | var canvas = rt.GetComponentInParent