diff --git a/Source/Editor/Modules/SceneEditingModule.cs b/Source/Editor/Modules/SceneEditingModule.cs
index e1db17eaf..68d327574 100644
--- a/Source/Editor/Modules/SceneEditingModule.cs
+++ b/Source/Editor/Modules/SceneEditingModule.cs
@@ -430,6 +430,7 @@ namespace FlaxEditor.Modules
var actorNode = Editor.Instance.Scene.GetActorNode(actor);
if (actorNode == null)
throw new InvalidOperationException("Failed to create scene node for the spawned actor.");
+ actorNode.PostConvert(oldNode);
actorNode.PostSpawn();
Editor.Scene.MarkSceneEdited(actor.Scene);
diff --git a/Source/Editor/SceneGraph/ActorNode.cs b/Source/Editor/SceneGraph/ActorNode.cs
index 6703c30a0..6019386d4 100644
--- a/Source/Editor/SceneGraph/ActorNode.cs
+++ b/Source/Editor/SceneGraph/ActorNode.cs
@@ -295,6 +295,14 @@ namespace FlaxEditor.SceneGraph
{
}
+ ///
+ /// Action called after converting actor in editor.
+ ///
+ /// The source actor node from which this node was converted.
+ public virtual void PostConvert(ActorNode source)
+ {
+ }
+
///
protected override void OnParentChanged()
{
diff --git a/Source/Editor/SceneGraph/Actors/JointNode.cs b/Source/Editor/SceneGraph/Actors/JointNode.cs
new file mode 100644
index 000000000..d637ea105
--- /dev/null
+++ b/Source/Editor/SceneGraph/Actors/JointNode.cs
@@ -0,0 +1,35 @@
+// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
+
+using FlaxEngine;
+
+namespace FlaxEditor.SceneGraph.Actors
+{
+ ///
+ /// Scene tree node for actor type.
+ ///
+ [HideInEditor]
+ public sealed class JointNode : ActorNode
+ {
+ ///
+ public JointNode(Actor actor)
+ : base(actor)
+ {
+ }
+
+ ///
+ public override void PostConvert(ActorNode source)
+ {
+ base.PostConvert(source);
+
+ if (source.Actor is Joint other)
+ {
+ // Preserve basic properties when changing joint type
+ var joint = (Joint)Actor;
+ joint.Target = other.Target;
+ joint.TargetAnchor = other.TargetAnchor;
+ joint.TargetAnchorRotation = other.TargetAnchorRotation;
+ joint.EnableCollision = other.EnableCollision;
+ }
+ }
+ }
+}
diff --git a/Source/Editor/SceneGraph/SceneGraphFactory.cs b/Source/Editor/SceneGraph/SceneGraphFactory.cs
index 4789af57e..94cc3ac6b 100644
--- a/Source/Editor/SceneGraph/SceneGraphFactory.cs
+++ b/Source/Editor/SceneGraph/SceneGraphFactory.cs
@@ -72,6 +72,7 @@ namespace FlaxEditor.SceneGraph
CustomNodesTypes.Add(typeof(SplineRopeBody), typeof(ActorNode));
CustomNodesTypes.Add(typeof(NavMesh), typeof(ActorNode));
CustomNodesTypes.Add(typeof(SpriteRender), typeof(SpriteRenderNode));
+ CustomNodesTypes.Add(typeof(Joint), typeof(JointNode));
}
///