From 9f83fd74ec370ecd983a1a1a837864f96b04c5bd Mon Sep 17 00:00:00 2001
From: LiRuoChen <571244399@qq.com>
Date: Fri, 10 Jul 2026 12:20:54 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E6=89=80=E6=9C=89=E7=9A=84?=
=?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Editor/Scripts/UniWindowControllerBatch.cs | 10 +--
Editor/Scripts/UniWindowControllerEditor.cs | 92 ++++++++++-----------
Runtime/Scripts/LowLevel/UniWinCore.cs | 10 +--
Samples~/Common/InputProxy.cs | 20 ++---
Samples~/Common/ModelController.cs | 20 ++---
5 files changed, 76 insertions(+), 76 deletions(-)
diff --git a/Editor/Scripts/UniWindowControllerBatch.cs b/Editor/Scripts/UniWindowControllerBatch.cs
index f6a8de0..3a872c4 100644
--- a/Editor/Scripts/UniWindowControllerBatch.cs
+++ b/Editor/Scripts/UniWindowControllerBatch.cs
@@ -1,4 +1,4 @@
-using UnityEngine;
+using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
@@ -11,7 +11,7 @@ namespace Kirurobo
//[MenuItem("Build/Build OSX")]
static void PerformBuild()
{
- // コマンドライン引数の最後が出力パスだとする
+ // 假设命令行参数的最后一个参数为输出路径
//string outputPath = System.Environment.GetCommandLineArgs().Last();
// var buildPlayerOptions = new BuildPlayerOptions();
@@ -20,12 +20,12 @@ namespace Kirurobo
// buildPlayerOptions.target = BuildTarget.StandaloneOSX;
// buildPlayerOptions.options = BuildOptions.None;
- // 事前にエディタから設定したビルド設定を利用
+ // 使用预先在编辑器中设置的构建设置
var scenes = EditorBuildSettings.scenes;
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
var locationPath = EditorUserBuildSettings.GetBuildLocation(buildTarget);
- // ビルド対象は環境に合わせて上書き
+ // 根据环境覆盖构建目标
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
buildTarget = BuildTarget.StandaloneOSX;
locationPath = "Builds/macOS/" + Application.productName;
@@ -42,7 +42,7 @@ namespace Kirurobo
options = BuildOptions.None
};
- // // 内容チェック用
+ // // 用于内容检查
// foreach (var scene in buildPlayerOptions.scenes)
// {
// Debug.Log(scene);
diff --git a/Editor/Scripts/UniWindowControllerEditor.cs b/Editor/Scripts/UniWindowControllerEditor.cs
index af9d339..a78a848 100644
--- a/Editor/Scripts/UniWindowControllerEditor.cs
+++ b/Editor/Scripts/UniWindowControllerEditor.cs
@@ -5,8 +5,8 @@
* License: MIT
*/
-// Assembry Definition を有効にしてから、ビルド時に Editor クラスがないとエラーが出る。
-// そこで丸ごと UNITY_EDITOR が無い場合は無視するものとした
+// 启用了程序集定义后,如果构建时没有 Editor 类会报错。
+// 因此整体用 UNITY_EDITOR 包裹,没有时直接忽略
#if UNITY_EDITOR
using System.Linq;
@@ -18,32 +18,32 @@ using UnityEngine.Rendering;
namespace Kirurobo
{
///
- /// UniWindowControllerのためのエディタカスタマイズ部分
+ /// UniWindowController 的编辑器自定义部分
///
[CustomEditor(typeof(UniWindowController))]
public class UniWindowControllerEditor : Editor
{
///
- /// カーソル下の色を表示するためのプロパティ
+ /// 用于显示光标下方颜色的属性
///
SerializedProperty pickedColor;
///
- /// ゲームビューのウィンドウ
+ /// 游戏视图窗口
///
private EditorWindow gameViewWindow;
///
- /// プロジェクト設定に関する警告を閉じておくか
+ /// 是否已关闭项目设置相关的警告
private bool isWarningDismissed = false;
///
- /// URP に関する警告を閉じておくか
+ /// 是否已关闭 URP 相关警告
///
private bool isUrpWarningDismissed = true;
///
- /// URP が有効かどうか
+ /// URP 是否有效
///
private bool hasUrp = false;
@@ -53,7 +53,7 @@ namespace Kirurobo
pickedColor = serializedObject.FindProperty("pickedColor");
- // URP が有効か否かを判定
+ // 判断 URP 是否有效
hasUrp = GetUrpSettings();
}
@@ -63,7 +63,7 @@ namespace Kirurobo
}
///
- /// URPが有効か否かを検出
+ /// 检测 URP 是否有效
///
///
private bool GetUrpSettings()
@@ -71,7 +71,7 @@ namespace Kirurobo
var renderPipelineAsset = GraphicsSettings.defaultRenderPipeline;
if (renderPipelineAsset == null || renderPipelineAsset.GetType().Name != "UniversalRenderPipelineAsset")
{
- // URP が設定されていない
+ // URP 未设置
return false;
}
return true;
@@ -88,16 +88,16 @@ namespace Kirurobo
}
///
- /// インスペクタでの表示をカスタマイズ
+ /// 自定义检视面板的显示
///
///
- /// 参考情報および、推奨設定の変更欄を表示します。
+ /// 显示参考信息以及推荐设置的更改栏。
///
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
- // カーソル下の色が得られていれば、その透明度を参考として表示
+ // 如果获取到了光标下的颜色,则显示其透明度作为参考
if (pickedColor != null)
{
EditorGUI.BeginDisabledGroup(true);
@@ -105,29 +105,29 @@ namespace Kirurobo
EditorGUI.EndDisabledGroup();
}
- // Project Settings の推奨設定を表示
+ // 显示 Project Settings 的推荐设置
isWarningDismissed = ShowPlayerSettingsValidation(isWarningDismissed);
- // URP 関連の推奨設定を表示
+ // 显示 URP 相关推荐设置
isUrpWarningDismissed = ShowUrpSettingsValidation(isUrpWarningDismissed);
}
///
- /// Project Settings に関する推奨設定の自動設定欄を表示
+ /// 显示 Project Settings 相关推荐设置的自动配置栏
///
private bool ShowPlayerSettingsValidation(bool dismissed) {
- // 以下は Project Settings 関連
+ // 以下是 Project Settings 相关
EditorGUILayout.Space();
bool enableValidation = EditorGUILayout.Foldout(!dismissed, "播放器设置验证");
- // チェックするかどうかを記憶
+ // 记录是否启用检查
if (enableValidation == dismissed)
{
dismissed = !enableValidation;
}
- // 推奨設定のチェック
+ // 检查推荐设置
//if (!isWarningDismissed)
if (enableValidation)
{
@@ -184,23 +184,23 @@ namespace Kirurobo
}
///
- /// URP に関する推奨設定の自動設定欄を表示
+ /// 显示 URP 相关推荐设置的自动配置栏
///
private bool ShowUrpSettingsValidation(bool dismissed) {
- // URP が無効ならば何もしない
+ // 如果 URP 未启用则不执行任何操作
if (!hasUrp) return dismissed;
- // 以下は URP 関連の自動設定
+ // 以下是 URP 相关自动设置
EditorGUILayout.Space();
bool enableValidation = EditorGUILayout.Foldout(!dismissed, "URP 设置验证");
- // チェックするかどうかを記憶
+ // 记录是否启用检查
if (enableValidation == dismissed)
{
dismissed = !enableValidation;
}
- // 推奨設定のチェック
- //if (!isWarningDismissed)
+
+ // 检查推荐设置
if (enableValidation)
{
if (ValidateUrpSettings(false))
@@ -283,7 +283,7 @@ namespace Kirurobo
EditorGUILayout.HelpBox(message, MessageType.Info, true);
GUILayout.FlexibleSpace();
- // 自動設定できない対象は、プロジェクトウィンドウで示すのみ
+ // 无法自动设置的对象,仅在项目窗口中标识
if (target != null)
{
EditorGUILayout.BeginVertical();
@@ -305,7 +305,7 @@ namespace Kirurobo
{
bool invalid = false;
- // バックグラウンドでも実行する。クリックスルー切替などで必要
+ // 在后台运行。点击穿透切换等功能需要此设置
if (!PlayerSettings.runInBackground)
{
invalid = true;
@@ -316,7 +316,7 @@ namespace Kirurobo
);
}
- // サイズ変更可能なウィンドウとする。必須ではないがウィンドウ枠無効時にサイズも変わるので変更可能である方が自然
+ // 设为可调整大小的窗口。非必需,但当窗口边框无效时大小会变化,因此可调整更自然
if (!PlayerSettings.resizableWindow)
{
invalid = true;
@@ -327,9 +327,9 @@ namespace Kirurobo
);
}
- // フルスクリーンでなくウィンドウとする
+ // 设为窗口模式而非全屏
#if UNITY_2018_1_OR_NEWER
- // Unity 2018 からはフルスクリーン指定の仕様が変わった
+ // Unity 2018 起全屏指定的行为发生了变化
if (PlayerSettings.fullScreenMode != FullScreenMode.Windowed)
{
invalid = true;
@@ -352,7 +352,7 @@ namespace Kirurobo
}
#endif
- // フルスクリーンとウィンドウの切替を無効とする
+ // 禁止全屏与窗口模式的切换
if (PlayerSettings.allowFullscreenSwitch)
{
invalid = true;
@@ -363,9 +363,9 @@ namespace Kirurobo
);
}
- // Windowsでは Use DXGI Flip Mode Swapchain を無効にしないと透過できない
- // ↓Unity 2019.1.6未満だと useFlipModelSwapchain は無いはず
- // なので除外のため書き連ねてあるが、ここまでサポートしなくて良い気もする。
+ // Windows 下不禁用 Use DXGI Flip Mode Swapchain 则无法透明
+ // ↓Unity 2019.1.6 以下应该没有 useFlipModelSwapchain
+ // 因此为了排除这些版本而逐一列出,但可能不需要支持到这么老的版本
#if UNITY_2019_1_6
#elif UNITY_2019_1_5
#elif UNITY_2019_1_4
@@ -374,7 +374,7 @@ namespace Kirurobo
#elif UNITY_2019_1_1
#elif UNITY_2019_1_0
#elif UNITY_2019_1_OR_NEWER
- // Unity 2019.1.7 以降であれば、Player 設定 の Use DXGI Flip... 無効化を推奨
+ // Unity 2019.1.7 以上推荐在 Player 设置中禁用 Use DXGI Flip...
if (PlayerSettings.useFlipModelSwapchain)
{
invalid = true;
@@ -385,10 +385,10 @@ namespace Kirurobo
);
}
- // Direct3D12 は透過ウィンドウに対応していないので、Graphics APIs for Windows から除外することを推奨
+ // Direct3D12 不支持透明窗口,建议从 Graphics APIs for Windows 中移除
if (PlayerSettings.GetUseDefaultGraphicsAPIs(BuildTarget.StandaloneWindows))
{
- // 自動の場合も警告を出す
+ // 自动选择图形 API 时也发出警告
ShowInfo(
"Direct3D12 不支持透明窗口。" +
"请考虑在播放器设置中使用 Direct3D11 替代'自动图形 API for Windows'设置。",
@@ -397,7 +397,7 @@ namespace Kirurobo
}
else if (PlayerSettings.GetGraphicsAPIs(BuildTarget.StandaloneWindows).Contains(GraphicsDeviceType.Direct3D12))
{
- // Graphhics APIs for Windows に Direct3D12 が含まれている場合は警告を出す
+ // Graphics APIs for Windows 中包含 Direct3D12 时发出警告
ShowInfo(
"Direct3D12 不支持透明窗口。" +
"请从播放器设置的'图形 API for Windows'中移除 Direct3D12。",
@@ -418,7 +418,7 @@ namespace Kirurobo
{
bool invalid = false;
- // Universal Render Pipelineが有効ならば、HDRの無効化を推奨
+ // 如果启用了 Universal Render Pipeline,建议禁用 HDR
foreach (var cam in Camera.allCameras)
{
if (cam.allowHDR) {
@@ -444,7 +444,7 @@ namespace Kirurobo
var urpAsset = GraphicsSettings.defaultRenderPipeline;
if (hasUrp && urpAsset != null)
{
- // hasUrp == true の時点で urpAsset は UniversalRenderPipelineAsset であるはず。そのため allowPostProcessAlphaOutput があるはず
+ // hasUrp == true 时 urpAsset 应该是 UniversalRenderPipelineAsset,因此应该存在 allowPostProcessAlphaOutput
var alphaProcessingProperty = urpAsset.GetType().GetProperty("allowPostProcessAlphaOutput", BindingFlags.Public | BindingFlags.Instance);
if (alphaProcessingProperty != null)
{
@@ -490,7 +490,7 @@ namespace Kirurobo
Object obj = property.serializedObject.targetObject;
- // Range(min, max) が設定されていれば取得
+ // 如果设置了 Range(min, max) 则获取
FieldInfo fieldInfo = obj.GetType().GetField(
property.name,
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static
@@ -500,10 +500,10 @@ namespace Kirurobo
if (EditorApplication.isPlayingOrWillChangePlaymode)
{
- // 変数の先頭が '_' であることが動作の条件
+ // 以 '_' 开头作为操作条件的依据
if (property.name[0] == '_')
{
- string propertyName = property.name.Substring(1); // '_' なしをプロパティ名として取得
+ string propertyName = property.name.Substring(1); // 获取去掉 '_' 后的属性名
PropertyInfo info = obj.GetType().GetProperty(propertyName);
MethodInfo getMethod = default(MethodInfo);
MethodInfo setMethod = default(MethodInfo);
@@ -553,7 +553,7 @@ namespace Kirurobo
}
else
{
- // bool, float 以外は今のところ非対応で Readonly とする
+ // bool、float 以外的类型暂不支持,设为只读
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
@@ -569,7 +569,7 @@ namespace Kirurobo
}
else
{
- // Range 指定があればスライダー
+ // 有 Range 指定则显示为滑块
if (range != null)
{
EditorGUI.Slider(position, property, range.min, range.max, label);
diff --git a/Runtime/Scripts/LowLevel/UniWinCore.cs b/Runtime/Scripts/LowLevel/UniWinCore.cs
index eda3a42..0c641e9 100644
--- a/Runtime/Scripts/LowLevel/UniWinCore.cs
+++ b/Runtime/Scripts/LowLevel/UniWinCore.cs
@@ -1,4 +1,4 @@
-/*
+/*
* UniWinCore.cs
*
* Author: Kirurobo http://twitter.com/kirurobo
@@ -356,8 +356,8 @@ namespace Kirurobo
}
///
- /// ファイル、フォルダがドロップされた時に呼ばれるコールバック
- /// 文字列を配列に直すことと、フラグを立てるまで行う
+ /// 文件或文件夹被拖放时调用的回调
+ /// 将字符串转换为数组,并设置标志位
///
///
[MonoPInvokeCallback(typeof(LibUniWinC.StringCallback))]
@@ -457,8 +457,8 @@ namespace Kirurobo
public void DetachWindow()
{
#if UNITY_EDITOR
- // エディタの場合、ウィンドウスタイルでは常に最前面と得られていない可能性があるため、
- // 最前面ではないのが本来と決め打ちで、デタッチ時無効化する
+ // 在编辑器中,窗口样式可能无法正确获取置顶状态,
+ // 因此默认视为非置顶,在分离时强制取消置顶
EnableTopmost(false);
#endif
LibUniWinC.DetachWindow();
diff --git a/Samples~/Common/InputProxy.cs b/Samples~/Common/InputProxy.cs
index eff4d4c..baa41aa 100644
--- a/Samples~/Common/InputProxy.cs
+++ b/Samples~/Common/InputProxy.cs
@@ -15,8 +15,8 @@ using UnityEngine.InputSystem;
namespace Kirurobo {
///
- /// Input System と Input Manager の違いを吸収するためのプロキシ
- ///
+ /// 用于消除 Input System 和 Input Manager 差异的代理
+ ///
public class InputProxy
{
public static Vector3 mousePosition {
@@ -26,7 +26,7 @@ namespace Kirurobo {
}
///
- /// Input System の利用に合わせてキーアップを取得
+ /// 配合 Input System 获取按键抬起
///
///
public static bool GetKeyUp(String key)
@@ -34,22 +34,22 @@ namespace Kirurobo {
#if ENABLE_LEGACY_INPUT_MANAGER
return Input.GetKeyUp(key);
#elif ENABLE_INPUT_SYSTEM
- // 簡易的な実装。keyが1文字で、かつアルファベットか数字に対応
- // 1文字以外は escape, space のみ対応
+ // 简易实现。仅支持单字母字符或数字
+ // 非单字符的仅支持 escape, space
if (key.Length == 1) {
Key k = Key.None;
char c = key[0];
if (c >= '0' && c <= '9') {
- // 数字の場合はDigit0~Digit9とNumpad0~Numpad9の両方に反応
+ // 数字时同时响应 Digit0~Digit9 和 Numpad0~Numpad9
k = (Key)Enum.ToObject(typeof(Key), (int)Key.Numpad0 + (int)(c - '0'));
if (Keyboard.current[k].wasReleasedThisFrame) return true;
- // Digitの場合はDigit0の値が最大
+ // Digit 键中 Digit0 的数值最大
k = (Key)Enum.ToObject(typeof(Key), (int)Key.Digit1 + (int)((c == '0' ? 9 : c - '1')));
if (Keyboard.current[k].wasReleasedThisFrame) return true;
}
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
- // アルファベットの場合は大文字・小文字どちらでも可とする
+ // 字母时大小写均可
k = (Key)Enum.ToObject(typeof(Key), (int)Key.A + (int)(Char.ToUpper(c) - 'A'));
if (Keyboard.current[k].wasReleasedThisFrame) return true;
}
@@ -65,7 +65,7 @@ namespace Kirurobo {
}
///
- /// Input System の利用に合わせてマウス座標を取得
+ /// 配合 Input System 获取鼠标坐标
///
///
private static Vector3 GetMousePosition()
@@ -99,7 +99,7 @@ namespace Kirurobo {
}
///
- /// このフレームでマウスボタンが押されたか判定
+ /// 判断本帧是否按下了鼠标按钮
///
///
///
diff --git a/Samples~/Common/ModelController.cs b/Samples~/Common/ModelController.cs
index bc9324e..c477dde 100644
--- a/Samples~/Common/ModelController.cs
+++ b/Samples~/Common/ModelController.cs
@@ -1,4 +1,4 @@
-/*
+/*
* ModelController
*
* 旋转、平移和缩放对象
@@ -40,7 +40,7 @@ namespace Kirurobo
public Vector2 maximumAngles = new Vector2(90f, 360f);
[Tooltip("Restrict to move out from screen")]
- public bool confineTranslation = true; // 並進移動をウィンドウ(Screen)の範囲に制限するか
+ public bool confineTranslation = true; // 是否将位移限制在窗口(屏幕)范围内
[Tooltip("Default is the parent transform")]
public Transform centerTransform; // 回転中心
@@ -69,7 +69,7 @@ namespace Kirurobo
void OnDestroy()
{
- // 回転中心を独自に作成していれば、削除
+ // 如果旋转中心是独立创建的,则删除
if (centerObject) GameObject.Destroy(centerObject);
}
@@ -82,7 +82,7 @@ namespace Kirurobo
}
///
- /// 必要なオブジェクトを取得・準備
+ /// 获取并准备所需对象
///
internal void Initialize()
{
@@ -106,8 +106,8 @@ namespace Kirurobo
}
///
- /// 初期位置・姿勢の設定
- /// 対象となるオブジェクトがそろった後で実行する
+ /// 设置初始位置和姿态
+ /// 在目标对象就绪后执行
///
internal void SetupTransform()
{
@@ -160,16 +160,16 @@ namespace Kirurobo
mousePos = Vector3.Max(Vector3.Min(mousePos, screenMax), Vector3.zero);
}
- lastMousePosition = mousePos; // ドラッグ開始時にはリセット
+ lastMousePosition = mousePos; // 拖动开始时重置
}
}
else if (InputProxy.GetMouseButtonDown(1))
{
- // 右ボタン(1)ドラッグでは回転を行う
+ // 右键(1)拖动时进行旋转
if (dragState == DragState.None && IsHit(mousePos))
{
dragState = DragState.Rotating;
- lastMousePosition = mousePos; // ドラッグ開始時にはリセット
+ lastMousePosition = mousePos; // 拖动开始时重置
}
}
@@ -224,7 +224,7 @@ namespace Kirurobo
}
else
{
- // ボタンが離されていれば並進は終了
+ // 如果按钮已松开则结束位移
dragState = DragState.None;
}
}