Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f58f6025e1 |
No files matched your search
+13
@@ -139,6 +139,19 @@ TextureImporter:
|
|||||||
ignorePlatformSupport: 0
|
ignorePlatformSupport: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: WindowsStoreApps
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 100
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
spriteSheet:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites: []
|
sprites: []
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,14 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9b12ce1ee004acbae19ebfe32026ca7
|
||||||
|
TrueTypeFontImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 4
|
||||||
|
fontSize: 16
|
||||||
|
characterPadding: 1
|
||||||
|
includeFontData: 1
|
||||||
|
fontNames:
|
||||||
|
- Exo 2
|
||||||
|
fallbackFontReferences: []
|
||||||
|
fontRenderingMode: 0
|
||||||
|
ascentCalculationMode: 1
|
||||||
|
shouldRoundAdvanceValue: 1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0b917cdca58366c49b88c71ee22b9a3d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9cd8f39eb9ca7914daf319df5b35d76e
|
||||||
|
VideoClipImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 3
|
||||||
|
frameRange: 0
|
||||||
|
startFrame: -1
|
||||||
|
endFrame: -1
|
||||||
|
colorSpace: 0
|
||||||
|
deinterlace: 0
|
||||||
|
encodeAlpha: 0
|
||||||
|
flipVertical: 0
|
||||||
|
flipHorizontal: 0
|
||||||
|
importAudio: 1
|
||||||
|
targetSettings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1df6207d90525474da9e8093a23c94dd
|
||||||
|
VideoClipImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 3
|
||||||
|
frameRange: 0
|
||||||
|
startFrame: -1
|
||||||
|
endFrame: -1
|
||||||
|
colorSpace: 0
|
||||||
|
deinterlace: 0
|
||||||
|
encodeAlpha: 0
|
||||||
|
flipVertical: 0
|
||||||
|
flipHorizontal: 0
|
||||||
|
importAudio: 1
|
||||||
|
targetSettings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f7175a9440a214747a5c4118ec5c878e
|
||||||
|
VideoClipImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 3
|
||||||
|
frameRange: 0
|
||||||
|
startFrame: -1
|
||||||
|
endFrame: -1
|
||||||
|
colorSpace: 0
|
||||||
|
deinterlace: 0
|
||||||
|
encodeAlpha: 0
|
||||||
|
flipVertical: 0
|
||||||
|
flipHorizontal: 0
|
||||||
|
importAudio: 1
|
||||||
|
targetSettings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bef6c581d659bb243a183f747bfb7be6
|
||||||
|
VideoClipImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 3
|
||||||
|
frameRange: 0
|
||||||
|
startFrame: -1
|
||||||
|
endFrame: -1
|
||||||
|
colorSpace: 0
|
||||||
|
deinterlace: 0
|
||||||
|
encodeAlpha: 0
|
||||||
|
flipVertical: 0
|
||||||
|
flipHorizontal: 0
|
||||||
|
importAudio: 1
|
||||||
|
targetSettings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 57a5a27328929e5469c1b1c664a99fdc
|
||||||
|
VideoClipImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 3
|
||||||
|
frameRange: 0
|
||||||
|
startFrame: -1
|
||||||
|
endFrame: -1
|
||||||
|
colorSpace: 0
|
||||||
|
deinterlace: 0
|
||||||
|
encodeAlpha: 0
|
||||||
|
flipVertical: 0
|
||||||
|
flipHorizontal: 0
|
||||||
|
importAudio: 1
|
||||||
|
targetSettings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+10605
-10885
File diff suppressed because it is too large.
Load diff
@@ -2,6 +2,8 @@ using System.Collections;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.XR.Interaction.Toolkit;
|
using UnityEngine.XR.Interaction.Toolkit;
|
||||||
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||||
|
using UnityEngine.XR.Interaction.Toolkit.Interactors;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class BabinaScript : MonoBehaviour
|
public class BabinaScript : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -21,12 +23,14 @@ public class BabinaScript : MonoBehaviour
|
|||||||
|
|
||||||
Transform SocketAttach;
|
Transform SocketAttach;
|
||||||
|
|
||||||
|
private XRSocketInteractor feederSocket;
|
||||||
|
private XRGrabInteractable reel;
|
||||||
|
private XRGrabInteractable tapeEnd;
|
||||||
|
private MeshRenderer tapeEndRenderer;
|
||||||
|
private XRSocketInteractor[] machineSockets;
|
||||||
|
private LineRenderer tapeMarker;
|
||||||
|
private LineRenderer socketMarker;
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
InitInteractionLayers = gameObject.GetComponent<XRGrabInteractable>().interactionLayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator SnapToSocketReset()
|
IEnumerator SnapToSocketReset()
|
||||||
{
|
{
|
||||||
@@ -43,13 +47,157 @@ public class BabinaScript : MonoBehaviour
|
|||||||
WireCapRenderer.enabled = true;
|
WireCapRenderer.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SwitchToRope(InteractionLayerMask SocketMask, Transform v_SocketAttach)
|
public void SwitchToRope(XRSocketInteractor socket)
|
||||||
{
|
{
|
||||||
gameObject.GetComponent<XRGrabInteractable>().interactionLayers = SocketMask;
|
CacheInteractables();
|
||||||
|
feederSocket = socket;
|
||||||
|
reel.interactionLayers = socket.interactionLayers;
|
||||||
|
|
||||||
SocketAttach = v_SocketAttach;
|
SocketAttach = socket.attachTransform;
|
||||||
|
|
||||||
StartCoroutine(SnapToSocketReset());
|
StartCoroutine(SnapToSocketReset());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CacheInteractables()
|
||||||
|
{
|
||||||
|
if (reel != null)
|
||||||
|
return;
|
||||||
|
reel = GetComponent<XRGrabInteractable>();
|
||||||
|
InitInteractionLayers = reel.interactionLayers;
|
||||||
|
tapeEnd = EndPos.GetComponent<XRGrabInteractable>();
|
||||||
|
tapeEndRenderer = EndPos.GetComponent<MeshRenderer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LateUpdate()
|
||||||
|
{
|
||||||
|
bool ready = feederSocket != null && feederSocket.IsSelecting(reel) &&
|
||||||
|
RopeRenderer.enabled && tapeEndRenderer.enabled && tapeEnd.isActiveAndEnabled;
|
||||||
|
var camera = ready ? Camera.main : null;
|
||||||
|
bool held = false;
|
||||||
|
if (camera != null)
|
||||||
|
{
|
||||||
|
foreach (var interactor in tapeEnd.interactorsSelecting)
|
||||||
|
{
|
||||||
|
if (interactor is XRSocketInteractor)
|
||||||
|
{
|
||||||
|
camera = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
held = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (camera == null)
|
||||||
|
{
|
||||||
|
HideMarker(tapeMarker);
|
||||||
|
HideMarker(socketMarker);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (held)
|
||||||
|
{
|
||||||
|
HideMarker(tapeMarker);
|
||||||
|
var socket = FindMachineSocket();
|
||||||
|
if (socket != null)
|
||||||
|
DrawMarker(ref socketMarker, camera, socket.attachTransform.position, 0.035f, new Color(0.1f, 1f, 0.8f));
|
||||||
|
else
|
||||||
|
HideMarker(socketMarker);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HideMarker(socketMarker);
|
||||||
|
var bounds = tapeEndRenderer.bounds;
|
||||||
|
DrawMarker(ref tapeMarker, camera, bounds.center, Mathf.Max(0.025f, bounds.extents.magnitude),
|
||||||
|
new Color(1f, 0.75f, 0.1f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TrySnapTape(IXRSelectInteractable released)
|
||||||
|
{
|
||||||
|
const float snapRadius = 0.16f;
|
||||||
|
if (!ReferenceEquals(released, tapeEnd) || feederSocket == null || !feederSocket.IsSelecting(reel))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var socket = FindMachineSocket();
|
||||||
|
if (socket == null || socket.interactionManager == null ||
|
||||||
|
!socket.interactionManager.IsSelectPossible(socket, tapeEnd))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var tapeAttach = tapeEnd.GetAttachTransform(socket);
|
||||||
|
var socketAttach = socket.attachTransform;
|
||||||
|
if ((tapeAttach.position - socketAttach.position).sqrMagnitude > snapRadius * snapRadius)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
socket.interactionManager.SelectEnter(socket, released);
|
||||||
|
return socket.IsSelecting(tapeEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
private XRSocketInteractor FindMachineSocket()
|
||||||
|
{
|
||||||
|
if (machineSockets == null)
|
||||||
|
{
|
||||||
|
var sockets = FindObjectsByType<FilteredSocket>(FindObjectsInactive.Include);
|
||||||
|
machineSockets = System.Array.ConvertAll(sockets, socket => socket.GetComponent<XRSocketInteractor>());
|
||||||
|
}
|
||||||
|
|
||||||
|
XRSocketInteractor closest = null;
|
||||||
|
float closestDistance = float.PositiveInfinity;
|
||||||
|
foreach (var socket in machineSockets)
|
||||||
|
{
|
||||||
|
if (socket == null || !socket.isActiveAndEnabled || !socket.socketActive || socket.hasSelection ||
|
||||||
|
!socket.CompareTag(tapeEnd.tag) || (socket.interactionLayers.value & tapeEnd.interactionLayers.value) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
float distance = (socket.attachTransform.position - feederSocket.attachTransform.position).sqrMagnitude;
|
||||||
|
if (distance < closestDistance)
|
||||||
|
{
|
||||||
|
closestDistance = distance;
|
||||||
|
closest = socket;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return closest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawMarker(ref LineRenderer marker, Camera camera, Vector3 center, float radius, Color color)
|
||||||
|
{
|
||||||
|
const int pointCount = 32;
|
||||||
|
if (marker == null)
|
||||||
|
{
|
||||||
|
var markerObject = new GameObject("Tape loading hint");
|
||||||
|
markerObject.transform.SetParent(transform, false);
|
||||||
|
marker = markerObject.AddComponent<LineRenderer>();
|
||||||
|
marker.sharedMaterial = Graphic.defaultGraphicMaterial;
|
||||||
|
marker.loop = true;
|
||||||
|
marker.useWorldSpace = true;
|
||||||
|
marker.positionCount = pointCount;
|
||||||
|
marker.widthMultiplier = 0.004f;
|
||||||
|
marker.startColor = color;
|
||||||
|
marker.endColor = color;
|
||||||
|
marker.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||||
|
marker.receiveShadows = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
marker.enabled = true;
|
||||||
|
radius *= 1f + 0.12f * Mathf.Sin(Time.unscaledTime * 5f);
|
||||||
|
var view = camera.transform;
|
||||||
|
center += (view.position - center).normalized * 0.025f;
|
||||||
|
for (int i = 0; i < pointCount; i++)
|
||||||
|
{
|
||||||
|
float angle = i * (2f * Mathf.PI / pointCount);
|
||||||
|
marker.SetPosition(i, center + radius * (view.right * Mathf.Cos(angle) + view.up * Mathf.Sin(angle)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
HideMarker(tapeMarker);
|
||||||
|
HideMarker(socketMarker);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HideMarker(LineRenderer marker)
|
||||||
|
{
|
||||||
|
if (marker != null)
|
||||||
|
marker.enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.InputSystem.UI;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.XR.Interaction.Toolkit;
|
||||||
|
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||||
|
using UnityEngine.XR.Interaction.Toolkit.Interactors;
|
||||||
|
using UnityEngine.XR.Interaction.Toolkit.UI;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(EventSystem))]
|
||||||
|
public sealed class DesktopMachineControls : MonoBehaviour
|
||||||
|
{
|
||||||
|
private const float EyeHeight = 1.36f;
|
||||||
|
private const float Reach = 5f;
|
||||||
|
private const float HoldDistancePerScrollStep = 0.18f;
|
||||||
|
private readonly List<RaycastResult> uiHits = new();
|
||||||
|
private Camera playerCamera;
|
||||||
|
private CharacterController controller;
|
||||||
|
private XRRayInteractor mouseInteractor;
|
||||||
|
private XRInteractionManager interactionManager;
|
||||||
|
private EventSystem eventSystem;
|
||||||
|
private PointerEventData pointer;
|
||||||
|
private float yaw;
|
||||||
|
private float pitch;
|
||||||
|
private float fallSpeed;
|
||||||
|
private bool holding;
|
||||||
|
private MachineTaskPanel taskPanel;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
playerCamera = Camera.main;
|
||||||
|
interactionManager = FindAnyObjectByType<XRInteractionManager>();
|
||||||
|
if (playerCamera == null || interactionManager == null)
|
||||||
|
{
|
||||||
|
Debug.LogError("Desktop controls require a Main Camera and XR Interaction Manager.", this);
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = new GameObject("Desktop Player") { layer = 2 };
|
||||||
|
player.transform.SetPositionAndRotation(playerCamera.transform.position - Vector3.up * EyeHeight, Quaternion.identity);
|
||||||
|
controller = player.AddComponent<CharacterController>();
|
||||||
|
controller.height = 1.5f;
|
||||||
|
controller.radius = 0.22f;
|
||||||
|
controller.center = Vector3.up * 0.75f;
|
||||||
|
controller.stepOffset = 0.18f;
|
||||||
|
controller.minMoveDistance = 0f;
|
||||||
|
playerCamera.transform.SetParent(player.transform, true);
|
||||||
|
yaw = playerCamera.transform.eulerAngles.y;
|
||||||
|
pitch = Mathf.DeltaAngle(0f, playerCamera.transform.eulerAngles.x);
|
||||||
|
|
||||||
|
eventSystem = GetComponent<EventSystem>();
|
||||||
|
pointer = new PointerEventData(eventSystem);
|
||||||
|
if (TryGetComponent<XRUIInputModule>(out var previousModule))
|
||||||
|
previousModule.enabled = false;
|
||||||
|
var ui = gameObject.AddComponent<InputSystemUIInputModule>();
|
||||||
|
ui.cursorLockBehavior = InputSystemUIInputModule.CursorLockBehavior.ScreenCenter;
|
||||||
|
|
||||||
|
foreach (var canvas in FindObjectsByType<Canvas>(FindObjectsInactive.Include))
|
||||||
|
{
|
||||||
|
if (canvas.renderMode == RenderMode.WorldSpace && canvas.worldCamera == null)
|
||||||
|
canvas.worldCamera = playerCamera;
|
||||||
|
if (canvas.TryGetComponent<TrackedDeviceGraphicRaycaster>(out var trackedRaycaster))
|
||||||
|
{
|
||||||
|
trackedRaycaster.enabled = false;
|
||||||
|
if (!canvas.TryGetComponent<GraphicRaycaster>(out _))
|
||||||
|
canvas.gameObject.AddComponent<GraphicRaycaster>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var rayObject = new GameObject("Desktop Interaction Ray");
|
||||||
|
rayObject.SetActive(false);
|
||||||
|
rayObject.transform.SetParent(playerCamera.transform, false);
|
||||||
|
var attach = new GameObject("Held Item Anchor").transform;
|
||||||
|
attach.SetParent(rayObject.transform, false);
|
||||||
|
mouseInteractor = rayObject.AddComponent<XRRayInteractor>();
|
||||||
|
mouseInteractor.interactionManager = interactionManager;
|
||||||
|
mouseInteractor.referenceFrame = player.transform;
|
||||||
|
mouseInteractor.rayOriginTransform = rayObject.transform;
|
||||||
|
mouseInteractor.attachTransform = attach;
|
||||||
|
mouseInteractor.interactionLayers = -1;
|
||||||
|
mouseInteractor.enableUIInteraction = false;
|
||||||
|
mouseInteractor.useForceGrab = true;
|
||||||
|
mouseInteractor.manipulateAttachTransform = false;
|
||||||
|
mouseInteractor.maxRaycastDistance = Reach;
|
||||||
|
rayObject.SetActive(true);
|
||||||
|
taskPanel = gameObject.AddComponent<MachineTaskPanel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start() => SetCursorLocked(true);
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
var mouse = Mouse.current;
|
||||||
|
var keyboard = Keyboard.current;
|
||||||
|
if (mouse == null || keyboard == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (keyboard.escapeKey.wasPressedThisFrame)
|
||||||
|
{
|
||||||
|
ReleaseItem();
|
||||||
|
SetCursorLocked(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Cursor.lockState != CursorLockMode.Locked)
|
||||||
|
{
|
||||||
|
if (mouse.leftButton.wasPressedThisFrame)
|
||||||
|
SetCursorLocked(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var mouseDelta = mouse.delta.ReadValue() * 0.12f;
|
||||||
|
yaw += mouseDelta.x;
|
||||||
|
pitch = Mathf.Clamp(pitch - mouseDelta.y, -85f, 85f);
|
||||||
|
playerCamera.transform.rotation = Quaternion.Euler(pitch, yaw, 0f);
|
||||||
|
MovePlayer(keyboard);
|
||||||
|
|
||||||
|
if (mouse.leftButton.wasPressedThisFrame)
|
||||||
|
TryPickUp();
|
||||||
|
if (!mouse.leftButton.isPressed)
|
||||||
|
ReleaseItem(snapTape: mouse.leftButton.wasReleasedThisFrame);
|
||||||
|
|
||||||
|
if (holding && mouseInteractor.hasSelection)
|
||||||
|
{
|
||||||
|
var attach = mouseInteractor.attachTransform;
|
||||||
|
var position = attach.localPosition;
|
||||||
|
var scroll = mouse.scroll.ReadValue().y;
|
||||||
|
if (Application.platform is RuntimePlatform.WindowsEditor or RuntimePlatform.WindowsPlayer &&
|
||||||
|
InputSystem.settings.scrollDeltaBehavior == InputSettings.ScrollDeltaBehavior.KeepPlatformSpecificInputRange)
|
||||||
|
scroll /= 120f;
|
||||||
|
|
||||||
|
position.z = Mathf.Clamp(position.z + scroll * HoldDistancePerScrollStep, 0.18f, Reach);
|
||||||
|
attach.localPosition = position;
|
||||||
|
float rotation = Axis(keyboard.eKey.isPressed, keyboard.qKey.isPressed);
|
||||||
|
attach.Rotate(Vector3.forward, rotation * 90f * Time.deltaTime, Space.Self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TryPickUp()
|
||||||
|
{
|
||||||
|
var ray = playerCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f));
|
||||||
|
var hits = Physics.RaycastAll(ray, Reach, Physics.DefaultRaycastLayers, QueryTriggerInteraction.Collide);
|
||||||
|
Array.Sort(hits, (first, second) => first.distance.CompareTo(second.distance));
|
||||||
|
foreach (var hit in hits)
|
||||||
|
{
|
||||||
|
if (interactionManager.TryGetInteractableForCollider(hit.collider, out var interactable) &&
|
||||||
|
interactable is IXRSelectInteractable target &&
|
||||||
|
interactionManager.IsSelectPossible(mouseInteractor, target))
|
||||||
|
{
|
||||||
|
if (HasUIInFront(hit.distance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool isReel = target.transform.TryGetComponent<BabinaScript>(out _);
|
||||||
|
Quaternion holdRotation = playerCamera.transform.rotation;
|
||||||
|
if (isReel)
|
||||||
|
holdRotation *= Quaternion.Euler(0f, 90f, 0f);
|
||||||
|
|
||||||
|
mouseInteractor.attachTransform.SetPositionAndRotation(hit.point, holdRotation);
|
||||||
|
mouseInteractor.StartManualInteraction(target);
|
||||||
|
holding = mouseInteractor.IsSelecting(target);
|
||||||
|
if (holding && isReel)
|
||||||
|
taskPanel?.ReelPickedUp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hit.collider.isTrigger)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool HasUIInFront(float objectDistance)
|
||||||
|
{
|
||||||
|
pointer.position = playerCamera.pixelRect.center;
|
||||||
|
uiHits.Clear();
|
||||||
|
eventSystem.RaycastAll(pointer, uiHits);
|
||||||
|
foreach (var hit in uiHits)
|
||||||
|
{
|
||||||
|
if (hit.distance <= objectDistance + 0.02f &&
|
||||||
|
(ExecuteEvents.GetEventHandler<IPointerClickHandler>(hit.gameObject) != null ||
|
||||||
|
ExecuteEvents.GetEventHandler<IPointerDownHandler>(hit.gameObject) != null ||
|
||||||
|
ExecuteEvents.GetEventHandler<IDragHandler>(hit.gameObject) != null))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReleaseItem(bool snapTape = false)
|
||||||
|
{
|
||||||
|
if (!holding)
|
||||||
|
return;
|
||||||
|
holding = false;
|
||||||
|
var released = mouseInteractor.firstInteractableSelected;
|
||||||
|
mouseInteractor.EndManualInteraction();
|
||||||
|
if (!snapTape || released == null || !released.transform.TryGetComponent<MaterialRopeDetachAction>(out _))
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var reel in FindObjectsByType<BabinaScript>())
|
||||||
|
{
|
||||||
|
if (reel.TrySnapTape(released))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MovePlayer(Keyboard keyboard)
|
||||||
|
{
|
||||||
|
var selected = eventSystem.currentSelectedGameObject;
|
||||||
|
var typing = selected != null &&
|
||||||
|
((selected.TryGetComponent<TMPro.TMP_InputField>(out var tmpField) && tmpField.isFocused) ||
|
||||||
|
(selected.TryGetComponent<InputField>(out var inputField) && inputField.isFocused));
|
||||||
|
var input = typing ? Vector3.zero : new Vector3(
|
||||||
|
Axis(keyboard.dKey.isPressed, keyboard.aKey.isPressed), 0f,
|
||||||
|
Axis(keyboard.wKey.isPressed, keyboard.sKey.isPressed));
|
||||||
|
var direction = Quaternion.Euler(0f, yaw, 0f) * Vector3.ClampMagnitude(input, 1f);
|
||||||
|
var speed = keyboard.shiftKey.isPressed ? 3f : 1.4f;
|
||||||
|
fallSpeed = controller.isGrounded ? -2f : Mathf.Max(-20f, fallSpeed + Physics.gravity.y * Time.deltaTime);
|
||||||
|
controller.Move((direction * speed + Vector3.up * fallSpeed) * Time.deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
if (Cursor.lockState == CursorLockMode.Locked && Event.current.type == EventType.Repaint)
|
||||||
|
GUI.DrawTexture(new Rect(Screen.width * 0.5f - 2f, Screen.height * 0.5f - 2f, 4f, 4f), Texture2D.whiteTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float Axis(bool positive, bool negative) => (positive ? 1f : 0f) - (negative ? 1f : 0f);
|
||||||
|
|
||||||
|
private static void SetCursorLocked(bool locked)
|
||||||
|
{
|
||||||
|
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
|
||||||
|
Cursor.visible = !locked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnApplicationFocus(bool focused)
|
||||||
|
{
|
||||||
|
if (!focused)
|
||||||
|
{
|
||||||
|
ReleaseItem();
|
||||||
|
SetCursorLocked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
ReleaseItem();
|
||||||
|
SetCursorLocked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 34d985ab762944b694601da0bf708fec
|
||||||
@@ -62,6 +62,10 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
List<bool> InsertedReels;
|
List<bool> InsertedReels;
|
||||||
|
|
||||||
|
public int InstalledReelCount => InsertedReels.Count(inserted => inserted);
|
||||||
|
public int AttachedTapeCount => InsertedMaterials.Count(inserted => inserted);
|
||||||
|
public bool IsWorking => WorkInProgress;
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
bool ReadyToWork = false;
|
bool ReadyToWork = false;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,400 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.Video;
|
||||||
|
|
||||||
|
public sealed class MachineTaskPanel : MonoBehaviour
|
||||||
|
{
|
||||||
|
private const int RequiredCount = 3;
|
||||||
|
private const float PanelWidth = 432f;
|
||||||
|
private const float Margin = 24f;
|
||||||
|
private const float SlideDuration = 0.42f;
|
||||||
|
private const float GlowPadding = 16f;
|
||||||
|
private const float GlowDuration = 1.4f;
|
||||||
|
|
||||||
|
private MachineCoordinatesMovementScript machine;
|
||||||
|
private UnityEngine.UI.Button playButton;
|
||||||
|
private RectTransform panel;
|
||||||
|
private CanvasGroup panelGroup;
|
||||||
|
private const float InstructionTop = 58f;
|
||||||
|
private const float ContentWidth = 386f;
|
||||||
|
private const float VideoHeight = 217f;
|
||||||
|
private const float VideoDuration = 0.32f;
|
||||||
|
private static readonly string[] VideoNames = { "PickUpReel", "InsertReel", "AttachTape", "RunMachine" };
|
||||||
|
|
||||||
|
private Text instruction;
|
||||||
|
private Text secondInstruction;
|
||||||
|
private RectTransform videoViewport;
|
||||||
|
private RawImage videoImage;
|
||||||
|
private VideoPlayer videoPlayer;
|
||||||
|
private RenderTexture videoTexture;
|
||||||
|
private VideoClip[] taskVideos;
|
||||||
|
private int currentVideoStep = -1;
|
||||||
|
private float videoProgress;
|
||||||
|
private Text status;
|
||||||
|
private Image completionGlow;
|
||||||
|
private Sprite roundedSprite;
|
||||||
|
private Sprite glowSprite;
|
||||||
|
private Font font;
|
||||||
|
private int task;
|
||||||
|
private int displayedCount = -1;
|
||||||
|
private bool reelPickedUp;
|
||||||
|
private bool playPressed;
|
||||||
|
private bool transitioning;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
machine = FindAnyObjectByType<MachineCoordinatesMovementScript>();
|
||||||
|
if (machine == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Machine tasks require the machine controller.", this);
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BindPlayButton();
|
||||||
|
BuildPanel();
|
||||||
|
ShowTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
UpdateVideo();
|
||||||
|
if (task == 2 && playButton == null)
|
||||||
|
BindPlayButton();
|
||||||
|
if (transitioning || task >= 3)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int count = task == 0 ? machine.InstalledReelCount : machine.AttachedTapeCount;
|
||||||
|
if (count != displayedCount && task < 2)
|
||||||
|
ShowTask();
|
||||||
|
|
||||||
|
if ((task < 2 && count >= RequiredCount) || (task == 2 && playPressed))
|
||||||
|
StartCoroutine(CompleteTask());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReelPickedUp()
|
||||||
|
{
|
||||||
|
if (reelPickedUp)
|
||||||
|
return;
|
||||||
|
reelPickedUp = true;
|
||||||
|
displayedCount = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BindPlayButton()
|
||||||
|
{
|
||||||
|
var monitor = FindAnyObjectByType<ControlButtonsScript>();
|
||||||
|
if (monitor != null && monitor.buttonsDictionary != null &&
|
||||||
|
monitor.buttonsDictionary.TryGetValue("Run", out playButton) && playButton != null)
|
||||||
|
playButton.onClick.AddListener(OnPlayPressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPlayPressed()
|
||||||
|
{
|
||||||
|
if (machine.IsWorking && machine.InstalledReelCount >= RequiredCount &&
|
||||||
|
machine.AttachedTapeCount >= RequiredCount)
|
||||||
|
playPressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowTask()
|
||||||
|
{
|
||||||
|
var count = task == 0 ? machine.InstalledReelCount : machine.AttachedTapeCount;
|
||||||
|
displayedCount = count;
|
||||||
|
instruction.text = task switch
|
||||||
|
{
|
||||||
|
0 => (reelPickedUp || count > 0 ? "<color=#B2F1CC>" : "") +
|
||||||
|
"1. Возьмите катушку с SMD-компонентами (зажать ЛКМ)" +
|
||||||
|
(reelPickedUp || count > 0 ? "</color>" : ""),
|
||||||
|
1 => $"Возьмитесь за ленту с катушки и зафиксируйте на станке ({count}/{RequiredCount})",
|
||||||
|
_ => "Нажмите кнопку RUN на мониторе."
|
||||||
|
};
|
||||||
|
secondInstruction.enabled = task == 0;
|
||||||
|
secondInstruction.text = $"2. Перенесите катушку в фидер ({count}/{RequiredCount})";
|
||||||
|
status.enabled = false;
|
||||||
|
LayoutVideo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator CompleteTask()
|
||||||
|
{
|
||||||
|
transitioning = true;
|
||||||
|
status.enabled = true;
|
||||||
|
LayoutVideo();
|
||||||
|
float elapsed = 0f;
|
||||||
|
while (elapsed < GlowDuration)
|
||||||
|
{
|
||||||
|
float pulse = Mathf.Sin(elapsed / GlowDuration * 2f * Mathf.PI);
|
||||||
|
SetGlow(pulse * pulse);
|
||||||
|
yield return null;
|
||||||
|
elapsed += Time.unscaledDeltaTime;
|
||||||
|
}
|
||||||
|
SetGlow(0f);
|
||||||
|
|
||||||
|
float hiddenX = -PanelWidth - Margin - GlowPadding;
|
||||||
|
yield return Slide(Margin, hiddenX, 1f, 0f);
|
||||||
|
task++;
|
||||||
|
if (task < 3)
|
||||||
|
{
|
||||||
|
ShowTask();
|
||||||
|
yield return Slide(hiddenX, Margin, 0f, 1f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
panel.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
transitioning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator Slide(float from, float to, float fromAlpha, float toAlpha)
|
||||||
|
{
|
||||||
|
float started = Time.unscaledTime;
|
||||||
|
float progress;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
progress = Mathf.Clamp01((Time.unscaledTime - started) / SlideDuration);
|
||||||
|
float eased = Mathf.SmoothStep(0f, 1f, progress);
|
||||||
|
panel.anchoredPosition = new Vector2(Mathf.Lerp(from, to, eased), -Margin);
|
||||||
|
panelGroup.alpha = Mathf.Lerp(fromAlpha, toAlpha, eased);
|
||||||
|
yield return null;
|
||||||
|
} while (progress < 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildPanel()
|
||||||
|
{
|
||||||
|
font = Resources.Load<Font>("Exo2-VariableFont_wght");
|
||||||
|
if (font == null)
|
||||||
|
font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
|
||||||
|
|
||||||
|
roundedSprite = CreateRoundedSprite(0f);
|
||||||
|
glowSprite = CreateRoundedSprite(GlowPadding);
|
||||||
|
var root = new GameObject("Machine Tasks", typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler));
|
||||||
|
root.transform.SetParent(transform, false);
|
||||||
|
var canvas = root.GetComponent<Canvas>();
|
||||||
|
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||||
|
canvas.sortingOrder = 50;
|
||||||
|
var scaler = root.GetComponent<CanvasScaler>();
|
||||||
|
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
||||||
|
scaler.referenceResolution = new Vector2(1920f, 1080f);
|
||||||
|
scaler.matchWidthOrHeight = 0.5f;
|
||||||
|
|
||||||
|
var panelObject = new GameObject("Task Panel", typeof(RectTransform), typeof(CanvasGroup));
|
||||||
|
panel = panelObject.GetComponent<RectTransform>();
|
||||||
|
panel.SetParent(root.transform, false);
|
||||||
|
panel.anchorMin = panel.anchorMax = panel.pivot = new Vector2(0f, 1f);
|
||||||
|
panel.sizeDelta = new Vector2(PanelWidth, 262f);
|
||||||
|
panel.anchoredPosition = new Vector2(Margin, -Margin);
|
||||||
|
panelGroup = panel.GetComponent<CanvasGroup>();
|
||||||
|
panelGroup.blocksRaycasts = false;
|
||||||
|
panelGroup.interactable = false;
|
||||||
|
|
||||||
|
var glow = AddImage(panel, "Completion Glow", Color.clear, glowSprite);
|
||||||
|
Stretch(glow, -GlowPadding);
|
||||||
|
completionGlow = glow.GetComponent<Image>();
|
||||||
|
|
||||||
|
var frame = AddImage(panel, "Outer Border", new Color32(38, 40, 118, 236), roundedSprite);
|
||||||
|
Stretch(frame, 0f);
|
||||||
|
var accent = AddImage(frame, "Inner Border", new Color32(89, 161, 241, 238), roundedSprite);
|
||||||
|
Stretch(accent, 4f);
|
||||||
|
var background = AddImage(accent, "Background", new Color32(17, 58, 105, 235), roundedSprite);
|
||||||
|
Stretch(background, 2f);
|
||||||
|
|
||||||
|
AddText(background, "Heading", "Задача", new Vector2(0f, -14f), new Vector2(318f, 31f),
|
||||||
|
26, TextAnchor.UpperCenter, new Color32(233, 245, 255, 255)).fontStyle = FontStyle.Bold;
|
||||||
|
instruction = AddText(background, "Instructions", "", new Vector2(17f, -58f), new Vector2(386f, 145f),
|
||||||
|
22, TextAnchor.UpperLeft, Color.white);
|
||||||
|
secondInstruction = AddText(background, "Second Instruction", "", Vector2.zero, new Vector2(ContentWidth, 70f),
|
||||||
|
22, TextAnchor.UpperLeft, Color.white);
|
||||||
|
BuildVideo(background);
|
||||||
|
status = AddText(background, "Task Status", "Выполнено", new Vector2(0f, -212f), new Vector2(318f, 29f),
|
||||||
|
22, TextAnchor.UpperCenter, new Color32(151, 255, 188, 255));
|
||||||
|
status.fontStyle = FontStyle.Bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildVideo(Transform parent)
|
||||||
|
{
|
||||||
|
taskVideos = new VideoClip[VideoNames.Length];
|
||||||
|
for (int i = 0; i < VideoNames.Length; i++)
|
||||||
|
{
|
||||||
|
taskVideos[i] = Resources.Load<VideoClip>("TaskVideos/" + VideoNames[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var viewport = new GameObject("Video Hint", typeof(RectTransform), typeof(RectMask2D));
|
||||||
|
videoViewport = viewport.GetComponent<RectTransform>();
|
||||||
|
videoViewport.SetParent(parent, false);
|
||||||
|
videoViewport.anchorMin = videoViewport.anchorMax = videoViewport.pivot = new Vector2(0f, 1f);
|
||||||
|
|
||||||
|
var image = new GameObject("Video Image", typeof(RectTransform), typeof(RawImage));
|
||||||
|
videoImage = image.GetComponent<RawImage>();
|
||||||
|
videoImage.raycastTarget = false;
|
||||||
|
var imageRect = videoImage.rectTransform;
|
||||||
|
imageRect.SetParent(videoViewport, false);
|
||||||
|
imageRect.anchorMin = imageRect.anchorMax = imageRect.pivot = new Vector2(0f, 1f);
|
||||||
|
imageRect.sizeDelta = new Vector2(ContentWidth, VideoHeight);
|
||||||
|
|
||||||
|
videoTexture = new RenderTexture(768, 432, 0) { name = "Task Video" };
|
||||||
|
videoImage.texture = videoTexture;
|
||||||
|
videoPlayer = viewport.AddComponent<VideoPlayer>();
|
||||||
|
videoPlayer.playOnAwake = false;
|
||||||
|
videoPlayer.isLooping = true;
|
||||||
|
videoPlayer.audioOutputMode = VideoAudioOutputMode.None;
|
||||||
|
videoPlayer.aspectRatio = VideoAspectRatio.FitInside;
|
||||||
|
videoPlayer.renderMode = VideoRenderMode.RenderTexture;
|
||||||
|
videoPlayer.targetTexture = videoTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateVideo()
|
||||||
|
{
|
||||||
|
if (videoPlayer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int nextStep = transitioning || task >= 3 ? -1 : task switch
|
||||||
|
{
|
||||||
|
0 => reelPickedUp || machine.InstalledReelCount > 0 ? 1 : 0,
|
||||||
|
1 => 2,
|
||||||
|
_ => 3
|
||||||
|
};
|
||||||
|
if (nextStep >= 0 && taskVideos[nextStep] == null)
|
||||||
|
nextStep = -1;
|
||||||
|
|
||||||
|
if (currentVideoStep != nextStep && videoProgress <= 0f)
|
||||||
|
{
|
||||||
|
videoPlayer.Stop();
|
||||||
|
currentVideoStep = nextStep;
|
||||||
|
if (nextStep >= 0)
|
||||||
|
{
|
||||||
|
videoPlayer.clip = taskVideos[nextStep];
|
||||||
|
videoPlayer.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool show = currentVideoStep >= 0 && currentVideoStep == nextStep && videoPlayer.isPrepared;
|
||||||
|
float progress = Mathf.MoveTowards(videoProgress, show ? 1f : 0f, Time.unscaledDeltaTime / VideoDuration);
|
||||||
|
if (progress != videoProgress)
|
||||||
|
{
|
||||||
|
videoProgress = progress;
|
||||||
|
LayoutVideo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LayoutVideo()
|
||||||
|
{
|
||||||
|
float open = Mathf.SmoothStep(0f, 1f, videoProgress);
|
||||||
|
float extraHeight = (VideoHeight + 12f) * open;
|
||||||
|
float afterFirst = InstructionTop + instruction.preferredHeight + 10f;
|
||||||
|
bool betweenPoints = task == 0 && currentVideoStep == 0;
|
||||||
|
|
||||||
|
secondInstruction.rectTransform.anchoredPosition = new Vector2(17f,
|
||||||
|
-afterFirst - (betweenPoints ? extraHeight : 0f));
|
||||||
|
float videoTop = task == 0 && !betweenPoints ? afterFirst + secondInstruction.preferredHeight + 10f : afterFirst;
|
||||||
|
videoViewport.anchoredPosition = new Vector2(17f, -videoTop);
|
||||||
|
videoViewport.sizeDelta = new Vector2(ContentWidth, VideoHeight * open);
|
||||||
|
videoImage.color = new Color(1f, 1f, 1f, open);
|
||||||
|
videoImage.enabled = open > 0f;
|
||||||
|
|
||||||
|
float contentBottom = videoTop + extraHeight;
|
||||||
|
float panelHeight = task == 0
|
||||||
|
? Mathf.Max(262f, videoTop + 54f) + extraHeight
|
||||||
|
: contentBottom + (status.enabled ? 46f : 12f);
|
||||||
|
panel.sizeDelta = new Vector2(PanelWidth, panelHeight);
|
||||||
|
float statusTop = task == 0 ? panelHeight - 50f : contentBottom + 6f;
|
||||||
|
status.rectTransform.anchoredPosition = new Vector2(0f, -statusTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RectTransform AddImage(Transform parent, string name, Color color, Sprite sprite)
|
||||||
|
{
|
||||||
|
var child = new GameObject(name, typeof(RectTransform), typeof(Image));
|
||||||
|
child.transform.SetParent(parent, false);
|
||||||
|
var image = child.GetComponent<Image>();
|
||||||
|
image.sprite = sprite;
|
||||||
|
image.type = Image.Type.Sliced;
|
||||||
|
image.color = color;
|
||||||
|
image.raycastTarget = false;
|
||||||
|
return image.rectTransform;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Stretch(RectTransform rect, float inset)
|
||||||
|
{
|
||||||
|
rect.anchorMin = Vector2.zero;
|
||||||
|
rect.anchorMax = Vector2.one;
|
||||||
|
rect.offsetMin = Vector2.one * inset;
|
||||||
|
rect.offsetMax = -Vector2.one * inset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Text AddText(Transform parent, string name, string content, Vector2 position, Vector2 size,
|
||||||
|
int fontSize, TextAnchor alignment, Color color)
|
||||||
|
{
|
||||||
|
var child = new GameObject(name, typeof(RectTransform), typeof(Text));
|
||||||
|
child.transform.SetParent(parent, false);
|
||||||
|
var text = child.GetComponent<Text>();
|
||||||
|
text.font = font;
|
||||||
|
text.fontSize = fontSize;
|
||||||
|
text.alignment = alignment;
|
||||||
|
text.color = color;
|
||||||
|
text.text = content;
|
||||||
|
text.raycastTarget = false;
|
||||||
|
var rect = text.rectTransform;
|
||||||
|
bool centered = alignment == TextAnchor.UpperCenter;
|
||||||
|
rect.anchorMin = rect.anchorMax = rect.pivot = new Vector2(centered ? 0.5f : 0f, 1f);
|
||||||
|
rect.anchoredPosition = position;
|
||||||
|
rect.sizeDelta = size;
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetGlow(float strength)
|
||||||
|
{
|
||||||
|
completionGlow.color = new Color(0.2f, 0.46f, 1f, strength * 0.9f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Sprite CreateRoundedSprite(float blur)
|
||||||
|
{
|
||||||
|
const int size = 64;
|
||||||
|
const float radius = 13f;
|
||||||
|
const float border = 30f;
|
||||||
|
var texture = new Texture2D(size, size, TextureFormat.RGBA32, false)
|
||||||
|
{
|
||||||
|
filterMode = FilterMode.Bilinear,
|
||||||
|
wrapMode = TextureWrapMode.Clamp
|
||||||
|
};
|
||||||
|
var pixels = new Color32[size * size];
|
||||||
|
float inner = size * 0.5f - radius - blur;
|
||||||
|
for (int y = 0; y < size; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < size; x++)
|
||||||
|
{
|
||||||
|
var corner = new Vector2(
|
||||||
|
Mathf.Max(0f, Mathf.Abs(x + 0.5f - size * 0.5f) - inner),
|
||||||
|
Mathf.Max(0f, Mathf.Abs(y + 0.5f - size * 0.5f) - inner));
|
||||||
|
float distance = corner.magnitude - radius;
|
||||||
|
float alpha = blur > 0f ? 1f - Mathf.SmoothStep(0f, 1f, distance / blur)
|
||||||
|
: Mathf.Clamp01(0.5f - distance);
|
||||||
|
pixels[y * size + x] = new Color32(255, 255, 255, (byte)Mathf.RoundToInt(alpha * 255f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
texture.SetPixels32(pixels);
|
||||||
|
texture.Apply(false, true);
|
||||||
|
return Sprite.Create(texture, new Rect(0f, 0f, size, size), new Vector2(0.5f, 0.5f), 100f,
|
||||||
|
0, SpriteMeshType.FullRect, Vector4.one * border);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DestroySprite(Sprite sprite)
|
||||||
|
{
|
||||||
|
if (sprite == null)
|
||||||
|
return;
|
||||||
|
Destroy(sprite.texture);
|
||||||
|
Destroy(sprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
if (playButton != null)
|
||||||
|
playButton.onClick.RemoveListener(OnPlayPressed);
|
||||||
|
if (videoPlayer != null)
|
||||||
|
videoPlayer.Stop();
|
||||||
|
if (videoTexture != null)
|
||||||
|
{
|
||||||
|
videoTexture.Release();
|
||||||
|
Destroy(videoTexture);
|
||||||
|
}
|
||||||
|
DestroySprite(roundedSprite);
|
||||||
|
DestroySprite(glowSprite);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0b798ee6ac1542b49697423188f03029
|
||||||
@@ -115,12 +115,12 @@ public class MovingBelt : MonoBehaviour
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (MoveDelta >= 1)
|
if (MoveDelta >= 1 && (reversed ? MovingPartSegments : StaticPartSegments).Count > 1)
|
||||||
{
|
{
|
||||||
MoveForward(reversed);
|
MoveForward(reversed);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (MoveDelta < 0)
|
else if (MoveDelta < 0 && (reversed ? StaticPartSegments : MovingPartSegments).Count > 2)
|
||||||
{
|
{
|
||||||
MoveBackward(reversed);
|
MoveBackward(reversed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class FilteredSocketReel : MonoBehaviour
|
|||||||
{
|
{
|
||||||
args.interactableObject.transform.GetComponent<Collider>().enabled = false;
|
args.interactableObject.transform.GetComponent<Collider>().enabled = false;
|
||||||
MachineController.ReelInserted(SocketTagNumber);
|
MachineController.ReelInserted(SocketTagNumber);
|
||||||
args.interactableObject.transform.GetComponent<BabinaScript>().SwitchToRope(socketInteractor.interactionLayers, socketInteractor.attachTransform);
|
args.interactableObject.transform.GetComponent<BabinaScript>().SwitchToRope(socketInteractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnObjectRemoved(SelectExitEventArgs args)
|
private void OnObjectRemoved(SelectExitEventArgs args)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ MonoBehaviour:
|
|||||||
m_AdditionalLightsShadowResolutionTierHigh: 1024
|
m_AdditionalLightsShadowResolutionTierHigh: 1024
|
||||||
m_ReflectionProbeBlending: 0
|
m_ReflectionProbeBlending: 0
|
||||||
m_ReflectionProbeBoxProjection: 0
|
m_ReflectionProbeBoxProjection: 0
|
||||||
m_ReflectionProbeAtlas: 1
|
m_ReflectionProbeAtlas: 0
|
||||||
m_ShadowDistance: 2.5
|
m_ShadowDistance: 2.5
|
||||||
m_ShadowCascadeCount: 1
|
m_ShadowCascadeCount: 1
|
||||||
m_Cascade2Split: 0.095
|
m_Cascade2Split: 0.095
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ MonoBehaviour:
|
|||||||
m_RendererType: 1
|
m_RendererType: 1
|
||||||
m_RendererData: {fileID: 0}
|
m_RendererData: {fileID: 0}
|
||||||
m_RendererDataList:
|
m_RendererDataList:
|
||||||
- {fileID: 11400000, guid: 53a413327819a984d8ab1618c9e90a10, type: 2}
|
- {fileID: 11400000, guid: b4712bf26326e8a4286df35b4a6d2b19, type: 2}
|
||||||
m_DefaultRendererIndex: 0
|
m_DefaultRendererIndex: 0
|
||||||
m_RequireDepthTexture: 0
|
m_RequireDepthTexture: 0
|
||||||
m_RequireOpaqueTexture: 0
|
m_RequireOpaqueTexture: 0
|
||||||
m_OpaqueDownsampling: 1
|
m_OpaqueDownsampling: 1
|
||||||
m_SupportsTerrainHoles: 0
|
m_SupportsTerrainHoles: 0
|
||||||
m_SupportsHDR: 0
|
m_SupportsHDR: 1
|
||||||
m_HDRColorBufferPrecision: 0
|
m_HDRColorBufferPrecision: 0
|
||||||
m_MSAA: 4
|
m_MSAA: 8
|
||||||
m_RenderScale: 1
|
m_RenderScale: 1.2
|
||||||
m_UpscalingFilter: 0
|
m_UpscalingFilter: 0
|
||||||
m_FsrOverrideSharpness: 1
|
m_FsrOverrideSharpness: 1
|
||||||
m_FsrSharpness: 0.5
|
m_FsrSharpness: 0.5
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ MonoBehaviour:
|
|||||||
m_Name: Android Settings
|
m_Name: Android Settings
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_LoaderManagerInstance: {fileID: -7453719424655649568}
|
m_LoaderManagerInstance: {fileID: -7453719424655649568}
|
||||||
m_InitManagerOnStart: 1
|
m_InitManagerOnStart: 0
|
||||||
--- !u!114 &-7453719424655649568
|
--- !u!114 &-7453719424655649568
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -72,7 +72,7 @@ MonoBehaviour:
|
|||||||
m_Name: Standalone Settings
|
m_Name: Standalone Settings
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_LoaderManagerInstance: {fileID: 3428388118024481725}
|
m_LoaderManagerInstance: {fileID: 3428388118024481725}
|
||||||
m_InitManagerOnStart: 1
|
m_InitManagerOnStart: 0
|
||||||
--- !u!114 &-6299096328155188010
|
--- !u!114 &-6299096328155188010
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 690929a59dc7a42da9030305190d391f, type: 3}
|
m_Script: {fileID: 11500000, guid: 690929a59dc7a42da9030305190d391f, type: 3}
|
||||||
m_Name: XRDeviceSimulatorSettings
|
m_Name: XRDeviceSimulatorSettings
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_AutomaticallyInstantiateSimulatorPrefab: 1
|
m_AutomaticallyInstantiateSimulatorPrefab: 0
|
||||||
m_AutomaticallyInstantiateInEditorOnly: 1
|
m_AutomaticallyInstantiateInEditorOnly: 1
|
||||||
m_UseClassic: 0
|
m_UseClassic: 0
|
||||||
m_SimulatorPrefab: {fileID: 8135023674665499069, guid: 58d0a4ac86f2348deb02f3880c71378e, type: 3}
|
m_SimulatorPrefab: {fileID: 8135023674665499069, guid: 58d0a4ac86f2348deb02f3880c71378e, type: 3}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"com.coplaydev.unity-mcp": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main",
|
||||||
"com.unity.2d.sprite": "1.0.0",
|
"com.unity.2d.sprite": "1.0.0",
|
||||||
"com.unity.collab-proxy": "2.13.6",
|
"com.unity.collab-proxy": "2.13.6",
|
||||||
"com.unity.feature.development": "1.0.2",
|
"com.unity.feature.development": "1.0.2",
|
||||||
|
|||||||
@@ -7,6 +7,23 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
"com.coplaydev.unity-mcp": {
|
||||||
|
"version": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "git",
|
||||||
|
"dependencies": {
|
||||||
|
"com.unity.modules.animation": "1.0.0",
|
||||||
|
"com.unity.modules.imageconversion": "1.0.0",
|
||||||
|
"com.unity.modules.physics": "1.0.0",
|
||||||
|
"com.unity.modules.physics2d": "1.0.0",
|
||||||
|
"com.unity.modules.uielements": "1.0.0",
|
||||||
|
"com.unity.modules.screencapture": "1.0.0",
|
||||||
|
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||||
|
"com.unity.nuget.newtonsoft-json": "3.0.2",
|
||||||
|
"com.unity.test-framework": "1.1.31"
|
||||||
|
},
|
||||||
|
"hash": "81542a7e86292b5c4c21b1782c5af23b567f45ce"
|
||||||
|
},
|
||||||
"com.unity.2d.sprite": {
|
"com.unity.2d.sprite": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
@@ -135,6 +152,13 @@
|
|||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
"com.unity.nuget.newtonsoft-json": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"depth": 1,
|
||||||
|
"source": "registry",
|
||||||
|
"dependencies": {},
|
||||||
|
"url": "https://packages.unity.com"
|
||||||
|
},
|
||||||
"com.unity.performance.profile-analyzer": {
|
"com.unity.performance.profile-analyzer": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ QualitySettings:
|
|||||||
globalTextureMipmapLimit: 0
|
globalTextureMipmapLimit: 0
|
||||||
textureMipmapLimitSettings: []
|
textureMipmapLimitSettings: []
|
||||||
anisotropicTextures: 1
|
anisotropicTextures: 1
|
||||||
antiAliasing: 4
|
antiAliasing: 8
|
||||||
softParticles: 1
|
softParticles: 1
|
||||||
softVegetation: 1
|
softVegetation: 1
|
||||||
realtimeReflectionProbes: 1
|
realtimeReflectionProbes: 1
|
||||||
|
|||||||
Reference in new issue
Block a user