Added UI to Furnance, fixed carry and drag obj and added fish
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public static class LocalPlayerCameraRegistry
|
||||
{
|
||||
public static Camera Current { get; private set; }
|
||||
|
||||
public static event Action<Camera> Changed;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void ResetState()
|
||||
{
|
||||
Current = null;
|
||||
Changed = null;
|
||||
}
|
||||
|
||||
public static void Register(Camera camera)
|
||||
{
|
||||
if (camera == null || Current == camera)
|
||||
return;
|
||||
|
||||
Current = camera;
|
||||
Changed?.Invoke(Current);
|
||||
}
|
||||
|
||||
public static void Unregister(Camera camera)
|
||||
{
|
||||
if (Current != camera)
|
||||
return;
|
||||
|
||||
Current = null;
|
||||
Changed?.Invoke(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e3d71c247514be98407f39adb750371
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(Canvas))]
|
||||
public sealed class WorldSpaceCanvasCameraBinder : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Canvas targetCanvas;
|
||||
|
||||
public Canvas TargetCanvas => targetCanvas;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
targetCanvas = GetComponent<Canvas>();
|
||||
RefreshBinding();
|
||||
}
|
||||
|
||||
private void Awake() => ResolveCanvas();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
LocalPlayerCameraRegistry.Changed += HandleLocalCameraChanged;
|
||||
RefreshBinding();
|
||||
}
|
||||
|
||||
private void OnDisable() =>
|
||||
LocalPlayerCameraRegistry.Changed -= HandleLocalCameraChanged;
|
||||
|
||||
public void RefreshBinding()
|
||||
{
|
||||
ResolveCanvas();
|
||||
|
||||
if (targetCanvas == null || targetCanvas.renderMode != RenderMode.WorldSpace)
|
||||
return;
|
||||
|
||||
targetCanvas.worldCamera = LocalPlayerCameraRegistry.Current;
|
||||
}
|
||||
|
||||
private void ResolveCanvas()
|
||||
{
|
||||
if (targetCanvas == null)
|
||||
targetCanvas = GetComponent<Canvas>();
|
||||
}
|
||||
|
||||
private void HandleLocalCameraChanged(Camera localCamera)
|
||||
{
|
||||
if (targetCanvas != null && targetCanvas.renderMode == RenderMode.WorldSpace)
|
||||
targetCanvas.worldCamera = localCamera;
|
||||
}
|
||||
|
||||
[ContextMenu("Refresh Local Player Camera")]
|
||||
private void RefreshFromContextMenu() => RefreshBinding();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 271d68bfa3ee4606a3ca57fa19150a49
|
||||
Reference in New Issue
Block a user