28 lines
724 B
C#
28 lines
724 B
C#
using Engine.Input;
|
|
using Engine.Scene.Component.BuiltIn;
|
|
using OpenTK.Mathematics;
|
|
|
|
namespace DoomDeathmatch.Component.UI;
|
|
|
|
public class UiContainerComponent : UiComponent
|
|
{
|
|
private readonly IInputHandler _inputHandler = Engine.Engine.Instance.InputHandler!;
|
|
|
|
public Camera? Camera { get; set; }
|
|
public Vector3 MousePosition { get; private set; }
|
|
|
|
public override void Update(double parDeltaTime)
|
|
{
|
|
base.Update(parDeltaTime);
|
|
|
|
if (Camera != null)
|
|
{
|
|
GameObject.Transform.Size.Xy = Camera.GameObject.Transform.Size.Xy;
|
|
MousePosition = Camera.ScreenToWorld(_inputHandler.MousePosition);
|
|
}
|
|
else if (Container != null)
|
|
{
|
|
MousePosition = Container.MousePosition;
|
|
}
|
|
}
|
|
} |