This commit is contained in:
Даниил Заикин
2026-06-17 20:44:53 +03:00
parent 9d153773c2
commit b133e7c656
1880 changed files with 244545 additions and 0 deletions
@@ -0,0 +1,23 @@
using UnityEngine;
namespace QFSW.QC.UI
{
[ExecuteInEditMode]
public class BlurShaderController : MonoBehaviour
{
[SerializeField] private Material _blurMaterial = null;
[SerializeField] private float _blurRadius = 1f;
[SerializeField] private Vector2 _referenceResolution = new Vector2(1920, 1080);
private void LateUpdate()
{
if (_blurMaterial)
{
Vector2 resolution = new Vector2(Screen.width, Screen.height);
float correction = resolution.y / _referenceResolution.y;
_blurMaterial.SetFloat("_Radius", _blurRadius);
_blurMaterial.SetFloat("_BlurMultiplier", correction);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71717f6dc91a9d44f954817d678345d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,68 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace QFSW.QC.UI
{
[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
public class DraggableUI : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
[SerializeField] private RectTransform _dragRoot = null;
[SerializeField] private QuantumConsole _quantumConsole = null;
[SerializeField] private bool _lockInScreen = true;
[SerializeField] private UnityEvent _onBeginDrag = null;
[SerializeField] private UnityEvent _onDrag = null;
[SerializeField] private UnityEvent _onEndDrag = null;
private Vector2 _lastPos;
private bool _isDragging = false;
public void OnPointerDown(PointerEventData eventData)
{
_isDragging =
_quantumConsole &&
_quantumConsole.KeyConfig &&
_quantumConsole.KeyConfig.DragConsoleKey.IsHeld();
if (_isDragging)
{
_onBeginDrag.Invoke();
_lastPos = eventData.position;
}
}
public void LateUpdate()
{
if (_isDragging)
{
Transform root = _dragRoot;
if (!root) { root = transform as RectTransform; }
Vector2 pos = InputHelper.GetMousePosition();
Vector2 delta = pos - _lastPos;
_lastPos = pos;
if (_lockInScreen)
{
Vector2 resolution = new Vector2(Screen.width, Screen.height);
if (pos.x <= 0 || pos.x >= resolution.x) { delta.x = 0; }
if (pos.y <= 0 || pos.y >= resolution.y) { delta.y = 0; }
}
root.Translate(delta);
_onDrag.Invoke();
}
}
public void OnPointerUp(PointerEventData eventData)
{
if (_isDragging)
{
_isDragging = false;
_onEndDrag.Invoke();
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dddf2c665e079af45893ab7b0269d255
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,71 @@
using UnityEngine;
using UnityEngine.UI;
namespace QFSW.QC.UI
{
[ExecuteInEditMode]
public class DynamicCanvasScaler : MonoBehaviour
{
public float RectMagnification
{
get => _rectMagnification;
set
{
if (value > 0)
{
_rectMagnification = value;
}
}
}
[Range(0.5f, 2f)]
[SerializeField] private float _rectMagnification = 1f;
public float ZoomMagnification
{
get => _zoomMagnification;
set
{
if (value > 0)
{
_zoomMagnification = value;
}
}
}
[Range(0.5f, 2f)]
[SerializeField] private float _zoomMagnification = 1f;
[SerializeField] private CanvasScaler _scaler = null;
[SerializeField] private RectTransform _uiRoot = null;
[SerializeField] private Vector2 _referenceResolution = new Vector2(1920, 1080);
private float RootScaler => _rectMagnification / _zoomMagnification;
private float _lastScaler;
private void OnEnable()
{
_lastScaler = RootScaler;
}
private void Update()
{
if (_scaler && _uiRoot)
{
if (RootScaler != _lastScaler)
{
Rect rootRect = new Rect(_uiRoot.offsetMin.x / _lastScaler, _uiRoot.offsetMin.y / _lastScaler, _uiRoot.offsetMax.x / _lastScaler, _uiRoot.offsetMax.y / _lastScaler);
_lastScaler = RootScaler;
_scaler.referenceResolution = _referenceResolution / _zoomMagnification;
_uiRoot.offsetMin = new Vector2(rootRect.x, rootRect.y) * RootScaler;
_uiRoot.offsetMax = new Vector2(rootRect.width, rootRect.height) * RootScaler;
#if UNITY_EDITOR
UnityEditor.EditorUtility.SetDirty(_uiRoot);
UnityEditor.EditorUtility.SetDirty(_scaler);
#endif
}
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 937bd4b48d20c51489879aabbe372231
timeCreated: 1568116289
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
{
"name": "QFSW.QC.UI",
"references": [
"QFSW.QC",
"Unity.TextMeshPro"
],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0ea4188915c00fb4688accb5ae29f133
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,41 @@
using UnityEngine;
using UnityEngine.EventSystems;
namespace QFSW.QC.UI
{
[DisallowMultipleComponent]
public class ResizableUI : MonoBehaviour, IDragHandler
{
[SerializeField] private RectTransform _resizeRoot = null;
[SerializeField] private Canvas _resizeCanvas = null;
[SerializeField] private bool _lockInScreen = true;
[SerializeField] private Vector2 _minSize = new Vector2();
public void OnDrag(PointerEventData eventData)
{
Vector2 minBounds = (_resizeRoot.offsetMin + _minSize) * _resizeCanvas.scaleFactor;
Vector2 maxBounds = _lockInScreen
? new Vector2(Screen.width, Screen.height)
: new Vector2(Mathf.Infinity, Mathf.Infinity);
Vector2 delta = eventData.delta;
Vector2 posCurrent = eventData.position;
Vector2 posLast = posCurrent - delta;
Vector2 posCurrentBounded = new Vector2(
Mathf.Clamp(posCurrent.x, minBounds.x, maxBounds.x),
Mathf.Clamp(posCurrent.y, minBounds.y, maxBounds.y)
);
Vector2 posLastBounded = new Vector2(
Mathf.Clamp(posLast.x, minBounds.x, maxBounds.x),
Mathf.Clamp(posLast.y, minBounds.y, maxBounds.y)
);
Vector2 deltaBounded = posCurrentBounded - posLastBounded;
_resizeRoot.offsetMax += deltaBounded / _resizeCanvas.scaleFactor;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f34c043809e27534ebfd9bfa1410ac0a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace QFSW.QC.UI
{
[ExecuteInEditMode]
public class ZoomUIController : MonoBehaviour
{
[SerializeField] private float _zoomIncrement = 0.1f;
[SerializeField] private float _minZoom = 0.1f;
[SerializeField] private float _maxZoom = 2f;
[SerializeField] private Button _zoomDownBtn = null;
[SerializeField] private Button _zoomUpBtn = null;
[SerializeField] private DynamicCanvasScaler _scaler = null;
[SerializeField] private QuantumConsole _quantumConsole = null;
[SerializeField] private TextMeshProUGUI _text = null;
private float _lastZoom = -1;
private float ClampAndSnapZoom(float zoom)
{
float clampedZoom = Mathf.Min(_maxZoom, Mathf.Max(_minZoom, zoom));
float snappedZoom = Mathf.Round(clampedZoom / _zoomIncrement) * _zoomIncrement;
return snappedZoom;
}
public void ZoomUp()
{
_scaler.ZoomMagnification = ClampAndSnapZoom(_scaler.ZoomMagnification + _zoomIncrement);
}
public void ZoomDown()
{
_scaler.ZoomMagnification = ClampAndSnapZoom(_scaler.ZoomMagnification - _zoomIncrement);
}
private void Update()
{
if (_quantumConsole && _quantumConsole.KeyConfig)
{
if (_quantumConsole.KeyConfig.ZoomInKey.IsPressed()) { ZoomUp(); }
if (_quantumConsole.KeyConfig.ZoomOutKey.IsPressed()) { ZoomDown(); }
}
}
private void LateUpdate()
{
if (_scaler && _text)
{
float zoom = _scaler.ZoomMagnification;
if (zoom != _lastZoom)
{
_lastZoom = zoom;
int percentage = Mathf.RoundToInt(100 * zoom);
_text.text = $"{percentage}%";
}
}
if (_zoomDownBtn)
{
_zoomDownBtn.interactable = _lastZoom > _minZoom;
}
if (_zoomUpBtn)
{
_zoomUpBtn.interactable = _lastZoom < _maxZoom;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 302ba813ec8ed7b4da5659d8529ab761
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: