Skip to content

Instantly share code, notes, and snippets.

@adrianoc

adrianoc/Dump.cs Secret

Created September 27, 2022 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianoc/95cb52fcfafd2517a098d4add71d8295 to your computer and use it in GitHub Desktop.
Save adrianoc/95cb52fcfafd2517a098d4add71d8295 to your computer and use it in GitHub Desktop.
Dumps some paths used internaly by Unity tools
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using UnityEditor;
using System;
public class Dump
{
[MenuItem("Tools/Dump Search Paths")]
public static void DumpSearchPaths()
{
var editorAssembly = typeof(MenuItem).Assembly;
var mlh = editorAssembly.GetType("UnityEditor.Scripting.ScriptCompilation.MonoLibraryHelpers");
Debug.Log($"mlh = {mlh != null} Assembly = {editorAssembly.Location}");
var gsrd = mlh.GetMethod("GetSystemReferenceDirectories", BindingFlags.Static | BindingFlags.Public, null, new [] { typeof(UnityEditor.ApiCompatibilityLevel) }, null);
var del= (Func<UnityEditor.ApiCompatibilityLevel, string[]>) gsrd.CreateDelegate(typeof(Func<UnityEditor.ApiCompatibilityLevel, string[]>));
var ebs = typeof(EditorUserBuildSettings);
var abtg = ebs.GetProperty("activeBuildTargetGroup", BindingFlags.Static | BindingFlags.NonPublic);
var btg = (BuildTargetGroup) abtg.GetValue(null);
var paths = del(PlayerSettings.GetApiCompatibilityLevel(btg));
Debug.Log($"Search Paths:\n------------------------------------------------------------\n{string.Join("\n", paths)}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment