Fix errors

This commit is contained in:
Chandler Cox
2024-11-21 20:52:34 -06:00
parent 27044da099
commit 7330101206

View File

@@ -52,12 +52,13 @@ namespace FlaxEditor.Windows
contextMenu.AddSeparator();
// Basic editing options
var firstSelection = (ActorNode)Editor.SceneEditing.Selection[0];
var firstSelection = hasSthSelected ? Editor.SceneEditing.Selection[0] as ActorNode : null;
b = contextMenu.AddButton("Rename", inputOptions.Rename, Rename);
b.Enabled = hasSthSelected;
b = contextMenu.AddButton("Duplicate", inputOptions.Duplicate, Editor.SceneEditing.Duplicate);
b.Enabled = hasSthSelected && firstSelection.CanDuplicate;
b.Enabled = hasSthSelected && (firstSelection != null ? firstSelection.CanDuplicate : true);
if (isSingleActorSelected && firstSelection.Actor is not Scene)
if (isSingleActorSelected && firstSelection?.Actor is not Scene)
{
var convertMenu = contextMenu.AddChildMenu("Convert");
convertMenu.ContextMenu.AutoSort = true;
@@ -117,31 +118,31 @@ namespace FlaxEditor.Windows
}
}
b = contextMenu.AddButton("Delete", inputOptions.Delete, Editor.SceneEditing.Delete);
b.Enabled = hasSthSelected && firstSelection.CanDelete;
b.Enabled = hasSthSelected && (firstSelection != null ? firstSelection.CanDelete : true);
contextMenu.AddSeparator();
b = contextMenu.AddButton("Copy", inputOptions.Copy, Editor.SceneEditing.Copy);
b.Enabled = hasSthSelected && firstSelection.CanCopyPaste;
b.Enabled = hasSthSelected && (firstSelection != null ? firstSelection.CanCopyPaste : true);
contextMenu.AddButton("Paste", inputOptions.Paste, Editor.SceneEditing.Paste);
b = contextMenu.AddButton("Cut", inputOptions.Cut, Editor.SceneEditing.Cut);
b.Enabled = canEditScene && firstSelection.CanCopyPaste;
b.Enabled = canEditScene && hasSthSelected && (firstSelection != null ? firstSelection.CanCopyPaste : true);
// Create option
contextMenu.AddSeparator();
b = contextMenu.AddButton("Parent to new Actor", inputOptions.GroupSelectedActors, Editor.SceneEditing.CreateParentForSelectedActors);
b.Enabled = canEditScene && hasSthSelected && firstSelection.Actor is not Scene;
b.Enabled = canEditScene && hasSthSelected && firstSelection?.Actor is not Scene;
b = contextMenu.AddButton("Create Prefab", Editor.Prefabs.CreatePrefab);
b.Enabled = isSingleActorSelected &&
firstSelection.CanCreatePrefab &&
(firstSelection != null ? firstSelection.CanCreatePrefab : false) &&
Editor.Windows.ContentWin.CurrentViewFolder.CanHaveAssets;
bool hasPrefabLink = canEditScene && isSingleActorSelected && firstSelection.HasPrefabLink;
bool hasPrefabLink = canEditScene && isSingleActorSelected && (firstSelection != null ? firstSelection.HasPrefabLink : false);
if (hasPrefabLink)
{
contextMenu.AddButton("Select Prefab", Editor.Prefabs.SelectPrefab);