Add EditorScene for using gameplay logic in editor preview windows
This commit is contained in:
23
Source/Editor/Utilities/EditorScene.cpp
Normal file
23
Source/Editor/Utilities/EditorScene.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "EditorScene.h"
|
||||
|
||||
EditorScene::EditorScene(const SpawnParams& params)
|
||||
: Scene(params)
|
||||
{
|
||||
// Mock editor preview scene to be in gameplay
|
||||
EditorScene::PostSpawn();
|
||||
SceneBeginData beginData;
|
||||
EditorScene::BeginPlay(&beginData);
|
||||
beginData.OnDone();
|
||||
}
|
||||
|
||||
void EditorScene::Update()
|
||||
{
|
||||
for (auto& e : Ticking.Update.Ticks)
|
||||
e.Call();
|
||||
for (auto& e : Ticking.LateUpdate.Ticks)
|
||||
e.Call();
|
||||
for (auto& e : Ticking.FixedUpdate.Ticks)
|
||||
e.Call();
|
||||
}
|
||||
19
Source/Editor/Utilities/EditorScene.h
Normal file
19
Source/Editor/Utilities/EditorScene.h
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Level/Scene/Scene.h"
|
||||
|
||||
/// <summary>
|
||||
/// Scene for editor previews with support of object drawing and updating in separation of global scenes collection. It mocks the gameplay to preview scene objects.
|
||||
/// </summary>
|
||||
API_CLASS() class EditorScene final : public Scene
|
||||
{
|
||||
DECLARE_SCENE_OBJECT(EditorScene);
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// Updates the gameplay.
|
||||
/// </summary>
|
||||
API_FUNCTION() void Update();
|
||||
};
|
||||
@@ -198,7 +198,7 @@ void Actor::SetParent(Actor* value, bool worldPositionsStays, bool canBreakPrefa
|
||||
// Check if value won't change
|
||||
if (_parent == value)
|
||||
return;
|
||||
if (!IsInMainThread())
|
||||
if (IsDuringPlay() && !IsInMainThread())
|
||||
{
|
||||
LOG(Error, "Editing scene hierarchy is only allowed on a main thread.");
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
public sealed partial class Scene
|
||||
partial class Scene
|
||||
{
|
||||
/// <summary>
|
||||
/// The scene asset typename. Type of the serialized scene asset data. Hidden class for the scene assets. Actors deserialization rules are strictly controlled under the hood by the C++ core parts. Mostly because scene asset has the same ID as scene root actor so loading both managed objects for scene asset and scene will crash (due to object ids conflict).
|
||||
|
||||
@@ -19,7 +19,7 @@ class NavMesh;
|
||||
/// <summary>
|
||||
/// The scene root object that contains a hierarchy of actors.
|
||||
/// </summary>
|
||||
API_CLASS() class FLAXENGINE_API Scene final : public Actor
|
||||
API_CLASS() class FLAXENGINE_API Scene : public Actor
|
||||
{
|
||||
DECLARE_SCENE_OBJECT(Scene);
|
||||
friend Level;
|
||||
|
||||
Reference in New Issue
Block a user