This commit is contained in:
Alex38Lyon
2025-06-03 12:00:47 +02:00
parent ed8041abcd
commit 878ea46cac
1300 changed files with 527178 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
using UnityEngine;
namespace Unity.FPS.UI
{
// The component that is used to display the Objectives, the Notification and the game messages like a list
// When a new one is created, the previous ones move down to make room for the new one
public class UITable : MonoBehaviour
{
[Tooltip("How much space should there be between items?")]
public float Offset;
[Tooltip("Add new the new items below existing items.")]
public bool Down;
public void UpdateTable(GameObject newItem)
{
if (newItem != null)
newItem.GetComponent<RectTransform>().localScale = Vector3.one;
float height = 0;
for (int i = 0; i < transform.childCount; i++)
{
RectTransform child = transform.GetChild(i).GetComponent<RectTransform>();
Vector2 size = child.sizeDelta;
height += Down ? -(1 - child.pivot.y) * size.y : (1 - child.pivot.y) * size.y;
if (i != 0)
height += Down ? -Offset : Offset;
Vector2 newPos = Vector2.zero;
newPos.y = height;
newPos.x = 0;//-child.pivot.x * size.x * hi.localScale.x;
child.anchoredPosition = newPos;
}
}
}
}