Use the BoxColliderNode class for handling actor spawn events.
This commit is contained in:
@@ -534,8 +534,6 @@ namespace FlaxEditor.Modules
|
|||||||
{
|
{
|
||||||
node.ParentNode = parentNode;
|
node.ParentNode = parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
actor.OnActorSpawned();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnActorDeleted(Actor actor)
|
private void OnActorDeleted(Actor actor)
|
||||||
|
|||||||
@@ -8,8 +8,33 @@ using Real = System.Single;
|
|||||||
|
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
|
|
||||||
|
#if FLAX_EDITOR
|
||||||
|
using FlaxEditor.CustomEditors.Dedicated;
|
||||||
|
using FlaxEditor.CustomEditors;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace FlaxEditor.SceneGraph.Actors
|
namespace FlaxEditor.SceneGraph.Actors
|
||||||
{
|
{
|
||||||
|
#if FLAX_EDITOR
|
||||||
|
/// <summary>
|
||||||
|
/// Dedicated custom editor for BoxCollider objects.
|
||||||
|
/// </summary>
|
||||||
|
[CustomEditor(typeof(BoxCollider)), DefaultEditor]
|
||||||
|
public class BoxColliderEditor : ActorEditor
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void Initialize(LayoutElementsContainer layout)
|
||||||
|
{
|
||||||
|
base.Initialize(layout);
|
||||||
|
layout.Space(20f);
|
||||||
|
var autoResizeButton = layout.Button("Resize to Fit", "Resize the box collider to fit it's parent's bounds.");
|
||||||
|
|
||||||
|
BoxCollider collider = Values[0] as BoxCollider;
|
||||||
|
autoResizeButton.Button.Clicked += collider.AutoResize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Scene tree node for <see cref="BoxCollider"/> actor type.
|
/// Scene tree node for <see cref="BoxCollider"/> actor type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -37,5 +62,13 @@ namespace FlaxEditor.SceneGraph.Actors
|
|||||||
|
|
||||||
return base.RayCastSelf(ref ray, out distance, out normal);
|
return base.RayCastSelf(ref ray, out distance, out normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void PostSpawn()
|
||||||
|
{
|
||||||
|
base.PostSpawn();
|
||||||
|
BoxCollider boxCollider = Actor as BoxCollider;
|
||||||
|
boxCollider.AutoResize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,15 +116,6 @@ namespace FlaxEngine
|
|||||||
LocalTransform = Transform.Identity;
|
LocalTransform = Transform.Identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called in-editor when an actor is added to the scene.
|
|
||||||
/// If not in the editor, this function will not be called.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnActorSpawned()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new child actor of the given type.
|
/// Creates a new child actor of the given type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -5,26 +5,6 @@ using FlaxEditor.CustomEditors.Dedicated;
|
|||||||
|
|
||||||
namespace FlaxEngine
|
namespace FlaxEngine
|
||||||
{
|
{
|
||||||
#if FLAX_EDITOR
|
|
||||||
/// <summary>
|
|
||||||
/// Dedicated custom editor for BoxCollider objects.
|
|
||||||
/// </summary>
|
|
||||||
[CustomEditor(typeof(BoxCollider)), DefaultEditor]
|
|
||||||
public class BoxColliderEditor : ActorEditor
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override void Initialize(LayoutElementsContainer layout)
|
|
||||||
{
|
|
||||||
base.Initialize(layout);
|
|
||||||
layout.Space(20f);
|
|
||||||
var autoResizeButton = layout.Button("Resize to Fit", "Resize the box collider to fit it's parent's bounds.");
|
|
||||||
|
|
||||||
BoxCollider collider = Values[0] as BoxCollider;
|
|
||||||
autoResizeButton.Button.Clicked += collider.AutoResize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
partial class BoxCollider
|
partial class BoxCollider
|
||||||
{
|
{
|
||||||
private void BoxExcluding(Actor target, ref BoundingBox output, Actor excluded)
|
private void BoxExcluding(Actor target, ref BoundingBox output, Actor excluded)
|
||||||
@@ -72,12 +52,5 @@ namespace FlaxEngine
|
|||||||
// Undo Rotation
|
// Undo Rotation
|
||||||
Orientation *= Quaternion.Invert(Orientation);
|
Orientation *= Quaternion.Invert(Orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override void OnActorSpawned()
|
|
||||||
{
|
|
||||||
base.OnActorSpawned();
|
|
||||||
AutoResize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user