@@ -18,6 +18,7 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
private readonly CustomEditorPresenter _presenter;
|
private readonly CustomEditorPresenter _presenter;
|
||||||
private readonly ToolStripButton _saveButton;
|
private readonly ToolStripButton _saveButton;
|
||||||
private object _object;
|
private object _object;
|
||||||
|
private bool _isRegisteredForScriptsReload;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public JsonAssetWindow(Editor editor, AssetItem item)
|
public JsonAssetWindow(Editor editor, AssetItem item)
|
||||||
@@ -43,7 +44,6 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
private void OnScriptsReloadBegin()
|
private void OnScriptsReloadBegin()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -83,8 +83,11 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
ClearEditedFlag();
|
ClearEditedFlag();
|
||||||
|
|
||||||
// Auto-close on scripting reload if json asset is from game scripts (it might be reloaded)
|
// Auto-close on scripting reload if json asset is from game scripts (it might be reloaded)
|
||||||
if (_object != null && FlaxEngine.Scripting.IsTypeFromGameScripts(_object.GetType()))
|
if (_object != null && FlaxEngine.Scripting.IsTypeFromGameScripts(_object.GetType()) && !_isRegisteredForScriptsReload)
|
||||||
|
{
|
||||||
|
_isRegisteredForScriptsReload = true;
|
||||||
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
||||||
|
}
|
||||||
|
|
||||||
base.OnAssetLoaded();
|
base.OnAssetLoaded();
|
||||||
}
|
}
|
||||||
@@ -98,5 +101,17 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
|
|
||||||
base.OnItemReimported(item);
|
base.OnItemReimported(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnDestroy()
|
||||||
|
{
|
||||||
|
if (_isRegisteredForScriptsReload)
|
||||||
|
{
|
||||||
|
_isRegisteredForScriptsReload = false;
|
||||||
|
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnDestroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,14 +496,8 @@ public:
|
|||||||
// - load scenes (from temporary files)
|
// - load scenes (from temporary files)
|
||||||
// Note: we don't want to override original scene files
|
// Note: we don't want to override original scene files
|
||||||
|
|
||||||
// If no scene loaded just reload scripting
|
LOG(Info, "Scripts reloading start");
|
||||||
if (!Level::IsAnySceneLoaded())
|
const auto startTime = DateTime::NowUTC();
|
||||||
{
|
|
||||||
// Reload scripting
|
|
||||||
LOG(Info, "No scenes loaded, performing fast scripts reload");
|
|
||||||
Scripting::Reload(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache data
|
// Cache data
|
||||||
struct SceneData
|
struct SceneData
|
||||||
@@ -538,8 +532,6 @@ public:
|
|||||||
scenes[i].Init(Level::Scenes[i]);
|
scenes[i].Init(Level::Scenes[i]);
|
||||||
|
|
||||||
// Fire event
|
// Fire event
|
||||||
LOG(Info, "Scripts reloading start");
|
|
||||||
const auto startTime = DateTime::NowUTC();
|
|
||||||
Level::ScriptsReloadStart();
|
Level::ScriptsReloadStart();
|
||||||
|
|
||||||
// Save scenes (to memory)
|
// Save scenes (to memory)
|
||||||
@@ -566,9 +558,10 @@ public:
|
|||||||
Scripting::Reload();
|
Scripting::Reload();
|
||||||
|
|
||||||
// Restore scenes (from memory)
|
// Restore scenes (from memory)
|
||||||
LOG(Info, "Loading temporary scenes");
|
|
||||||
for (int32 i = 0; i < scenesCount; i++)
|
for (int32 i = 0; i < scenesCount; i++)
|
||||||
{
|
{
|
||||||
|
LOG(Info, "Restoring scene {0}", scenes[i].Name);
|
||||||
|
|
||||||
// Parse json
|
// Parse json
|
||||||
const auto& sceneData = scenes[i].Data;
|
const auto& sceneData = scenes[i].Data;
|
||||||
ISerializable::SerializeDocument document;
|
ISerializable::SerializeDocument document;
|
||||||
@@ -590,8 +583,9 @@ public:
|
|||||||
scenes.Resize(0);
|
scenes.Resize(0);
|
||||||
|
|
||||||
// Initialize scenes (will link references and create managed objects using new assembly)
|
// Initialize scenes (will link references and create managed objects using new assembly)
|
||||||
LOG(Info, "Prepare scene objects");
|
if (Level::Scenes.HasItems())
|
||||||
{
|
{
|
||||||
|
LOG(Info, "Prepare scene objects");
|
||||||
SceneBeginData beginData;
|
SceneBeginData beginData;
|
||||||
for (int32 i = 0; i < Level::Scenes.Count(); i++)
|
for (int32 i = 0; i < Level::Scenes.Count(); i++)
|
||||||
{
|
{
|
||||||
@@ -601,8 +595,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fire event
|
// Fire event
|
||||||
const auto endTime = DateTime::NowUTC();
|
LOG(Info, "Scripts reloading end. Total time: {0}ms", static_cast<int32>((DateTime::NowUTC() - startTime).GetTotalMilliseconds()));
|
||||||
LOG(Info, "Scripts reloading end. Total time: {0}ms", static_cast<int32>((endTime - startTime).GetTotalMilliseconds()));
|
|
||||||
Level::ScriptsReloadEnd();
|
Level::ScriptsReloadEnd();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user