chore(unity): 固定Unity CLI Loop本地包并移除UnitySkills依赖

This commit is contained in:
Liubing\LB
2026-09-28 18:14:59 +08:00
parent 0eb43b2b40
commit c4ae02def9
952 changed files with 70137 additions and 11 deletions

View File

@@ -0,0 +1,84 @@
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace io.github.hatayama.uLoopMCP
{
/// <summary>
/// Bridge class for accessing Unity GameView internal APIs via reflection.
/// GameView is an internal class; this bridge discovers members dynamically.
/// </summary>
public static class GameViewBridge
{
private static Type _gameViewType;
private static FieldInfo _renderTextureField;
private static bool _memberSearchDone;
/// <summary>
/// Get the GameView's composited RenderTexture containing all cameras + Screen Space Overlay Canvas.
/// </summary>
/// <returns>The RenderTexture, or null if GameView not found or field not accessible</returns>
public static RenderTexture GetRenderTexture()
{
EnsureMembersResolved();
EditorWindow gameView = FindMainGameView();
if (gameView == null || _renderTextureField == null)
{
return null;
}
return _renderTextureField.GetValue(gameView) as RenderTexture;
}
private static EditorWindow FindMainGameView()
{
if (_gameViewType == null)
{
return null;
}
UnityEngine.Object[] gameViews = Resources.FindObjectsOfTypeAll(_gameViewType);
if (gameViews.Length == 0)
{
return null;
}
// Prefer focused window to match editor's active view context
foreach (UnityEngine.Object gv in gameViews)
{
EditorWindow window = gv as EditorWindow;
if (window != null && window.hasFocus)
{
return window;
}
}
return gameViews[0] as EditorWindow;
}
private static void EnsureMembersResolved()
{
if (_memberSearchDone)
{
return;
}
_memberSearchDone = true;
_gameViewType = typeof(Editor).Assembly.GetType("UnityEditor.GameView");
if (_gameViewType == null)
{
Debug.LogWarning("[GameViewBridge] GameView type not found");
return;
}
_renderTextureField = _gameViewType.GetField("m_RenderTexture",
BindingFlags.Instance | BindingFlags.NonPublic);
if (_renderTextureField == null)
{
Debug.LogWarning("[GameViewBridge] m_RenderTexture field not found");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ffc5f144655b14111a8bfd75811c5ec2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using System.Reflection;
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
namespace io.github.hatayama.uLoopMCP
{
/// <summary>
/// Bridge class for accessing Unity internal APIs.
/// Uses Unity.InternalAPIEditorBridge assembly name to access internal members via InternalsVisibleTo.
/// </summary>
public static class InternalEditorUtilityBridge
{
private static Material _blitSceneViewCaptureMat;
/// <summary>
/// Capture an EditorWindow to a RenderTexture using Unity internal GrabPixels method.
/// Considers pixelsPerPoint for Retina/HiDPI displays.
/// </summary>
/// <param name="window">The EditorWindow to capture</param>
/// <param name="rt">The RenderTexture to capture into</param>
public static void CaptureEditorWindow(EditorWindow window, RenderTexture rt)
{
if (window == null || rt == null)
{
return;
}
if (_blitSceneViewCaptureMat == null)
{
FieldInfo blitMatField = typeof(InternalEditorUtility).GetField(
"blitSceneViewCaptureMat",
BindingFlags.Static | BindingFlags.NonPublic);
if (blitMatField != null)
{
_blitSceneViewCaptureMat = blitMatField.GetValue(null) as Material;
}
if (_blitSceneViewCaptureMat == null)
{
_blitSceneViewCaptureMat = EditorGUIUtility.LoadRequired("SceneView/BlitSceneViewCapture.mat") as Material;
if (blitMatField != null)
{
blitMatField.SetValue(null, _blitSceneViewCaptureMat);
}
}
}
// When in Linear color space, use a RenderTexture with sRGB write disabled
// to prevent double gamma correction from BlitSceneViewCapture.mat
RenderTextureDescriptor descriptor = rt.descriptor;
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
{
descriptor.sRGB = false;
}
RenderTexture temporary = RenderTexture.GetTemporary(descriptor);
float scale = EditorGUIUtility.pixelsPerPoint;
Rect rect = new Rect(0.0f, 0.0f, window.position.width * scale, window.position.height * scale);
// m_Parent is the HostView/DockArea that contains the EditorWindow
// GrabPixels is an internal method that captures the view contents
window.m_Parent.GrabPixels(temporary, rect);
Graphics.Blit(temporary, rt, _blitSceneViewCaptureMat);
RenderTexture.ReleaseTemporary(temporary);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 39e7587173e6d4dc1b01299a7eae9476
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
{
"name": "Unity.InternalAPIEditorBridge.024",
"rootNamespace": "io.github.hatayama.uLoopMCP",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5079a8d3a72924a81aa1cbc25f65ed1b
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: