Fix custom actor options for prefab window

This commit is contained in:
Wojtek Figat
2021-10-25 23:23:07 +02:00
parent b9e29520cf
commit 07a6e50d14
3 changed files with 20 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ namespace FlaxEditor.SceneGraph
CustomNodesTypes.Add(typeof(SkyLight), typeof(SkyLightNode));
CustomNodesTypes.Add(typeof(PostFxVolume), typeof(PostFxVolumeNode));
CustomNodesTypes.Add(typeof(StaticModel), typeof(StaticModelNode));
CustomNodesTypes.Add(typeof(AnimatedModel), typeof(AnimatedModelNode));
CustomNodesTypes.Add(typeof(BoxBrush), typeof(BoxBrushNode));
CustomNodesTypes.Add(typeof(TextRender), typeof(TextRenderNode));
CustomNodesTypes.Add(typeof(AudioListener), typeof(AudioListenerNode));

View File

@@ -143,7 +143,23 @@ namespace FlaxEditor.Windows.Assets
}
// Custom options
bool showCustomNodeOptions = Editor.SceneEditing.Selection.Count == 1;
if (!showCustomNodeOptions && Editor.SceneEditing.Selection.Count != 0)
{
showCustomNodeOptions = true;
for (int i = 1; i < Editor.SceneEditing.Selection.Count; i++)
{
if (Editor.SceneEditing.Selection[0].GetType() != Editor.SceneEditing.Selection[i].GetType())
{
showCustomNodeOptions = false;
break;
}
}
}
if (showCustomNodeOptions)
{
Editor.SceneEditing.Selection[0].OnContextMenu(contextMenu);
}
ContextMenuShow?.Invoke(contextMenu);
return contextMenu;

View File

@@ -57,7 +57,7 @@ namespace FlaxEditor.Windows
b = contextMenu.AddButton("Duplicate", Editor.SceneEditing.Duplicate);
b.Enabled = hasSthSelected;
if (Editor.SceneEditing.SelectionCount == 1)
if (isSingleActorSelected)
{
var convertMenu = contextMenu.AddChildMenu("Convert");
var convertActorCm = convertMenu.ContextMenu;
@@ -100,7 +100,7 @@ namespace FlaxEditor.Windows
b = contextMenu.AddButton("Create Prefab", Editor.Prefabs.CreatePrefab);
b.Enabled = isSingleActorSelected &&
(Editor.SceneEditing.Selection[0] as ActorNode).CanCreatePrefab &&
((ActorNode)Editor.SceneEditing.Selection[0]).CanCreatePrefab &&
Editor.Windows.ContentWin.CurrentViewFolder.CanHaveAssets;
bool hasPrefabLink = canEditScene && isSingleActorSelected && (Editor.SceneEditing.Selection[0] as ActorNode).HasPrefabLink;