57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
|
|
|
#if USE_LARGE_WORLDS
|
|
using Real = System.Double;
|
|
#else
|
|
using Real = System.Single;
|
|
#endif
|
|
|
|
using FlaxEngine;
|
|
|
|
namespace FlaxEditor.SceneGraph.Actors
|
|
{
|
|
/// <summary>
|
|
/// Scene tree node for <see cref="UICanvas"/> actor type.
|
|
/// </summary>
|
|
/// <seealso cref="ActorNode" />
|
|
[HideInEditor]
|
|
public sealed class UICanvasNode : ActorNode
|
|
{
|
|
/// <inheritdoc />
|
|
public UICanvasNode(Actor actor)
|
|
: base(actor)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void PostSpawn()
|
|
{
|
|
base.PostSpawn();
|
|
|
|
// Rotate to match the space (GUI uses upper left corner as a root)
|
|
Actor.LocalOrientation = Quaternion.Euler(0, -180, -180);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override bool RayCastSelf(ref RayCastData ray, out Real distance, out Vector3 normal)
|
|
{
|
|
normal = Vector3.Up;
|
|
|
|
if (Actor is UICanvas uiCanvas && uiCanvas.Is3D)
|
|
return uiCanvas.Bounds.Intersects(ref ray.Ray, out distance);
|
|
|
|
distance = 0;
|
|
return false;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void OnDebugDraw(ViewportDebugDrawData data)
|
|
{
|
|
base.OnDebugDraw(data);
|
|
|
|
if (Actor is UICanvas uiCanvas && uiCanvas.Is3D)
|
|
DebugDraw.DrawWireBox(uiCanvas.Bounds, Color.BlueViolet);
|
|
}
|
|
}
|
|
}
|