Add backbone for card creation and implement Camera minigame mechanics
This commit is contained in:
39
Assets/Scripts/UI/Utils/MaxHeightScaler.cs
Normal file
39
Assets/Scripts/UI/Utils/MaxHeightScaler.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI.Utils
|
||||
{
|
||||
[ExecuteAlways] // ✅ Runs in Edit Mode too
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
public class MaxHeightScaler : MonoBehaviour
|
||||
{
|
||||
public float maxHeight = 400f;
|
||||
public bool maintainAspectInEditor = true;
|
||||
|
||||
private RectTransform rect;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
rect = GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (rect == null) return;
|
||||
|
||||
// Get current screen or parent height
|
||||
float availableHeight = Screen.height;
|
||||
float targetHeight = Mathf.Min(availableHeight, maxHeight);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
// In Editor Mode, use parent height so UI previews nicely in Canvas
|
||||
if (!Application.isPlaying && rect.parent is RectTransform parent)
|
||||
{
|
||||
float parentHeight = parent.rect.height;
|
||||
targetHeight = Mathf.Min(parentHeight, maxHeight);
|
||||
}
|
||||
#endif
|
||||
|
||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, targetHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Utils/MaxHeightScaler.cs.meta
Normal file
2
Assets/Scripts/UI/Utils/MaxHeightScaler.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d2badd0f003c954487f5783c481102a
|
||||
Reference in New Issue
Block a user