1
This commit is contained in:
22
Unity/Extensions/UGUI/UGUIAncher.cs
Normal file
22
Unity/Extensions/UGUI/UGUIAncher.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class UGUIAncher : MonoBehaviour
|
||||
{
|
||||
public UXElement element;
|
||||
public RectTransform rect;
|
||||
void FixedUpdate()
|
||||
{
|
||||
var ve = element.GetVisualElement();
|
||||
var pos = ve.worldTransform.GetPosition();
|
||||
var size = ve.layout.size;
|
||||
if (size.x is not float.NaN)
|
||||
rect.sizeDelta = size;
|
||||
if (pos.x is not float.NaN)
|
||||
rect.anchoredPosition = new(pos.x, -pos.y);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user