Merge branch 'nothingTVatYT-load-additional-scene'
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.Windows;
|
||||
using FlaxEngine;
|
||||
|
||||
@@ -68,5 +69,15 @@ namespace FlaxEditor.Content
|
||||
{
|
||||
return new SceneItem(path, id);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnContentWindowContextMenu(ContextMenu menu, ContentItem item)
|
||||
{
|
||||
var id = ((SceneItem)item).ID;
|
||||
if (Level.FindScene(id) == null)
|
||||
{
|
||||
menu.AddButton("Open (additive)", () => { Editor.Instance.Scene.OpenScene(id, true); });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.SceneGraph;
|
||||
using FlaxEngine;
|
||||
@@ -146,6 +148,31 @@ namespace FlaxEditor.Windows
|
||||
contextMenu.AddButton("Break Prefab Link", Editor.Prefabs.BreakLinks);
|
||||
}
|
||||
|
||||
// Load additional scenes option
|
||||
|
||||
if (!hasSthSelected)
|
||||
{
|
||||
var allScenes = FlaxEngine.Content.GetAllAssetsByType(typeof(SceneAsset));
|
||||
var loadedSceneIds = Editor.Instance.Scene.Root.ChildNodes.Select(node => node.ID).ToList();
|
||||
var unloadedScenes = allScenes.Where(sceneId => !loadedSceneIds.Contains(sceneId)).ToList();
|
||||
if (unloadedScenes.Count > 0)
|
||||
{
|
||||
contextMenu.AddSeparator();
|
||||
var childCM = contextMenu.GetOrAddChildMenu("Open Scene");
|
||||
foreach (var sceneGuid in unloadedScenes)
|
||||
{
|
||||
if (FlaxEngine.Content.GetAssetInfo(sceneGuid, out var unloadedScene))
|
||||
{
|
||||
var splitPath = unloadedScene.Path.Split('/');
|
||||
var sceneName = splitPath[^1];
|
||||
if (splitPath[^1].EndsWith(".scene"))
|
||||
sceneName = sceneName[..^6];
|
||||
childCM.ContextMenu.AddButton(sceneName, () => { Editor.Instance.Scene.OpenScene(sceneGuid, true); });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spawning actors options
|
||||
|
||||
contextMenu.AddSeparator();
|
||||
|
||||
@@ -439,7 +439,7 @@ public:
|
||||
|
||||
bool Do() const override
|
||||
{
|
||||
auto scene = Scripting::FindObject<Scene>(TargetScene);
|
||||
auto scene = Level::FindScene(TargetScene);
|
||||
if (!scene)
|
||||
return true;
|
||||
return unloadScene(scene);
|
||||
|
||||
Reference in New Issue
Block a user