init uniWindowController 0.9.8
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Kirurobo {
|
||||
/// <summary>
|
||||
/// 使附加的对象以恒定速度进行偏航旋转
|
||||
/// </summary>
|
||||
public class AutoRotator : MonoBehaviour {
|
||||
/// <summary>
|
||||
/// 旋转速度 [度/秒]
|
||||
/// </summary>
|
||||
public float angularVelocity = 90f;
|
||||
|
||||
/// <summary>
|
||||
/// 旋转轴(偏航旋转,方向向上)
|
||||
/// </summary>
|
||||
Vector3 rotationAxis = Vector3.up;
|
||||
|
||||
/// <summary>
|
||||
/// 初始姿态
|
||||
/// </summary>
|
||||
Quaternion initialLocalRotation;
|
||||
|
||||
// 用于初始化
|
||||
void Start () {
|
||||
// 记录初始姿态
|
||||
initialLocalRotation = transform.localRotation;
|
||||
}
|
||||
|
||||
// 每帧调用 Update
|
||||
void Update () {
|
||||
var rotation = Quaternion.Euler(0f, Time.time * angularVelocity, 0f);
|
||||
transform.localRotation = initialLocalRotation * rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f985bf036f5416a45b9dd4e31bc85075
|
||||
timeCreated: 1545989238
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 452 B |
@@ -0,0 +1,88 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b5d2690e20d6584e909fd2bdfd93579
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 9
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 0
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 8, y: 8, z: 8, w: 8}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 533df9bf30503d349b91598d325d5fcd
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 451 B |
@@ -0,0 +1,88 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4713fc586389c694f9e384c7f3a02289
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 9
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 0
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 8, y: 8, z: 8, w: 8}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 47fdf1b4c9bb7764d916b229e9a2d98c
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace Kirurobo {
|
||||
|
||||
/// <summary>
|
||||
/// 为快速兼容 Legacy InputManager 和 InputSystem 而准备的类
|
||||
/// </summary>
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
public class InputModuleProxy : UnityEngine.EventSystems.StandaloneInputModule
|
||||
{
|
||||
}
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
public class InputModuleProxy : UnityEngine.InputSystem.UI.InputSystemUIInputModule
|
||||
{
|
||||
}
|
||||
#else
|
||||
public class InputModuleProxy
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce6b387a66b0e654d9eb8712d70fff48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* UniWindowController 的示例脚本
|
||||
*
|
||||
* 作者: Kirurobo http://twitter.com/kirurobo
|
||||
* 许可证: MIT
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
// Don't use InputSystem in this script to prevent TouchPhase duplication
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace Kirurobo {
|
||||
/// <summary>
|
||||
/// Input System と Input Manager の違いを吸収するためのプロキシ
|
||||
/// </summary>
|
||||
public class InputProxy
|
||||
{
|
||||
public static Vector3 mousePosition {
|
||||
get {
|
||||
return GetMousePosition();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Input System の利用に合わせてキーアップを取得
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool GetKeyUp(String key)
|
||||
{
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
return Input.GetKeyUp(key);
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
// 簡易的な実装。keyが1文字で、かつアルファベットか数字に対応
|
||||
// 1文字以外は escape, space のみ対応
|
||||
if (key.Length == 1) {
|
||||
Key k = Key.None;
|
||||
char c = key[0];
|
||||
if (c >= '0' && c <= '9') {
|
||||
// 数字の場合は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の値が最大
|
||||
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;
|
||||
}
|
||||
} else if (key == "escape") {
|
||||
return Keyboard.current.escapeKey.wasReleasedThisFrame;
|
||||
} else if (key == "space") {
|
||||
return Keyboard.current.spaceKey.wasReleasedThisFrame;
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Input System の利用に合わせてマウス座標を取得
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static Vector3 GetMousePosition()
|
||||
{
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
return Input.mousePosition;
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
return Mouse.current.position.ReadValue();
|
||||
#else
|
||||
return Vector3.zero;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断鼠标按钮当前是否被按下
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetMouseButton(int button)
|
||||
{
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
return Input.GetMouseButton(button);
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
if (button == 0) return Mouse.current.leftButton.isPressed;
|
||||
if (button == 1) return Mouse.current.rightButton.isPressed;
|
||||
if (button == 2) return Mouse.current.middleButton.isPressed;
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// このフレームでマウスボタンが押されたか判定
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetMouseButtonDown(int button)
|
||||
{
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
return Input.GetMouseButtonDown(button);
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
if (button == 0) return Mouse.current.leftButton.wasPressedThisFrame;
|
||||
if (button == 1) return Mouse.current.rightButton.wasPressedThisFrame;
|
||||
if (button == 2) return Mouse.current.middleButton.wasPressedThisFrame;
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断本帧是否松开了鼠标按钮
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
public static bool GetMouseButtonUp(int button) {
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
return Input.GetMouseButtonUp(button);
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
if (button == 0) return Mouse.current.leftButton.wasReleasedThisFrame;
|
||||
if (button == 1) return Mouse.current.rightButton.wasReleasedThisFrame;
|
||||
if (button == 2) return Mouse.current.middleButton.wasReleasedThisFrame;
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93a3055c4733041a1a83f6c90996f3ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* ModelController
|
||||
*
|
||||
* 旋转、平移和缩放对象
|
||||
*
|
||||
* 作者: Kirurobo http://twitter.com/kirurobo
|
||||
* 许可证: MIT
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Kirurobo
|
||||
{
|
||||
public class ModelController : MonoBehaviour
|
||||
{
|
||||
[Flags]
|
||||
public enum RotationAxes : int
|
||||
{
|
||||
None = 0,
|
||||
Pitch = 1,
|
||||
Yaw = 2,
|
||||
PitchAndYaw = 3
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum DragState
|
||||
{
|
||||
None,
|
||||
Rotating,
|
||||
Translating,
|
||||
}
|
||||
|
||||
public RotationAxes axes = RotationAxes.PitchAndYaw;
|
||||
public float yawSensitivity = 1f;
|
||||
public float pitchSensitvity = 1f;
|
||||
public float scaleSensitivity = 0.5f;
|
||||
|
||||
public Vector2 minimumAngles = new Vector2(-90f, -360f);
|
||||
public Vector2 maximumAngles = new Vector2(90f, 360f);
|
||||
|
||||
[Tooltip("Restrict to move out from screen")]
|
||||
public bool confineTranslation = true; // 並進移動をウィンドウ(Screen)の範囲に制限するか
|
||||
|
||||
[Tooltip("Default is the parent transform")]
|
||||
public Transform centerTransform; // 回転中心
|
||||
|
||||
[Tooltip("Default is the main camera")]
|
||||
public Camera currentCamera;
|
||||
|
||||
internal GameObject centerObject = null; // 当未指定旋转中心Transform时创建的对象
|
||||
|
||||
internal Vector3 rotation;
|
||||
internal Vector3 translation;
|
||||
internal Vector3 lastMousePosition; // 上一帧的鼠标坐标
|
||||
internal DragState dragState; // 拖动时根据开始时的按钮设置对应状态
|
||||
|
||||
internal Vector3 relativePosition;
|
||||
internal Quaternion relativeRotation;
|
||||
internal Vector3 originalLocalScale;
|
||||
internal float zoom;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
Initialize();
|
||||
SetupTransform();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
// 回転中心を独自に作成していれば、削除
|
||||
if (centerObject) GameObject.Destroy(centerObject);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!currentCamera.isActiveAndEnabled) return;
|
||||
{
|
||||
HandleMouse();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 必要なオブジェクトを取得・準備
|
||||
/// </summary>
|
||||
internal void Initialize()
|
||||
{
|
||||
if (!centerTransform)
|
||||
{
|
||||
centerTransform = this.transform.parent;
|
||||
if (!centerTransform || centerTransform == this.transform)
|
||||
{
|
||||
centerObject = new GameObject();
|
||||
centerTransform = centerObject.transform;
|
||||
centerTransform.position = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentCamera)
|
||||
{
|
||||
currentCamera = Camera.main;
|
||||
}
|
||||
|
||||
lastMousePosition = InputProxy.mousePosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初期位置・姿勢の設定
|
||||
/// 対象となるオブジェクトがそろった後で実行する
|
||||
/// </summary>
|
||||
internal void SetupTransform()
|
||||
{
|
||||
relativePosition = transform.position- centerTransform.position; // 从对象到中心坐标的向量
|
||||
relativeRotation = transform.rotation * Quaternion.Inverse(centerTransform.rotation);
|
||||
originalLocalScale = transform.localScale;
|
||||
|
||||
ResetTransform();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset rotation and translation.
|
||||
/// </summary>
|
||||
public void ResetTransform()
|
||||
{
|
||||
rotation = relativeRotation.eulerAngles;
|
||||
translation = relativePosition;
|
||||
zoom = 0f;
|
||||
|
||||
UpdateTransform();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用旋转和平移
|
||||
/// </summary>
|
||||
internal void UpdateTransform()
|
||||
{
|
||||
Quaternion rot = Quaternion.Euler(rotation);
|
||||
transform.rotation = rot;
|
||||
transform.position = centerTransform.position + translation;
|
||||
|
||||
transform.localScale = originalLocalScale * Mathf.Pow(10f, zoom);
|
||||
}
|
||||
|
||||
internal virtual void HandleMouse()
|
||||
{
|
||||
Vector3 mousePos = InputProxy.mousePosition;
|
||||
|
||||
if (InputProxy.GetMouseButtonDown(0))
|
||||
{
|
||||
// 左键(0)拖动时进行平移
|
||||
if (dragState == DragState.None && IsHit(mousePos))
|
||||
{
|
||||
dragState = DragState.Translating;
|
||||
|
||||
// 限制在屏幕范围内
|
||||
if (confineTranslation)
|
||||
{
|
||||
Vector3 screenMax = new Vector3(Screen.width, Screen.height);
|
||||
mousePos = Vector3.Max(Vector3.Min(mousePos, screenMax), Vector3.zero);
|
||||
}
|
||||
|
||||
lastMousePosition = mousePos; // ドラッグ開始時にはリセット
|
||||
}
|
||||
}
|
||||
else if (InputProxy.GetMouseButtonDown(1))
|
||||
{
|
||||
// 右ボタン(1)ドラッグでは回転を行う
|
||||
if (dragState == DragState.None && IsHit(mousePos))
|
||||
{
|
||||
dragState = DragState.Rotating;
|
||||
lastMousePosition = mousePos; // ドラッグ開始時にはリセット
|
||||
}
|
||||
}
|
||||
|
||||
// 通过拖动旋转
|
||||
if (dragState == DragState.Rotating)
|
||||
{
|
||||
// 仅在按下按钮时操作
|
||||
if (InputProxy.GetMouseButton(1))
|
||||
{
|
||||
// 通过拖动旋转
|
||||
if ((axes & RotationAxes.Yaw) > RotationAxes.None)
|
||||
{
|
||||
rotation.y -= (mousePos.x - lastMousePosition.x) * 360f / Screen.width * yawSensitivity;
|
||||
rotation.y = ClampAngle(rotation.y, minimumAngles.y, maximumAngles.y);
|
||||
}
|
||||
|
||||
if ((axes & RotationAxes.Pitch) > RotationAxes.None)
|
||||
{
|
||||
rotation.x += (mousePos.y - lastMousePosition.y) * 360f / Screen.height * pitchSensitvity;
|
||||
rotation.x = ClampAngle(rotation.x, minimumAngles.x, maximumAngles.x);
|
||||
}
|
||||
|
||||
UpdateTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果右键已松开则结束旋转
|
||||
dragState = DragState.None;
|
||||
}
|
||||
}
|
||||
|
||||
// 通过拖动平移
|
||||
if (dragState == DragState.Translating)
|
||||
{
|
||||
// 仅在按下按钮时操作
|
||||
if (InputProxy.GetMouseButton(0))
|
||||
{
|
||||
// 限制在屏幕范围内
|
||||
if (confineTranslation)
|
||||
{
|
||||
Vector3 screenMax = new Vector3(Screen.width, Screen.height);
|
||||
mousePos = Vector3.Max(Vector3.Min(mousePos, screenMax), Vector3.zero);
|
||||
}
|
||||
|
||||
Vector3 screenPos = currentCamera.WorldToScreenPoint(transform.position);
|
||||
Vector3 deltaPos = mousePos - lastMousePosition;
|
||||
deltaPos.z = 0f;
|
||||
Vector3 worldPos = currentCamera.ScreenToWorldPoint(screenPos + deltaPos);
|
||||
translation = worldPos - centerTransform.position;
|
||||
|
||||
UpdateTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
// ボタンが離されていれば並進は終了
|
||||
dragState = DragState.None;
|
||||
}
|
||||
}
|
||||
|
||||
// 暂时仅在使用 Legacy Input Manager 时接受滚轮操作
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
// 如果滚轮转动,则进行缩放
|
||||
if (!Mathf.Approximately(Input.GetAxis("Mouse ScrollWheel"), 0f) && IsHit(mousePos))
|
||||
{
|
||||
// 滚轮操作量
|
||||
float wheelDelta = Input.GetAxis("Mouse ScrollWheel") * scaleSensitivity;
|
||||
|
||||
// 更改缩放倍率
|
||||
zoom -= wheelDelta;
|
||||
zoom = Mathf.Clamp(zoom, -1f, 2f); // 视场角的对数范围 [度]
|
||||
|
||||
UpdateTransform();
|
||||
}
|
||||
#endif
|
||||
|
||||
lastMousePosition = mousePos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断鼠标操作时是否点击到对象
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal bool IsHit(Vector3 screenPosition)
|
||||
{
|
||||
RaycastHit hit;
|
||||
Ray ray = currentCamera.ScreenPointToRay(screenPosition);
|
||||
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
if (hit.transform.IsChildOf(transform)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 若角度超出指定范围,则进行修正
|
||||
/// </summary>
|
||||
/// <param name="angle"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns></returns>
|
||||
public static float ClampAngle(float angle, float min, float max)
|
||||
{
|
||||
if (angle < -min) angle = -((-angle) % 360f);
|
||||
if (angle > max) angle = angle % 360f;
|
||||
return Mathf.Clamp(angle, min, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 035ad1913e9c28f4492641ca36127790
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,84 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UiMaterial
|
||||
m_Shader: {fileID: 10760, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 0.78431374}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57c048a21c6552643bb464f9bcd0cf1a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"displayName": "FileDialog",
|
||||
"description": "Demonstrates native file open/save dialog integration.",
|
||||
"createSeparatePackage": false
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Kirurobo
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础文件面板示例
|
||||
/// </summary>
|
||||
public class FileDialogSample : MonoBehaviour
|
||||
{
|
||||
public Button openFileButton;
|
||||
public Button openMultipleFilesButton;
|
||||
public Button saveFileButton;
|
||||
public Text messageText;
|
||||
|
||||
// 首次更新前调用 Start
|
||||
void Start()
|
||||
{
|
||||
openFileButton.onClick.AddListener(OpenSingleFile);
|
||||
openMultipleFilesButton.onClick.AddListener(OpenMultipleFiles);
|
||||
saveFileButton.onClick.AddListener(OpenSaveFile);
|
||||
messageText.text = "点击按钮!";
|
||||
}
|
||||
|
||||
// 每帧调用 Update
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开单个文件的对话框。
|
||||
/// </summary>
|
||||
private void OpenSingleFile() {
|
||||
FilePanel.Settings settings = new FilePanel.Settings();
|
||||
settings.filters = new FilePanel.Filter[]
|
||||
{
|
||||
new FilePanel.Filter("所有文件", "*"),
|
||||
new FilePanel.Filter("图片文件 (*.png;*.jpg;*.jpeg;*.tiff;*.gif;*.tga)", "png", "jpg", "jpeg", "tiff", "gif", "tga"),
|
||||
new FilePanel.Filter("文档 (*.txt;*.rtf;*.doc;*.docx)", "txt", "rtf", "doc", "docx"),
|
||||
};
|
||||
settings.title = "打开文件!";
|
||||
settings.initialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures);
|
||||
|
||||
messageText.text = "";
|
||||
FilePanel.OpenFilePanel(settings, (files) =>
|
||||
{
|
||||
messageText.text = "打开文件\n" + string.Join("\n", files);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开多个文件的对话框。
|
||||
/// </summary>
|
||||
private void OpenMultipleFiles() {
|
||||
FilePanel.Settings settings = new FilePanel.Settings();
|
||||
settings.filters = new FilePanel.Filter[]
|
||||
{
|
||||
new FilePanel.Filter("图片文件 (*.png;*.jpg;*.jpeg;*.tiff;*.gif;*.tga)", "png", "jpg", "jpeg", "tiff", "gif", "tga"),
|
||||
new FilePanel.Filter("文档 (*.txt;*.rtf;*.doc;*.docx)", "txt", "rtf", "doc", "docx"),
|
||||
new FilePanel.Filter("所有文件", "*"),
|
||||
};
|
||||
settings.flags = FilePanel.Flag.AllowMultipleSelection;
|
||||
settings.title = "打开多个文件!";
|
||||
settings.initialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
|
||||
|
||||
messageText.text = "";
|
||||
FilePanel.OpenFilePanel(settings, (files) =>
|
||||
{
|
||||
messageText.text = "打开多个文件\n" + string.Join("\n", files);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开保存文件对话框。
|
||||
/// </summary>
|
||||
private void OpenSaveFile() {
|
||||
FilePanel.Settings settings = new FilePanel.Settings();
|
||||
settings.filters = new FilePanel.Filter[]
|
||||
{
|
||||
new FilePanel.Filter("文本文件 (*.txt;*.log)", "txt", "log"),
|
||||
new FilePanel.Filter("图片文件 (*.png;*.jpg;*.jpeg;*.tiff;*.gif;*.tga)", "png", "jpg", "jpeg", "tiff", "gif", "tga"),
|
||||
new FilePanel.Filter("所有文件", "*"),
|
||||
};
|
||||
settings.title = "实际上不会执行保存操作";
|
||||
settings.initialFile = "Test.txt";
|
||||
|
||||
messageText.text = "";
|
||||
FilePanel.SaveFilePanel(settings, (files) =>
|
||||
{
|
||||
messageText.text = "选中的文件\n" + string.Join("\n", files);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FileDialogSampleSettings
|
||||
serializedVersion: 3
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 1
|
||||
m_BakeBackend: 1
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 1
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 2
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"displayName": "Fullscreen",
|
||||
"description": "Fullscreen mode example with right-click context menu and 3D snowman scene.",
|
||||
"createSeparatePackage": false
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* 全屏示例的 UI 控制器
|
||||
*
|
||||
* Author: Kirurobo http://twitter.com/kirurobo
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Kirurobo
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用 Toggle 开关 WindowController 设置的示例
|
||||
/// </summary>
|
||||
public class FullscreenSample : MonoBehaviour
|
||||
{
|
||||
private UniWindowController uniwinc;
|
||||
private RectTransform canvasRect;
|
||||
|
||||
private float mouseMoveSS = 0f; // 鼠标轨迹平方和。[px^2]
|
||||
private float mouseMoveSSThreshold = 36f; // 点击(非拖拽)阈值。[px^2]
|
||||
private Vector3 lastMousePosition; // 右键点击位置。
|
||||
private float touchDuration = 0f;
|
||||
private float touchDurationThreshold = 0.5f; // 长按时间阈值。[s]
|
||||
|
||||
public Toggle transparentToggle;
|
||||
public Toggle topmostToggle;
|
||||
public Toggle bottommostToggle;
|
||||
public Dropdown fitWindowDropdown;
|
||||
public Button quitButton;
|
||||
public Button menuCloseButton;
|
||||
public RectTransform menuPanel;
|
||||
|
||||
/// <summary>
|
||||
/// 设置
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
// 查找 UniWindowController
|
||||
uniwinc = GameObject.FindAnyObjectByType<UniWindowController>();
|
||||
|
||||
// 获取 Canvas 的 RectTransform
|
||||
if (menuPanel) canvasRect = menuPanel.GetComponentInParent<Canvas>().GetComponent<RectTransform>();
|
||||
|
||||
// 根据有效显示器数量创建选项
|
||||
UpdateMonitorDropdown();
|
||||
|
||||
// 将 Toggle 的选中状态与当前状态同步
|
||||
UpdateUI();
|
||||
|
||||
// 初始状态下关闭菜单
|
||||
CloseMenu();
|
||||
|
||||
if (uniwinc)
|
||||
{
|
||||
// 操作 UI 时将其反映到窗口
|
||||
transparentToggle?.onValueChanged.AddListener(val => uniwinc.isTransparent = val);
|
||||
topmostToggle?.onValueChanged.AddListener(val => uniwinc.isTopmost = val);
|
||||
bottommostToggle?.onValueChanged.AddListener(val => uniwinc.isBottommost = val);
|
||||
fitWindowDropdown?.onValueChanged.AddListener(val => SetFitToMonitor(val));
|
||||
quitButton?.onClick.AddListener(Quit);
|
||||
menuCloseButton?.onClick.AddListener(CloseMenu);
|
||||
|
||||
// Add events
|
||||
uniwinc.OnStateChanged += (type) =>
|
||||
{
|
||||
UpdateUI();
|
||||
//ShowEventMessage("Window state changed: " + type);
|
||||
};
|
||||
uniwinc.OnMonitorChanged += () => {
|
||||
UpdateMonitorDropdown();
|
||||
UpdateUI();
|
||||
//ShowEventMessage("Resolution changed!");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 每帧执行
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
// 鼠标右键点击时显示上下文菜单。
|
||||
// 如果鼠标移动距离在阈值以下,则视为点击
|
||||
if (InputProxy.GetMouseButtonDown(1))
|
||||
{
|
||||
lastMousePosition = InputProxy.mousePosition;
|
||||
touchDuration = 0f;
|
||||
}
|
||||
if (InputProxy.GetMouseButton(1))
|
||||
{
|
||||
mouseMoveSS += (InputProxy.mousePosition - lastMousePosition).sqrMagnitude;
|
||||
}
|
||||
if (InputProxy.GetMouseButtonUp(1))
|
||||
{
|
||||
if (mouseMoveSS < mouseMoveSSThreshold)
|
||||
{
|
||||
ShowMenu(lastMousePosition);
|
||||
}
|
||||
mouseMoveSS = 0f;
|
||||
touchDuration = 0f;
|
||||
}
|
||||
|
||||
// 暂时仅在 Legacy Input Manager 中处理触摸
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
// 长按也可显示菜单
|
||||
if (Input.touchSupported && (Input.touchCount > 0))
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
lastMousePosition = Input.mousePosition;
|
||||
touchDuration = 0f;
|
||||
}
|
||||
if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
|
||||
{
|
||||
mouseMoveSS += touch.deltaPosition.sqrMagnitude;
|
||||
touchDuration += touch.deltaTime;
|
||||
}
|
||||
if (touch.phase == TouchPhase.Ended)
|
||||
{
|
||||
if ((mouseMoveSS < mouseMoveSSThreshold) && (touchDuration >= touchDurationThreshold))
|
||||
{
|
||||
ShowMenu(lastMousePosition);
|
||||
}
|
||||
mouseMoveSS = 0f;
|
||||
touchDuration = 0f;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// 按下 [Space] 键也可显示菜单
|
||||
if (InputProxy.GetKeyUp("space"))
|
||||
{
|
||||
if (menuPanel)
|
||||
{
|
||||
if (menuPanel.gameObject.activeSelf) {
|
||||
CloseMenu();
|
||||
} else {
|
||||
Vector2 pos = new Vector2(Screen.width / 2, Screen.height / 2);
|
||||
ShowMenu(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 按下 [ESC] 时退出或停止播放
|
||||
if (InputProxy.GetKeyUp("escape"))
|
||||
{
|
||||
Quit();
|
||||
}
|
||||
}
|
||||
|
||||
void Quit()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适配显示器下拉列表更改时的处理
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
void SetFitToMonitor(int val)
|
||||
{
|
||||
if (!uniwinc) return;
|
||||
|
||||
if (val < 1)
|
||||
{
|
||||
// 下拉列表第一项为不适配
|
||||
uniwinc.shouldFitMonitor = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 由于从第二项开始,显示器编号减1
|
||||
uniwinc.monitorToFit = val - 1;
|
||||
uniwinc.shouldFitMonitor = true; // 从false变为true时才会移动窗口,因此先指定显示器编号再更改
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在指定坐标显示上下文菜单
|
||||
/// </summary>
|
||||
/// <param name="position">指定中心坐标</param>
|
||||
private void ShowMenu(Vector2 position)
|
||||
{
|
||||
if (menuPanel)
|
||||
{
|
||||
Vector2 pos = position * (canvasRect.sizeDelta.x / Screen.width);
|
||||
float w = menuPanel.rect.width;
|
||||
float h = menuPanel.rect.height;
|
||||
|
||||
// 以指定坐标为中心进行位置调整
|
||||
pos.y = Mathf.Max(Mathf.Min(pos.y, Screen.height - h / 2f), h / 2f); // 如果超出则向上移动
|
||||
pos.x = Mathf.Max(Mathf.Min(pos.x, Screen.width - w / 2f), w / 2f); // 如果超出右侧则向左移动
|
||||
|
||||
menuPanel.pivot = Vector2.one * 0.5f; // 设置为中心
|
||||
menuPanel.anchorMin = Vector2.zero;
|
||||
menuPanel.anchorMax = Vector2.zero;
|
||||
menuPanel.anchoredPosition = pos;
|
||||
|
||||
menuPanel.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭上下文菜单
|
||||
/// </summary>
|
||||
private void CloseMenu()
|
||||
{
|
||||
if (menuPanel)
|
||||
{
|
||||
menuPanel.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将实际状态反映到 UI 显示
|
||||
/// </summary>
|
||||
private void UpdateUI()
|
||||
{
|
||||
if (uniwinc)
|
||||
{
|
||||
if (transparentToggle)
|
||||
{
|
||||
transparentToggle.isOn = uniwinc.isTransparent;
|
||||
}
|
||||
|
||||
if (topmostToggle)
|
||||
{
|
||||
topmostToggle.isOn = uniwinc.isTopmost;
|
||||
}
|
||||
|
||||
if (bottommostToggle)
|
||||
{
|
||||
bottommostToggle.isOn = uniwinc.isBottommost;
|
||||
}
|
||||
|
||||
if (fitWindowDropdown)
|
||||
{
|
||||
if (uniwinc.shouldFitMonitor)
|
||||
{
|
||||
fitWindowDropdown.value = uniwinc.monitorToFit + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fitWindowDropdown.value = 0;
|
||||
}
|
||||
fitWindowDropdown.RefreshShownValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新显示器选择下拉列表的选项
|
||||
/// 之后需要调用 UpdateUI()
|
||||
/// </summary>
|
||||
void UpdateMonitorDropdown()
|
||||
{
|
||||
if (!fitWindowDropdown) return;
|
||||
|
||||
// 删除除第一项以外的选项
|
||||
fitWindowDropdown.options.RemoveRange(1, fitWindowDropdown.options.Count - 1);
|
||||
|
||||
if (!uniwinc)
|
||||
{
|
||||
fitWindowDropdown.value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = UniWindowController.GetMonitorCount();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
fitWindowDropdown.options.Add(new Dropdown.OptionData("适配显示器 " + i));
|
||||
}
|
||||
if (uniwinc.monitorToFit >= count)
|
||||
{
|
||||
uniwinc.monitorToFit = count - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示带超时功能的消息
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
private void ShowEventMessage(string message)
|
||||
{
|
||||
Debug.Log(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果 UI 中有文本框,则显示消息。否则输出到控制台
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
public void OutputMessage(string text)
|
||||
{
|
||||
Debug.Log(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,66 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FullscreenSampleSettings
|
||||
serializedVersion: 6
|
||||
m_GIWorkflowMode: 1
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 50
|
||||
m_Padding: 2
|
||||
m_LightmapCompression: 0
|
||||
m_AO: 1
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 1
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentImportanceSampling: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_PVRTiledBaking: 0
|
||||
m_NumRaysToShootPerTexel: -1
|
||||
m_RespectSceneVisibilityWhenBakingGI: 0
|
||||
@@ -0,0 +1,108 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SnowParticle
|
||||
m_Shader: {fileID: 210, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ALPHABLEND_ON
|
||||
- _EMISSION
|
||||
- _FADING_ON
|
||||
m_InvalidKeywords:
|
||||
- _COLORCOLOR_ON
|
||||
m_LightmapFlags: 0
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses:
|
||||
- GRABPASS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 10300, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 1
|
||||
- _CameraFadingEnabled: 1
|
||||
- _CameraFarFadeDistance: 5
|
||||
- _CameraNearFadeDistance: 0.5
|
||||
- _ColorMode: 4
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DistortionBlend: 0.5
|
||||
- _DistortionEnabled: 0
|
||||
- _DistortionStrength: 1
|
||||
- _DistortionStrengthScaled: 0
|
||||
- _DstBlend: 10
|
||||
- _EmissionEnabled: 1
|
||||
- _FlipbookMode: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _LightingEnabled: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 2
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SoftParticlesEnabled: 0
|
||||
- _SoftParticlesFarFadeDistance: 1
|
||||
- _SoftParticlesNearFadeDistance: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _CameraFadeParams: {r: 0.5, g: 0.22222222, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ColorAddSubDiff: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,77 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SnowmanArm
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.263
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0.683
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.9433962, g: 0.64307785, b: 0.3693485, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
@@ -0,0 +1,78 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SnowmanBody
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords: _EMISSION _GLOSSYREFLECTIONS_OFF _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
_SPECULARHIGHLIGHTS_OFF
|
||||
m_LightmapFlags: 2
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 1
|
||||
- _SpecularHighlights: 0
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0.3490566, g: 0.3490566, b: 0.3490566, a: 1}
|
||||
@@ -0,0 +1,77 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SnowmanFace
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords: _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 1
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.21698111, g: 0.21698111, b: 0.21698111, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"displayName": "Menu",
|
||||
"description": "Sample menu scene for navigating between different example scenes.",
|
||||
"createSeparatePackage": false
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Kirurobo
|
||||
{
|
||||
public class SampleManager : MonoBehaviour
|
||||
{
|
||||
private static SampleManager _instance;
|
||||
public static SampleManager Instance => _instance ?? (_instance = GameObject.FindAnyObjectByType<SampleManager>() ?? new SampleManager());
|
||||
|
||||
public Canvas canvas;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 设为单例。若已有实例则销毁自身
|
||||
if (this != Instance)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(Instance);
|
||||
DontDestroyOnLoad(UniWindowController.current);
|
||||
|
||||
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景加载时记录主相机
|
||||
/// </summary>
|
||||
/// <param name="arg0"></param>
|
||||
/// <param name="arg1"></param>
|
||||
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
|
||||
{
|
||||
UniWindowController.current.SetCamera(Camera.main);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开指定名称的场景
|
||||
/// </summary>
|
||||
/// <param name="name">场景名</param>
|
||||
public void LoadScene(string name)
|
||||
{
|
||||
if (name == "SimpleSample")
|
||||
{
|
||||
// SimpleSample 时无脚本控制,在此处设置透明
|
||||
UniWindowController.current.isTransparent = true;
|
||||
}
|
||||
else if (name == "FullScreenSample")
|
||||
{
|
||||
// FullScreenSample 时强制最大化
|
||||
UniWindowController.current.shouldFitMonitor = true;
|
||||
}
|
||||
|
||||
SceneManager.LoadScene(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 退出
|
||||
/// </summary>
|
||||
public void Quit()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SampleMenuSettings
|
||||
serializedVersion: 3
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 1
|
||||
m_BakeBackend: 1
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 1
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 2
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"displayName": "SimpleSample",
|
||||
"description": "A minimal example demonstrating basic window control setup.",
|
||||
"createSeparatePackage": false
|
||||
}
|
||||
@@ -0,0 +1,795 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 3
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.44657815, g: 0.49641186, b: 0.57481647, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &4
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 1
|
||||
m_BakeResolution: 50
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 1
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 1
|
||||
m_BakeBackend: 0
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 2074312002}
|
||||
--- !u!196 &5
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 3
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666666
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
buildHeightMesh: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &144805234
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 144805236}
|
||||
- component: {fileID: 144805235}
|
||||
m_Layer: 0
|
||||
m_Name: Directional light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &144805235
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 144805234}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 0
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &144805236
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 144805234}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.10938166, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &269992499
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 9167954367673589911, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: DragMoveCanvas
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_Pivot.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9167954367673589915, guid: d7dcf50428b152040847878685fe0746,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: d7dcf50428b152040847878685fe0746, type: 3}
|
||||
--- !u!1 &452327621
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 452327624}
|
||||
- component: {fileID: 452327623}
|
||||
- component: {fileID: 452327625}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &452327623
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 452327621}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &452327624
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 452327621}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &452327625
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 452327621}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ce6b387a66b0e654d9eb8712d70fff48, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018,
|
||||
type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
--- !u!1001 &1158200202
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626842, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626843, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: _isTopmost
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626843, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: _isTransparent
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626844, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
value: UniWindowController
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626845, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: _isTopmost
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2416199871598626845, guid: e893aefd93740714b999573b02916984,
|
||||
type: 3}
|
||||
propertyPath: _isTransparent
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: e893aefd93740714b999573b02916984, type: 3}
|
||||
--- !u!850595691 &2074312002
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Settings.lighting
|
||||
serializedVersion: 6
|
||||
m_GIWorkflowMode: 1
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 2
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 50
|
||||
m_Padding: 2
|
||||
m_LightmapCompression: 0
|
||||
m_AO: 1
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 1
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentImportanceSampling: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_PVRTiledBaking: 0
|
||||
m_NumRaysToShootPerTexel: -1
|
||||
m_RespectSceneVisibilityWhenBakingGI: 0
|
||||
--- !u!1 &2084589444
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2084589449}
|
||||
- component: {fileID: 2084589448}
|
||||
- component: {fileID: 2084589445}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &2084589445
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2084589444}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &2084589448
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2084589444}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 30
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &2084589449
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2084589444}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -5}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2124152612
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2124152616}
|
||||
- component: {fileID: 2124152615}
|
||||
- component: {fileID: 2124152614}
|
||||
- component: {fileID: 2124152613}
|
||||
m_Layer: 0
|
||||
m_Name: Cube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &2124152613
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2124152612}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 0
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10302, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!65 &2124152614
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2124152612}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &2124152615
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2124152612}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &2124152616
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2124152612}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.35355338, y: 0.35355338, z: -0.1464466, w: 0.8535535}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 45, y: 45.000004, z: 0}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 144805236}
|
||||
- {fileID: 2084589449}
|
||||
- {fileID: 2124152616}
|
||||
- {fileID: 1158200202}
|
||||
- {fileID: 269992499}
|
||||
- {fileID: 452327624}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"displayName": "UiSample",
|
||||
"description": "Complete UI demonstration with toggles and sliders for controlling window properties (transparency, topmost, click-through, etc.).",
|
||||
"createSeparatePackage": false
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,603 @@
|
||||
/**
|
||||
* UniWindowController 的示例脚本
|
||||
*
|
||||
* Author: Kirurobo http://twitter.com/kirurobo
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Kirurobo
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用 Toggle 开关 WindowController 设置的示例
|
||||
/// </summary>
|
||||
public class UiSampleController : MonoBehaviour
|
||||
{
|
||||
private UniWindowController uniwinc;
|
||||
private UniWindowMoveHandle uniWinMoveHandle;
|
||||
private RectTransform canvasRect;
|
||||
|
||||
private float mouseMoveSS = 0f; // 鼠标轨迹平方和。[px^2]
|
||||
private float mouseMoveSSThreshold = 36f; // 点击(非拖拽)阈值。[px^2]
|
||||
private Vector3 lastMousePosition; // 右键点击位置。
|
||||
private float lastEventOccurredTime = -5f; // 上次事件发生的时间戳 [s]
|
||||
private float eventMessageTimeout = 1f; // 在此时间段内显示事件消息 [s]
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
private float touchDuration = 0f;
|
||||
private float touchDurationThreshold = 0.5f; // 长按时间阈值。[s]
|
||||
#endif
|
||||
public Toggle transparentToggle;
|
||||
public Slider alphaSlider;
|
||||
public Toggle topmostToggle;
|
||||
public Toggle bottommostToggle;
|
||||
[FormerlySerializedAs("maximizedToggle")] public Toggle zoomedToggle;
|
||||
public Toggle dragMoveToggle;
|
||||
public Toggle allowDropToggle;
|
||||
public Dropdown fitWindowDropdown;
|
||||
public Toggle showBorderlineToggle;
|
||||
public Button widthDownButton;
|
||||
public Button widthUpButton;
|
||||
public Button heightDownButton;
|
||||
public Button heightUpButton;
|
||||
public Dropdown transparentTypeDropdown;
|
||||
public Dropdown hitTestTypeDropdown;
|
||||
public Toggle clickThroughToggle;
|
||||
public Image pickedColorImage;
|
||||
public Text pickedColorText;
|
||||
public Text messageText;
|
||||
public Text clientSizeText;
|
||||
public Button menuCloseButton;
|
||||
public RectTransform menuPanel;
|
||||
public RectTransform borderlinePanel;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
// 查找 UniWindowController
|
||||
uniwinc = UniWindowController.current;
|
||||
|
||||
// 查找 UniWindowDragMove
|
||||
uniWinMoveHandle = GameObject.FindAnyObjectByType<UniWindowMoveHandle>();
|
||||
|
||||
// 获取 Canvas 的 RectTransform
|
||||
if (menuPanel) canvasRect = menuPanel.GetComponentInParent<Canvas>().GetComponent<RectTransform>();
|
||||
|
||||
// 根据有效显示器数量创建选项
|
||||
UpdateMonitorDropdown();
|
||||
|
||||
// 将 Toggle 的选中状态与当前状态同步
|
||||
UpdateUI();
|
||||
|
||||
if (uniwinc)
|
||||
{
|
||||
// 操作 UI 时将其反映到窗口
|
||||
transparentToggle?.onValueChanged.AddListener(val => uniwinc.isTransparent = val);
|
||||
alphaSlider?.onValueChanged.AddListener(val => uniwinc.alphaValue = val);
|
||||
topmostToggle?.onValueChanged.AddListener(val => uniwinc.isTopmost = val);
|
||||
bottommostToggle?.onValueChanged.AddListener(val => uniwinc.isBottommost = val);
|
||||
zoomedToggle?.onValueChanged.AddListener(val => uniwinc.isZoomed = val);
|
||||
allowDropToggle?.onValueChanged.AddListener(val => uniwinc.allowDropFiles = val);
|
||||
|
||||
fitWindowDropdown?.onValueChanged.AddListener(val => SetFitToMonitor(val));
|
||||
|
||||
widthDownButton?.onClick.AddListener(() => uniwinc.windowSize += new Vector2(-100, 0));
|
||||
widthUpButton?.onClick.AddListener(() => uniwinc.windowSize += new Vector2(+100, 0));
|
||||
heightDownButton?.onClick.AddListener(() => uniwinc.windowSize += new Vector2(0, -100));
|
||||
heightUpButton?.onClick.AddListener(() => uniwinc.windowSize += new Vector2(0, +100));
|
||||
|
||||
clickThroughToggle?.onValueChanged.AddListener(val => uniwinc.isClickThrough = val);
|
||||
|
||||
transparentTypeDropdown?.onValueChanged.AddListener(val => uniwinc.SetTransparentType((UniWindowController.TransparentType)val));
|
||||
hitTestTypeDropdown?.onValueChanged.AddListener(val => uniwinc.hitTestType = (UniWindowController.HitTestType)val);
|
||||
menuCloseButton?.onClick.AddListener(CloseMenu);
|
||||
|
||||
if (uniWinMoveHandle) dragMoveToggle?.onValueChanged.AddListener(val => uniWinMoveHandle.enabled = val);
|
||||
|
||||
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
|
||||
// 如果不是 Windows,则禁用透明方式选择
|
||||
//if (transparentTypeDropdown) transparentTypeDropdown.interactable = false;
|
||||
//if (transparentTypeDropdown) transparentTypeDropdown.enabled = false;
|
||||
if (transparentTypeDropdown) transparentTypeDropdown.gameObject.SetActive(false);
|
||||
#endif
|
||||
|
||||
// 添加事件
|
||||
uniwinc.OnStateChanged += (type) =>
|
||||
{
|
||||
UpdateUI();
|
||||
//Debug.Log("Window state changed: " + type);
|
||||
ShowEventMessage("状态改变: " + type);
|
||||
//ShowEventMessage("State changed: " + type + "4:isKey 2:canBecomeKey, 1:canBecomeMain : " + uniwinc.GetDebugInfo().ToString());
|
||||
ShowClientSize();
|
||||
};
|
||||
uniwinc.OnMonitorChanged += () => {
|
||||
UpdateMonitorDropdown();
|
||||
UpdateUI();
|
||||
ShowEventMessage("分辨率已改变!");
|
||||
ShowClientSize();
|
||||
};
|
||||
uniwinc.OnDropFiles += files =>
|
||||
{
|
||||
ShowEventMessage(string.Join(Environment.NewLine, files));
|
||||
};
|
||||
}
|
||||
|
||||
// 即使 UinWinC 未就绪也能运行的 Listener
|
||||
showBorderlineToggle?.onValueChanged.AddListener(val => borderlinePanel.gameObject.SetActive(val));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示带超时功能的消息
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
private void ShowEventMessage(string message)
|
||||
{
|
||||
lastEventOccurredTime = Time.time;
|
||||
if (messageText) messageText.text = message;
|
||||
|
||||
Debug.Log(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 每帧执行的处理
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
// 更新点击测试相关的显示
|
||||
UpdateHitTestUI();
|
||||
|
||||
// 显示窗口位置和大小以确认运行状态
|
||||
if ((lastEventOccurredTime + eventMessageTimeout) < Time.time)
|
||||
{
|
||||
ShowWindowMetrics();
|
||||
}
|
||||
|
||||
// 鼠标右键点击显示菜单。移动距离在阈值以下视为点击。
|
||||
if (InputProxy.GetMouseButtonDown(1))
|
||||
{
|
||||
lastMousePosition = InputProxy.mousePosition;
|
||||
ResetTouchDuration();
|
||||
}
|
||||
if (InputProxy.GetMouseButton(1))
|
||||
{
|
||||
mouseMoveSS += (InputProxy.mousePosition - lastMousePosition).sqrMagnitude;
|
||||
}
|
||||
if (InputProxy.GetMouseButtonUp(1))
|
||||
{
|
||||
if (mouseMoveSS < mouseMoveSSThreshold)
|
||||
{
|
||||
ShowMenu(lastMousePosition);
|
||||
}
|
||||
mouseMoveSS = 0f;
|
||||
ResetTouchDuration();
|
||||
}
|
||||
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
// 长按也可显示菜单
|
||||
if (Input.touchSupported && (Input.touchCount > 0))
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
lastMousePosition = Input.mousePosition;
|
||||
ResetTouchDuration();
|
||||
}
|
||||
if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
|
||||
{
|
||||
mouseMoveSS += touch.deltaPosition.sqrMagnitude;
|
||||
touchDuration += touch.deltaTime;
|
||||
}
|
||||
if (touch.phase == TouchPhase.Ended)
|
||||
{
|
||||
if ((mouseMoveSS < mouseMoveSSThreshold) && (touchDuration >= touchDurationThreshold))
|
||||
{
|
||||
ShowMenu(lastMousePosition);
|
||||
}
|
||||
mouseMoveSS = 0f;
|
||||
ResetTouchDuration();
|
||||
}
|
||||
}
|
||||
#elif ENABLE_INPUT_SYSTEM
|
||||
// 目前 New Input System 不支持触摸
|
||||
// EnhancedTouch 不能与 InputAction 同时使用?
|
||||
#endif
|
||||
|
||||
// 按键也可更改设置
|
||||
if (uniwinc)
|
||||
{
|
||||
// 切换透明模式
|
||||
if (InputProxy.GetKeyUp("t"))
|
||||
{
|
||||
uniwinc.isTransparent = !uniwinc.isTransparent;
|
||||
}
|
||||
|
||||
// 切换始终置顶
|
||||
if (InputProxy.GetKeyUp("f"))
|
||||
{
|
||||
uniwinc.isTopmost = !uniwinc.isTopmost;
|
||||
}
|
||||
|
||||
// 切换始终置底
|
||||
if (InputProxy.GetKeyUp("b"))
|
||||
{
|
||||
uniwinc.isBottommost = !uniwinc.isBottommost;
|
||||
}
|
||||
|
||||
// 切换最大化
|
||||
if (InputProxy.GetKeyUp("z"))
|
||||
{
|
||||
uniwinc.isZoomed = !uniwinc.isZoomed;
|
||||
}
|
||||
|
||||
// 切换自由定位
|
||||
if (InputProxy.GetKeyUp("p"))
|
||||
{
|
||||
uniwinc.isFreePositioningEnabled = !uniwinc.isFreePositioningEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 测试打开文件面板
|
||||
if (InputProxy.GetKeyUp("o"))
|
||||
{
|
||||
FilePanel.Settings ds = new FilePanel.Settings
|
||||
{
|
||||
flags = FilePanel.Flag.AllowMultipleSelection,
|
||||
title = "打开!",
|
||||
filters = new FilePanel.Filter[]{
|
||||
new FilePanel.Filter("Image files", "png", "jpg", "jpeg"),
|
||||
new FilePanel.Filter("All files", "*"),
|
||||
},
|
||||
initialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
|
||||
initialFile = "test.png",
|
||||
};
|
||||
FilePanel.OpenFilePanel(ds, (files) => ShowEventMessage(string.Join(Environment.NewLine, files)));
|
||||
}
|
||||
|
||||
// 测试保存文件面板
|
||||
if (InputProxy.GetKeyUp("s"))
|
||||
{
|
||||
FilePanel.Settings ds = new FilePanel.Settings
|
||||
{
|
||||
flags = FilePanel.Flag.AllowMultipleSelection,
|
||||
title = "保存!",
|
||||
filters = new FilePanel.Filter[]{
|
||||
//// TODO: 指定文件类型时,macOS 保存对话框打开会失败
|
||||
//// 给 NSSavePanel.accessoryView 指定内容时会发生此问题。
|
||||
//// NSOpenPanel 继承自它,但不会发生此问题。
|
||||
// new FilePanel.Filter("Shell script", "sh"),
|
||||
// new FilePanel.Filter("Log", "log"),
|
||||
// new FilePanel.Filter("Plain text", "txt"),
|
||||
// new FilePanel.Filter("All files", "*"),
|
||||
},
|
||||
initialFile = "Test.txt",
|
||||
initialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
|
||||
};
|
||||
FilePanel.SaveFilePanel(ds, (files) => ShowEventMessage(string.Join(Environment.NewLine, files)));
|
||||
}
|
||||
|
||||
// 按下 [ESC] 时退出或停止播放
|
||||
if (InputProxy.GetKeyUp("escape"))
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置持续触摸时间的记录
|
||||
/// 仅在 Legacy Input Manager 中处理以避免警告
|
||||
/// </summary>
|
||||
void ResetTouchDuration() {
|
||||
#if ENABLE_LEGACY_INPUT_MANAGER
|
||||
touchDuration = 0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 适配显示器下拉列表更改时的处理
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
void SetFitToMonitor(int val)
|
||||
{
|
||||
if (!uniwinc) return;
|
||||
|
||||
if (val < 1)
|
||||
{
|
||||
// 下拉列表第一项为不适配
|
||||
uniwinc.shouldFitMonitor = false;
|
||||
|
||||
// 允许更改最大化状态
|
||||
if (zoomedToggle) zoomedToggle.interactable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 由于从第二项开始,显示器编号减1
|
||||
uniwinc.monitorToFit = val - 1;
|
||||
uniwinc.shouldFitMonitor = true; // 从false变为true时才会移动窗口,因此先指定显示器编号再更改
|
||||
|
||||
// 禁止更改最大化状态
|
||||
if (zoomedToggle) zoomedToggle.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示窗口位置和坐标
|
||||
/// </summary>
|
||||
void ShowWindowMetrics()
|
||||
{
|
||||
if (uniwinc)
|
||||
{
|
||||
var winPos = uniwinc.windowPosition;
|
||||
//var curPos = uniwinc.GetClientCursorPosition();
|
||||
OutputMessage(
|
||||
"位置: " + winPos
|
||||
+ "\n大小: " + uniwinc.windowSize
|
||||
+ "\n相对鼠标:" + (uniwinc.cursorPosition - winPos)
|
||||
//+ "\nScr. Cur.:" + curPos
|
||||
+ "\nUnity鼠标:" + (Vector2)InputProxy.mousePosition
|
||||
);
|
||||
ShowClientSize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 聚焦时刷新 UI
|
||||
/// </summary>
|
||||
/// <param name="hasFocus"></param>
|
||||
private void OnApplicationFocus(bool hasFocus)
|
||||
{
|
||||
if (hasFocus)
|
||||
{
|
||||
UpdateUI();
|
||||
|
||||
if (uniwinc)
|
||||
{
|
||||
OutputMessage("已聚焦");
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputMessage("未找到 UniWindowController");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在指定坐标显示上下文菜单
|
||||
/// </summary>
|
||||
/// <param name="position">指定中心坐标</param>
|
||||
private void ShowMenu(Vector2 position)
|
||||
{
|
||||
if (menuPanel)
|
||||
{
|
||||
Vector2 pos = position * (canvasRect.sizeDelta.x / Screen.width);
|
||||
float w = menuPanel.rect.width;
|
||||
float h = menuPanel.rect.height;
|
||||
|
||||
// 以指定坐标为中心进行位置调整
|
||||
pos.y = Mathf.Max(Mathf.Min(pos.y, Screen.height - h / 2f), h / 2f); // 如果超出则向上移动
|
||||
pos.x = Mathf.Max(Mathf.Min(pos.x, Screen.width - w / 2f), w / 2f); // 如果超出右侧则向左移动
|
||||
|
||||
menuPanel.pivot = Vector2.one * 0.5f; // 设置为中心
|
||||
menuPanel.anchorMin = Vector2.zero;
|
||||
menuPanel.anchorMax = Vector2.zero;
|
||||
menuPanel.anchoredPosition = pos;
|
||||
menuPanel.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭上下文菜单
|
||||
/// </summary>
|
||||
private void CloseMenu()
|
||||
{
|
||||
if (menuPanel)
|
||||
{
|
||||
menuPanel.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将实际状态反映到 UI 显示
|
||||
/// </summary>
|
||||
private void UpdateUI()
|
||||
{
|
||||
if (uniwinc)
|
||||
{
|
||||
if (transparentToggle)
|
||||
{
|
||||
transparentToggle.SetIsOnWithoutNotify(uniwinc.isTransparent);
|
||||
}
|
||||
|
||||
if (alphaSlider)
|
||||
{
|
||||
alphaSlider.SetValueWithoutNotify(uniwinc.alphaValue);
|
||||
}
|
||||
|
||||
if (topmostToggle)
|
||||
{
|
||||
topmostToggle.SetIsOnWithoutNotify(uniwinc.isTopmost);
|
||||
}
|
||||
|
||||
if (bottommostToggle)
|
||||
{
|
||||
bottommostToggle.SetIsOnWithoutNotify(uniwinc.isBottommost);
|
||||
}
|
||||
|
||||
if (zoomedToggle)
|
||||
{
|
||||
zoomedToggle.SetIsOnWithoutNotify(uniwinc.isZoomed);
|
||||
}
|
||||
|
||||
if (allowDropToggle)
|
||||
{
|
||||
allowDropToggle.SetIsOnWithoutNotify(uniwinc.allowDropFiles);
|
||||
}
|
||||
|
||||
if (dragMoveToggle)
|
||||
{
|
||||
dragMoveToggle.isOn = (uniWinMoveHandle && uniWinMoveHandle.isActiveAndEnabled);
|
||||
}
|
||||
|
||||
if (fitWindowDropdown)
|
||||
{
|
||||
if (uniwinc.shouldFitMonitor)
|
||||
{
|
||||
fitWindowDropdown.value = uniwinc.monitorToFit + 1;
|
||||
if (zoomedToggle) zoomedToggle.interactable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fitWindowDropdown.value = 0;
|
||||
if (zoomedToggle) zoomedToggle.interactable = true;
|
||||
}
|
||||
fitWindowDropdown.RefreshShownValue();
|
||||
}
|
||||
|
||||
if (transparentTypeDropdown)
|
||||
{
|
||||
transparentTypeDropdown.value = (int)uniwinc.transparentType;
|
||||
transparentTypeDropdown.RefreshShownValue();
|
||||
}
|
||||
|
||||
|
||||
if (hitTestTypeDropdown)
|
||||
{
|
||||
hitTestTypeDropdown.value = (int)uniwinc.hitTestType;
|
||||
hitTestTypeDropdown.RefreshShownValue();
|
||||
}
|
||||
|
||||
// 同时更新点击测试部分的显示
|
||||
UpdateHitTestUI();
|
||||
}
|
||||
|
||||
// 即使没有 UniWinC 也能运行的部分
|
||||
if (showBorderlineToggle && borderlinePanel)
|
||||
{
|
||||
borderlinePanel.gameObject.SetActive(showBorderlineToggle.isOn);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新点击测试相关的 UI
|
||||
/// 由于会自动变化,需要比 UpdateUI() 更频繁地更新
|
||||
/// </summary>
|
||||
public void UpdateHitTestUI()
|
||||
{
|
||||
if (uniwinc)
|
||||
{
|
||||
if (clickThroughToggle)
|
||||
{
|
||||
clickThroughToggle.SetIsOnWithoutNotify(uniwinc.isClickThrough);
|
||||
if (uniwinc.hitTestType == UniWindowController.HitTestType.None)
|
||||
{
|
||||
clickThroughToggle.interactable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
clickThroughToggle.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (uniwinc.hitTestType == UniWindowController.HitTestType.Opacity && uniwinc.isTransparent)
|
||||
{
|
||||
if (pickedColorImage)
|
||||
{
|
||||
pickedColorImage.color = uniwinc.pickedColor;
|
||||
}
|
||||
|
||||
if (pickedColorText)
|
||||
{
|
||||
pickedColorText.text = $"Alpha:{uniwinc.pickedColor.a:P0}";
|
||||
pickedColorText.color = Color.black;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pickedColorImage)
|
||||
{
|
||||
pickedColorImage.color = Color.gray;
|
||||
}
|
||||
|
||||
if (pickedColorText)
|
||||
{
|
||||
pickedColorText.text = $"颜色拾取器已禁用";
|
||||
pickedColorText.color = Color.gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新显示器选择下拉列表的选项
|
||||
/// 之后需要调用 UpdateUI()
|
||||
/// </summary>
|
||||
void UpdateMonitorDropdown()
|
||||
{
|
||||
if (!fitWindowDropdown) return;
|
||||
|
||||
// 删除除第一项以外的选项
|
||||
fitWindowDropdown.options.RemoveRange(1, fitWindowDropdown.options.Count - 1);
|
||||
|
||||
if (!uniwinc)
|
||||
{
|
||||
fitWindowDropdown.value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = UniWindowController.GetMonitorCount();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
fitWindowDropdown.options.Add(new Dropdown.OptionData("适配显示器 " + i));
|
||||
}
|
||||
if (uniwinc.monitorToFit >= count)
|
||||
{
|
||||
uniwinc.monitorToFit = count - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果 UI 中有文本框,则显示消息。否则输出到控制台
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
public void OutputMessage(string text)
|
||||
{
|
||||
if (messageText)
|
||||
{
|
||||
messageText.text = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log(text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果 UI 中有客户端大小文本框,则显示消息。否则输出到控制台
|
||||
/// </summary>
|
||||
public void ShowClientSize()
|
||||
{
|
||||
if (!uniwinc) return;
|
||||
|
||||
string text = "Client " + uniwinc.clientSize;
|
||||
if (clientSizeText)
|
||||
{
|
||||
clientSizeText.text = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user