2021-06-05 19:36:09 +10:00
|
|
|
|
using Mono.CSharp;
|
|
|
|
|
using System;
|
2021-03-25 18:39:35 +11:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2021-05-14 06:14:25 +10:00
|
|
|
|
using System.Text;
|
2021-06-05 19:36:09 +10:00
|
|
|
|
using UnityEngine;
|
2022-01-17 19:42:05 +11:00
|
|
|
|
using UnityExplorer.Runtime;
|
2021-12-02 18:35:46 +11:00
|
|
|
|
using UniverseLib;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2021-06-30 07:49:58 +10:00
|
|
|
|
namespace UnityExplorer.CSConsole
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
public class ScriptInteraction : InteractiveBase
|
|
|
|
|
{
|
2021-05-14 02:45:59 +10:00
|
|
|
|
public static void Log(object message)
|
2021-05-11 19:15:46 +10:00
|
|
|
|
{
|
2021-05-14 02:45:59 +10:00
|
|
|
|
ExplorerCore.Log(message);
|
2021-05-11 19:15:46 +10:00
|
|
|
|
}
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2021-05-14 02:45:59 +10:00
|
|
|
|
public static object CurrentTarget => InspectorManager.ActiveInspector?.Target;
|
|
|
|
|
|
2021-05-15 01:21:07 +10:00
|
|
|
|
public static object[] AllTargets => InspectorManager.Inspectors.Select(it => it.Target).ToArray();
|
2021-05-14 02:45:59 +10:00
|
|
|
|
|
2021-05-11 19:15:46 +10:00
|
|
|
|
public static void Inspect(object obj)
|
|
|
|
|
{
|
|
|
|
|
InspectorManager.Inspect(obj);
|
|
|
|
|
}
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2021-05-11 19:15:46 +10:00
|
|
|
|
public static void Inspect(Type type)
|
|
|
|
|
{
|
|
|
|
|
InspectorManager.Inspect(type);
|
|
|
|
|
}
|
2021-05-14 02:45:59 +10:00
|
|
|
|
|
2021-05-15 01:21:07 +10:00
|
|
|
|
public static void Start(IEnumerator ienumerator)
|
2021-05-14 02:45:59 +10:00
|
|
|
|
{
|
|
|
|
|
RuntimeProvider.Instance.StartCoroutine(ienumerator);
|
|
|
|
|
}
|
2021-05-14 06:14:25 +10:00
|
|
|
|
|
|
|
|
|
public static void GetUsing()
|
|
|
|
|
{
|
|
|
|
|
Log(Evaluator.GetUsing());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void GetVars()
|
|
|
|
|
{
|
2021-05-15 01:21:07 +10:00
|
|
|
|
var vars = Evaluator.GetVars()?.Trim();
|
|
|
|
|
if (string.IsNullOrEmpty(vars))
|
|
|
|
|
ExplorerCore.LogWarning("No variables seem to be defined!");
|
|
|
|
|
else
|
|
|
|
|
Log(vars);
|
2021-05-14 06:14:25 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void GetClasses()
|
|
|
|
|
{
|
|
|
|
|
if (ReflectionUtility.GetFieldInfo(typeof(Evaluator), "source_file")
|
2021-06-05 19:36:09 +10:00
|
|
|
|
.GetValue(Evaluator) is CompilationSourceFile sourceFile
|
2021-05-14 06:14:25 +10:00
|
|
|
|
&& sourceFile.Containers.Any())
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
sb.Append($"There are {sourceFile.Containers.Count} defined classes:");
|
|
|
|
|
foreach (TypeDefinition type in sourceFile.Containers.Where(it => it is TypeDefinition))
|
|
|
|
|
{
|
|
|
|
|
sb.Append($"\n\n{type.MemberName.Name}:");
|
|
|
|
|
foreach (var member in type.Members)
|
|
|
|
|
sb.Append($"\n\t- {member.AttributeTargets}: \"{member.MemberName.Name}\" ({member.ModFlags})");
|
|
|
|
|
}
|
|
|
|
|
Log(sb.ToString());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ExplorerCore.LogWarning("No classes seem to be defined.");
|
|
|
|
|
|
|
|
|
|
}
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
2021-07-07 23:21:40 +10:00
|
|
|
|
}
|