Merge branch 'sc-editor-asset-redux' of https://github.com/aws-lumberyard-dev/o3de into cgalvan/SCSourceFilePicker
This commit is contained in:
@@ -48,7 +48,6 @@ namespace ScriptCanvasBuilder
|
||||
SharedHandlers HandleAssetTypes()
|
||||
{
|
||||
SharedHandlers handlers;
|
||||
// handlers.m_editorAssetHandler = RegisterHandler<ScriptCanvasEditor::ScriptCanvasAsset, ScriptCanvasEditor::ScriptCanvasAssetHandler>("scriptcanvas", false);
|
||||
handlers.m_subgraphInterfaceHandler = RegisterHandler<ScriptCanvas::SubgraphInterfaceAsset, ScriptCanvas::SubgraphInterfaceAssetHandler>("scriptcanvas_fn_compiled", true);
|
||||
handlers.m_runtimeAssetHandler = RegisterHandler<ScriptCanvas::RuntimeAsset, JobDependencyVerificationHandler>("scriptcanvas_compiled", true);
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace ScriptCanvasBuilder
|
||||
{
|
||||
void Worker::Activate(const AssetHandlers& handlers)
|
||||
{
|
||||
m_editorAssetHandler = handlers.m_editorAssetHandler;
|
||||
m_runtimeAssetHandler = handlers.m_runtimeAssetHandler;
|
||||
m_subgraphInterfaceHandler = handlers.m_subgraphInterfaceHandler;
|
||||
}
|
||||
@@ -255,49 +254,14 @@ namespace ScriptCanvasBuilder
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_editorAssetHandler)
|
||||
{
|
||||
AZ_Error(s_scriptCanvasBuilder, false, R"(Exporting of .scriptcanvas for "%s" file failed as no editor asset handler was registered for script canvas. The ScriptCanvas Gem might not be enabled.)", fullPath.data());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_runtimeAssetHandler)
|
||||
{
|
||||
AZ_Error(s_scriptCanvasBuilder, false, R"(Exporting of .scriptcanvas for "%s" file failed as no runtime asset handler was registered for script canvas.)", fullPath.data());
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::shared_ptr<AZ::Data::AssetDataStream> assetDataStream = AZStd::make_shared<AZ::Data::AssetDataStream>();
|
||||
|
||||
AZ::IO::FileIOStream stream(fullPath.c_str(), AZ::IO::OpenMode::ModeRead);
|
||||
if (!AZ::IO::RetryOpenStream(stream))
|
||||
{
|
||||
AZ_Warning(s_scriptCanvasBuilder, false, "CreateJobs for \"%s\" failed because the source file could not be opened.", fullPath.data());
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the asset into a memory buffer, then hand ownership of the buffer to assetDataStream
|
||||
{
|
||||
AZ::IO::FileIOStream ioStream;
|
||||
if (!ioStream.Open(fullPath.data(), AZ::IO::OpenMode::ModeRead))
|
||||
{
|
||||
AZ_Warning(s_scriptCanvasBuilder, false, "CreateJobs for \"%s\" failed because the source file could not be opened.", fullPath.data());
|
||||
return;
|
||||
}
|
||||
AZStd::vector<AZ::u8> fileBuffer(ioStream.GetLength());
|
||||
size_t bytesRead = ioStream.Read(fileBuffer.size(), fileBuffer.data());
|
||||
if (bytesRead != ioStream.GetLength())
|
||||
{
|
||||
AZ_Warning(s_scriptCanvasBuilder, false, AZStd::string::format("File failed to read completely: %s", fullPath.data()).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
assetDataStream->Open(AZStd::move(fileBuffer));
|
||||
}
|
||||
|
||||
AZ::Data::Asset<ScriptCanvasEditor::ScriptCanvasAsset> asset;
|
||||
asset.Create(request.m_sourceFileUUID);
|
||||
if (m_editorAssetHandler->LoadAssetDataFromStream(asset, assetDataStream, nullptr) != AZ::Data::AssetHandler::LoadResult::LoadComplete)
|
||||
auto loadOutcome = ScriptCanvasEditor::LoadFromFile(request.m_fullPath);
|
||||
if (!loadOutcome.IsSuccess())
|
||||
{
|
||||
AZ_Error(s_scriptCanvasBuilder, false, R"(Loading of ScriptCanvas asset for source file "%s" has failed)", fullPath.data());
|
||||
return;
|
||||
@@ -310,9 +274,11 @@ namespace ScriptCanvasBuilder
|
||||
AzFramework::StringFunc::Path::Join(request.m_tempDirPath.c_str(), fileNameOnly.c_str(), runtimeScriptCanvasOutputPath, true, true);
|
||||
AzFramework::StringFunc::Path::ReplaceExtension(runtimeScriptCanvasOutputPath, ScriptCanvas::RuntimeAsset::GetFileExtension());
|
||||
|
||||
auto sourceHandle = loadOutcome.TakeValue();
|
||||
|
||||
if (request.m_jobDescription.m_jobKey == s_scriptCanvasProcessJobKey)
|
||||
{
|
||||
AZ::Entity* buildEntity = asset.Get()->GetScriptCanvasEntity();
|
||||
AZ::Entity* buildEntity = sourceHandle.Get()->GetEntity();
|
||||
ProcessTranslationJobInput input;
|
||||
input.assetID = AZ::Data::AssetId(request.m_sourceFileUUID, AZ_CRC("RuntimeData", 0x163310ae));
|
||||
input.request = &request;
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace ScriptCanvasBuilder
|
||||
|
||||
ForceBuildForDevTest0,
|
||||
ForceBuildForDevTest1,
|
||||
ForceBuildForDevTest2,
|
||||
|
||||
// add new entries above
|
||||
Current,
|
||||
@@ -73,7 +74,6 @@ namespace ScriptCanvasBuilder
|
||||
|
||||
struct AssetHandlers
|
||||
{
|
||||
AZ::Data::AssetHandler* m_editorAssetHandler = nullptr;
|
||||
AZ::Data::AssetHandler* m_editorFunctionAssetHandler = nullptr;
|
||||
AZ::Data::AssetHandler* m_runtimeAssetHandler = nullptr;
|
||||
AZ::Data::AssetHandler* m_subgraphInterfaceHandler = nullptr;
|
||||
@@ -84,7 +84,6 @@ namespace ScriptCanvasBuilder
|
||||
|
||||
struct SharedHandlers
|
||||
{
|
||||
HandlerOwnership m_editorAssetHandler{};
|
||||
HandlerOwnership m_editorFunctionAssetHandler{};
|
||||
HandlerOwnership m_runtimeAssetHandler{};
|
||||
HandlerOwnership m_subgraphInterfaceHandler{};
|
||||
@@ -173,7 +172,6 @@ namespace ScriptCanvasBuilder
|
||||
void ShutDown() override {};
|
||||
|
||||
private:
|
||||
AZ::Data::AssetHandler* m_editorAssetHandler = nullptr;
|
||||
AZ::Data::AssetHandler* m_runtimeAssetHandler = nullptr;
|
||||
AZ::Data::AssetHandler* m_subgraphInterfaceHandler = nullptr;
|
||||
|
||||
|
||||
@@ -34,15 +34,13 @@
|
||||
namespace ScriptCanvasBuilder
|
||||
{
|
||||
AssetHandlers::AssetHandlers(SharedHandlers& source)
|
||||
: m_editorAssetHandler(source.m_editorAssetHandler.first)
|
||||
, m_editorFunctionAssetHandler(source.m_editorFunctionAssetHandler.first)
|
||||
: m_editorFunctionAssetHandler(source.m_editorFunctionAssetHandler.first)
|
||||
, m_runtimeAssetHandler(source.m_runtimeAssetHandler.first)
|
||||
, m_subgraphInterfaceHandler(source.m_subgraphInterfaceHandler.first)
|
||||
{}
|
||||
|
||||
void SharedHandlers::DeleteOwnedHandlers()
|
||||
{
|
||||
DeleteIfOwned(m_editorAssetHandler);
|
||||
DeleteIfOwned(m_editorFunctionAssetHandler);
|
||||
DeleteIfOwned(m_runtimeAssetHandler);
|
||||
DeleteIfOwned(m_subgraphInterfaceHandler);
|
||||
|
||||
@@ -26,18 +26,20 @@
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasAsset.h>
|
||||
#include <ScriptCanvas/Bus/RequestBus.h>
|
||||
#include <ScriptCanvas/Components/EditorGraph.h>
|
||||
#include <ScriptCanvas/Components/EditorUtils.h>
|
||||
#include <ScriptCanvas/Components/EditorGraphVariableManagerComponent.h>
|
||||
#include <ScriptCanvas/Components/EditorScriptCanvasComponent.h>
|
||||
#include <ScriptCanvas/Core/Node.h>
|
||||
#include <ScriptCanvas/PerformanceStatisticsBus.h>
|
||||
|
||||
#include <LyViewPaneNames.h>
|
||||
#include <ScriptCanvas/Assets/ScriptCanvasFileHandling.h>
|
||||
|
||||
namespace EditorScriptCanvasComponentCpp
|
||||
{
|
||||
enum Version
|
||||
{
|
||||
PrefabIntegration = 10,
|
||||
|
||||
AddSourceHandle,
|
||||
// add description above
|
||||
Current
|
||||
};
|
||||
@@ -142,6 +144,25 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
if (rootElement.GetVersion() < EditorScriptCanvasComponentCpp::Version::AddSourceHandle)
|
||||
{
|
||||
ScriptCanvasAssetHolder assetHolder;
|
||||
if (!rootElement.FindSubElementAndGetData(AZ_CRC_CE("m_assetHolder"), assetHolder))
|
||||
{
|
||||
AZ_Error("ScriptCanvas", false, "EditorScriptCanvasComponent conversion failed: could not retrieve old 'm_assetHolder'");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto assetId = assetHolder.GetAssetId();
|
||||
auto path = assetHolder.GetAssetHint();
|
||||
|
||||
if (!rootElement.AddElementWithData(serializeContext, "runtimeDataOverrides", SourceHandle(nullptr, assetId.m_guid, path)))
|
||||
{
|
||||
AZ_Error("ScriptCanvas", false, "EditorScriptCanvasComponent conversion failed: failed to add 'sourceHandle'");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -153,9 +174,9 @@ namespace ScriptCanvasEditor
|
||||
serializeContext->Class<EditorScriptCanvasComponent, EditorComponentBase>()
|
||||
->Version(EditorScriptCanvasComponentCpp::Version::Current, &EditorScriptCanvasComponentVersionConverter)
|
||||
->Field("m_name", &EditorScriptCanvasComponent::m_name)
|
||||
->Field("m_assetHolder", &EditorScriptCanvasComponent::m_scriptCanvasAssetHolder)
|
||||
->Field("runtimeDataIsValid", &EditorScriptCanvasComponent::m_runtimeDataIsValid)
|
||||
->Field("runtimeDataOverrides", &EditorScriptCanvasComponent::m_variableOverrides)
|
||||
->Field("sourceHandle", &EditorScriptCanvasComponent::m_sourceHandle)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
@@ -171,7 +192,7 @@ namespace ScriptCanvasEditor
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("UI", 0x27ff46b0))
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Level", 0x9aeacc13))
|
||||
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/scripting/script-canvas/")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorScriptCanvasComponent::m_scriptCanvasAssetHolder, "Script Canvas Asset", "Script Canvas asset associated with this component")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorScriptCanvasComponent::m_sourceHandle, "Script Canvas Source File", "Script Canvas source file associated with this component")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &EditorScriptCanvasComponent::m_variableOverrides, "Properties", "Script Canvas Graph Properties")
|
||||
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
|
||||
@@ -181,19 +202,13 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
|
||||
EditorScriptCanvasComponent::EditorScriptCanvasComponent()
|
||||
: EditorScriptCanvasComponent(AZ::Data::Asset<ScriptCanvasAsset>())
|
||||
: EditorScriptCanvasComponent(SourceHandle())
|
||||
{
|
||||
}
|
||||
|
||||
EditorScriptCanvasComponent::EditorScriptCanvasComponent(AZ::Data::Asset<ScriptCanvasAsset> asset)
|
||||
: m_scriptCanvasAssetHolder()
|
||||
EditorScriptCanvasComponent::EditorScriptCanvasComponent(const SourceHandle& sourceHandle)
|
||||
: m_sourceHandle(sourceHandle)
|
||||
{
|
||||
if (asset.GetId().IsValid())
|
||||
{
|
||||
m_scriptCanvasAssetHolder.SetAsset(asset.GetId());
|
||||
}
|
||||
|
||||
m_scriptCanvasAssetHolder.SetScriptChangedCB([this](AZ::Data::AssetId assetId) { OnScriptCanvasAssetChanged(assetId); });
|
||||
}
|
||||
|
||||
EditorScriptCanvasComponent::~EditorScriptCanvasComponent()
|
||||
@@ -209,42 +224,35 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void EditorScriptCanvasComponent::UpdateName()
|
||||
{
|
||||
AZ::Data::AssetId assetId = m_scriptCanvasAssetHolder.GetAssetId();
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
// Pathname from the asset doesn't seem to return a value unless the asset has been loaded up once(which isn't done until we try to show it).
|
||||
// Using the Job system to determine the asset name instead.
|
||||
AZ::Outcome<AzToolsFramework::AssetSystem::JobInfoContainer> jobOutcome = AZ::Failure();
|
||||
AzToolsFramework::AssetSystemJobRequestBus::BroadcastResult(jobOutcome, &AzToolsFramework::AssetSystemJobRequestBus::Events::GetAssetJobsInfoByAssetID, assetId, false, false);
|
||||
|
||||
AZStd::string assetPath;
|
||||
AZStd::string assetName;
|
||||
|
||||
if (jobOutcome.IsSuccess())
|
||||
{
|
||||
AzToolsFramework::AssetSystem::JobInfoContainer& jobs = jobOutcome.GetValue();
|
||||
|
||||
// Get the asset relative path
|
||||
if (!jobs.empty())
|
||||
{
|
||||
assetPath = jobs[0].m_sourceFile;
|
||||
}
|
||||
|
||||
// Get the asset file name
|
||||
assetName = assetPath;
|
||||
|
||||
if (!assetPath.empty())
|
||||
{
|
||||
AzFramework::StringFunc::Path::GetFileName(assetPath.c_str(), assetName);
|
||||
SetName(assetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
SetName(m_sourceHandle.Path().Filename().Native());
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::OpenEditor()
|
||||
{
|
||||
m_scriptCanvasAssetHolder.OpenEditor();
|
||||
AzToolsFramework::OpenViewPane(LyViewPane::ScriptCanvas);
|
||||
|
||||
AZ::Outcome<int, AZStd::string> openOutcome = AZ::Failure(AZStd::string());
|
||||
|
||||
if (m_sourceHandle.IsValid())
|
||||
{
|
||||
GeneralRequestBus::BroadcastResult(openOutcome, &GeneralRequests::OpenScriptCanvasAsset, m_sourceHandle, -1);
|
||||
|
||||
if (!openOutcome)
|
||||
{
|
||||
AZ_Warning("Script Canvas", openOutcome, "%s", openOutcome.GetError().data());
|
||||
}
|
||||
}
|
||||
else if (GetEntityId().IsValid())
|
||||
{
|
||||
AzToolsFramework::EntityIdList selectedEntityIds;
|
||||
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(selectedEntityIds, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
|
||||
|
||||
// Going to bypass the multiple selected entities flow for right now.
|
||||
if (selectedEntityIds.size() == 1)
|
||||
{
|
||||
GeneralRequestBus::Broadcast(&GeneralRequests::CreateScriptCanvasAssetFor, AZStd::make_pair(GetEntityId(), GetId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::Init()
|
||||
@@ -260,6 +268,8 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
EditorComponentBase::Activate();
|
||||
|
||||
AzToolsFramework::AssetSystemBus::Handler::BusConnect();
|
||||
|
||||
AZ::EntityId entityId = GetEntityId();
|
||||
|
||||
EditorContextMenuRequestBus::Handler::BusConnect(entityId);
|
||||
@@ -268,19 +278,13 @@ namespace ScriptCanvasEditor
|
||||
EditorScriptCanvasComponentLoggingBus::Handler::BusConnect(entityId);
|
||||
EditorLoggingComponentNotificationBus::Broadcast(&EditorLoggingComponentNotifications::OnEditorScriptCanvasComponentActivated, GetNamedEntityId(), GetGraphIdentifier());
|
||||
|
||||
AZ::Data::AssetId fileAssetId = m_scriptCanvasAssetHolder.GetAssetId();
|
||||
|
||||
if (fileAssetId.IsValid())
|
||||
{
|
||||
AssetTrackerNotificationBus::Handler::BusConnect(fileAssetId);
|
||||
AzToolsFramework::ToolsApplicationNotificationBus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree_NewContent);
|
||||
}
|
||||
AzToolsFramework::ToolsApplicationNotificationBus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree_NewContent);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
void EditorScriptCanvasComponent::Deactivate()
|
||||
{
|
||||
AssetTrackerNotificationBus::Handler::BusDisconnect();
|
||||
AzToolsFramework::AssetSystemBus::Handler::BusDisconnect();
|
||||
|
||||
EditorScriptCanvasComponentLoggingBus::Handler::BusDisconnect();
|
||||
EditorLoggingComponentNotificationBus::Broadcast(&EditorLoggingComponentNotifications::OnEditorScriptCanvasComponentDeactivated, GetNamedEntityId(), GetGraphIdentifier());
|
||||
@@ -297,7 +301,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
m_runtimeDataIsValid = false;
|
||||
|
||||
auto assetTreeOutcome = LoadEditorAssetTree(m_scriptCanvasAssetHolder.GetAssetId(), m_scriptCanvasAssetHolder.GetAssetHint());
|
||||
auto assetTreeOutcome = LoadEditorAssetTree(m_sourceHandle.Id(), m_sourceHandle.Path().c_str());
|
||||
if (!assetTreeOutcome.IsSuccess())
|
||||
{
|
||||
AZ_Warning("ScriptCanvas", false, "EditorScriptCanvasComponent::BuildGameEntityData failed: %s", assetTreeOutcome.GetError().c_str());
|
||||
@@ -335,7 +339,8 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (!m_runtimeDataIsValid)
|
||||
{
|
||||
AZ_Error("ScriptCanvasBuilder", false, "Runtime information did not build for ScriptCanvas Component using asset: %s", m_scriptCanvasAssetHolder.GetAssetId().ToString<AZStd::string>().c_str());
|
||||
AZ_Error("ScriptCanvasBuilder", false, "Runtime information did not build for ScriptCanvas Component using asset: %s"
|
||||
, m_sourceHandle.ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -343,123 +348,53 @@ namespace ScriptCanvasEditor
|
||||
runtimeComponent->TakeRuntimeDataOverrides(ConvertToRuntime(m_variableOverrides));
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::OnCatalogAssetAdded(const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_removedCatalogId == assetId)
|
||||
{
|
||||
if (!m_scriptCanvasAssetHolder.GetAssetId().IsValid())
|
||||
{
|
||||
SetPrimaryAsset(assetId);
|
||||
m_removedCatalogId.SetInvalid();
|
||||
}
|
||||
}
|
||||
}
|
||||
void EditorScriptCanvasComponent::OnCatalogAssetRemoved(const AZ::Data::AssetId& removedAssetId, const AZ::Data::AssetInfo& /*assetInfo*/)
|
||||
{
|
||||
AZ::Data::AssetId assetId = m_scriptCanvasAssetHolder.GetAssetId();
|
||||
if (assetId == removedAssetId)
|
||||
{
|
||||
m_removedCatalogId = assetId;
|
||||
SetPrimaryAsset({});
|
||||
}
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::SetPrimaryAsset(const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
m_scriptCanvasAssetHolder.ClearAsset();
|
||||
m_sourceHandle = SourceHandle(nullptr, assetId.m_guid, {});
|
||||
|
||||
if (assetId.IsValid())
|
||||
auto completeAsset = CompleteDescription(m_sourceHandle);
|
||||
if (completeAsset)
|
||||
{
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
||||
|
||||
if (memoryAsset)
|
||||
{
|
||||
m_scriptCanvasAssetHolder.SetAsset(memoryAsset->GetFileAssetId());
|
||||
OnScriptCanvasAssetChanged(memoryAsset->GetFileAssetId());
|
||||
SetName(memoryAsset->GetTabName());
|
||||
}
|
||||
else
|
||||
{
|
||||
auto scriptCanvasAsset = AZ::Data::AssetManager::Instance().FindAsset(assetId, AZ::Data::AssetLoadBehavior::Default);
|
||||
if (scriptCanvasAsset)
|
||||
{
|
||||
m_scriptCanvasAssetHolder.SetAsset(assetId);
|
||||
}
|
||||
}
|
||||
m_sourceHandle = *completeAsset;
|
||||
}
|
||||
|
||||
OnScriptCanvasAssetChanged(m_sourceHandle);
|
||||
SetName(m_sourceHandle.Path().Filename().Native());
|
||||
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_AttributesAndValues);
|
||||
}
|
||||
|
||||
AZ::Data::AssetId EditorScriptCanvasComponent::GetAssetId() const
|
||||
{
|
||||
return m_scriptCanvasAssetHolder.GetAssetId();
|
||||
return m_sourceHandle.Id();
|
||||
}
|
||||
|
||||
AZ::EntityId EditorScriptCanvasComponent::GetGraphEntityId() const
|
||||
void EditorScriptCanvasComponent::OnScriptCanvasAssetChanged(const SourceHandle& assetId)
|
||||
{
|
||||
AZ::EntityId scriptCanvasEntityId;
|
||||
AZ::Data::AssetId assetId = m_scriptCanvasAssetHolder.GetAssetId();
|
||||
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
AssetTrackerRequestBus::BroadcastResult(scriptCanvasEntityId, &AssetTrackerRequests::GetScriptCanvasId, assetId);
|
||||
}
|
||||
|
||||
return scriptCanvasEntityId;
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::OnAssetReady(const ScriptCanvasMemoryAsset::pointer asset)
|
||||
{
|
||||
OnScriptCanvasAssetReady(asset);
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::OnAssetSaved(const ScriptCanvasMemoryAsset::pointer asset, bool isSuccessful)
|
||||
{
|
||||
if (isSuccessful)
|
||||
{
|
||||
OnScriptCanvasAssetReady(asset);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::OnAssetReloaded(const ScriptCanvasMemoryAsset::pointer asset)
|
||||
{
|
||||
OnScriptCanvasAssetReady(asset);
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::OnScriptCanvasAssetChanged(AZ::Data::AssetId assetId)
|
||||
{
|
||||
AssetTrackerNotificationBus::Handler::BusDisconnect();
|
||||
ScriptCanvas::GraphIdentifier newIdentifier = GetGraphIdentifier();
|
||||
newIdentifier.m_assetId = assetId;
|
||||
newIdentifier.m_assetId = assetId.Id();
|
||||
|
||||
ScriptCanvas::GraphIdentifier oldIdentifier = GetGraphIdentifier();
|
||||
oldIdentifier.m_assetId = m_previousAssetId;
|
||||
oldIdentifier.m_assetId = m_previousHandle.Id();
|
||||
|
||||
EditorLoggingComponentNotificationBus::Broadcast(&EditorLoggingComponentNotifications::OnAssetSwitched, GetNamedEntityId(), newIdentifier, oldIdentifier);
|
||||
|
||||
m_previousAssetId = m_scriptCanvasAssetHolder.GetAssetId();
|
||||
m_previousHandle = m_sourceHandle.Describe();
|
||||
|
||||
// Only clear our variables when we are given a new asset id
|
||||
// or when the asset was explicitly set to empty.
|
||||
//
|
||||
// i.e. do not clear variables when we lose the catalog asset.
|
||||
if ((assetId.IsValid() && assetId != m_removedCatalogId)
|
||||
|| (!assetId.IsValid() && !m_removedCatalogId.IsValid()))
|
||||
if ((assetId.IsValidDescription() && assetId.Describe() != m_removedHandle.Describe())
|
||||
|| (!assetId.IsValidDescription() && !m_removedHandle.IsValidDescription()))
|
||||
{
|
||||
ClearVariables();
|
||||
}
|
||||
|
||||
if (assetId.IsValid())
|
||||
if (assetId.IsValidDescription())
|
||||
{
|
||||
AssetTrackerNotificationBus::Handler::BusConnect(assetId);
|
||||
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetId);
|
||||
if (memoryAsset && memoryAsset->GetAsset().GetStatus() == AZ::Data::AssetData::AssetStatus::Ready)
|
||||
if (auto loaded = LoadFromFile(assetId.Path().c_str()); loaded.IsSuccess())
|
||||
{
|
||||
OnScriptCanvasAssetReady(memoryAsset);
|
||||
OnScriptCanvasAssetReady(loaded.GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,39 +411,49 @@ namespace ScriptCanvasEditor
|
||||
AZ::ScriptSystemRequestBus::Broadcast(&AZ::ScriptSystemRequests::GarbageCollect);
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::SetAssetId(const AZ::Data::AssetId& assetId)
|
||||
void EditorScriptCanvasComponent::SetAssetId(const SourceHandle& assetId)
|
||||
{
|
||||
if (m_scriptCanvasAssetHolder.GetAssetId() != assetId)
|
||||
if (m_sourceHandle.Describe() != assetId.Describe())
|
||||
{
|
||||
// Invalidate the previously removed catalog id if we are setting a new asset id
|
||||
m_removedCatalogId.SetInvalid();
|
||||
SetPrimaryAsset(assetId);
|
||||
m_removedHandle = {};
|
||||
SetPrimaryAsset(assetId.Id());
|
||||
}
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::SourceFileChanged(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid /*fileAssetId*/)
|
||||
{}
|
||||
|
||||
void EditorScriptCanvasComponent::SourceFileRemoved(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid /*fileAssetId*/)
|
||||
{}
|
||||
|
||||
void EditorScriptCanvasComponent::SourceFileFailed(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid /*fileAssetId*/)
|
||||
{}
|
||||
|
||||
bool EditorScriptCanvasComponent::HasAssetId() const
|
||||
{
|
||||
return m_scriptCanvasAssetHolder.GetAssetId().IsValid();
|
||||
return !m_sourceHandle.Id().IsNull();
|
||||
}
|
||||
|
||||
ScriptCanvas::GraphIdentifier EditorScriptCanvasComponent::GetGraphIdentifier() const
|
||||
{
|
||||
// For now we don't want to deal with disambiguating duplicates of the same script running on one entity.
|
||||
// Should that change we need to add the component id back into this.
|
||||
return ScriptCanvas::GraphIdentifier(m_scriptCanvasAssetHolder.GetAssetId(), 0);
|
||||
return ScriptCanvas::GraphIdentifier(m_sourceHandle.Id(), 0);
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::OnScriptCanvasAssetReady(const ScriptCanvasMemoryAsset::pointer memoryAsset)
|
||||
void EditorScriptCanvasComponent::OnScriptCanvasAssetReady(const SourceHandle& sourceHandle)
|
||||
{
|
||||
if (memoryAsset->GetFileAssetId() == m_scriptCanvasAssetHolder.GetAssetId())
|
||||
if (sourceHandle.IsValid())
|
||||
{
|
||||
auto assetData = memoryAsset->GetAsset();
|
||||
[[maybe_unused]] AZ::Entity* scriptCanvasEntity = assetData->GetScriptCanvasEntity();
|
||||
AZ_Assert(scriptCanvasEntity, "This graph must have a valid entity");
|
||||
BuildGameEntityData();
|
||||
UpdateName();
|
||||
AzToolsFramework::ToolsApplicationNotificationBus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree_NewContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
// #sc_editor_asset clear or disable something
|
||||
}
|
||||
}
|
||||
|
||||
void EditorScriptCanvasComponent::ClearVariables()
|
||||
|
||||
@@ -17,6 +17,7 @@ AZ_POP_DISABLE_WARNING
|
||||
#include <ScriptCanvas/Libraries/Core/EBusEventHandler.h>
|
||||
#include <ScriptCanvas/Libraries/Core/ReceiveScriptEvent.h>
|
||||
#include <ScriptCanvas/Utils/NodeUtils.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
|
||||
#include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
|
||||
#include <Editor/Include/ScriptCanvas/GraphCanvas/NodeDescriptorBus.h>
|
||||
@@ -30,6 +31,44 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
AZStd::optional<SourceHandle> CompleteDescription(const SourceHandle& source)
|
||||
{
|
||||
if (source.IsValidDescription())
|
||||
{
|
||||
return source.Describe();
|
||||
}
|
||||
|
||||
AZStd::string watchFolder;
|
||||
AZ::Data::AssetInfo assetInfo;
|
||||
bool sourceInfoFound{};
|
||||
|
||||
if (!source.Id().IsNull())
|
||||
{
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult
|
||||
( sourceInfoFound
|
||||
, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourceUUID, source.Id(), assetInfo, watchFolder);
|
||||
|
||||
if (sourceInfoFound && !assetInfo.m_relativePath.empty())
|
||||
{
|
||||
return SourceHandle(nullptr, assetInfo.m_assetId.m_guid, assetInfo.m_relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!source.Path().empty())
|
||||
{
|
||||
AzToolsFramework::AssetSystemRequestBus::BroadcastResult
|
||||
( sourceInfoFound
|
||||
, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, source.Path().c_str(), assetInfo, watchFolder);
|
||||
|
||||
if (sourceInfoFound && assetInfo.m_assetId.IsValid())
|
||||
{
|
||||
return SourceHandle(nullptr, assetInfo.m_assetId.m_guid, assetInfo.m_relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
return AZStd::nullopt;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// NodeIdentifierFactory
|
||||
//////////////////////////
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace ScriptCanvasEditor
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = AZ::EntityId;
|
||||
|
||||
virtual void SetAssetId(const AZ::Data::AssetId& assetId) = 0;
|
||||
virtual void SetAssetId(const SourceHandle& assetId) = 0;
|
||||
virtual bool HasAssetId() const = 0;
|
||||
};
|
||||
|
||||
@@ -91,32 +91,7 @@ namespace ScriptCanvasEditor
|
||||
};
|
||||
|
||||
using EditorContextMenuRequestBus = AZ::EBus<EditorContextMenuRequests>;
|
||||
|
||||
class EditorScriptCanvasAssetNotifications : public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = AZ::Data::AssetId;
|
||||
|
||||
//! Notification which fires after an EditorGraph has received it's on AssetReady callback
|
||||
//! \param scriptCanvasAsset Script Canvas asset which is now ready for use in the Editor
|
||||
virtual void OnScriptCanvasAssetReady(const AZ::Data::Asset<ScriptCanvas::ScriptCanvasAssetBase>& /*scriptCanvasAsset*/) {};
|
||||
|
||||
//! Notification which fires after an EditorGraph has received it's on AssetReloaded callback
|
||||
//! \param scriptCanvasAsset Script Canvas asset which is now ready for use in the Editor
|
||||
virtual void OnScriptCanvasAssetReloaded(const AZ::Data::Asset<ScriptCanvas::ScriptCanvasAssetBase>& /*scriptCanvaAsset */) {};
|
||||
|
||||
//! Notification which fires after an EditorGraph has received it's on AssetReady callback
|
||||
//! \param AssetId AssetId of unloaded ScriptCanvas
|
||||
virtual void OnScriptCanvasAssetUnloaded(const AZ::Data::AssetId& /*assetId*/) {};
|
||||
|
||||
//! Notification which fires after an EditorGraph has received an onAssetSaved callback
|
||||
//! \param scriptCanvasAsset Script Canvas asset which was attempted to be saved
|
||||
//! \param isSuccessful specified where the Script Canvas asset was successfully saved
|
||||
virtual void OnScriptCanvasAssetSaved(const AZ::Data::AssetId) {};
|
||||
};
|
||||
using EditorScriptCanvasAssetNotificationBus = AZ::EBus<EditorScriptCanvasAssetNotifications>;
|
||||
|
||||
|
||||
class EditorGraphRequests : public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
|
||||
+21
-17
@@ -17,6 +17,7 @@
|
||||
#include <ScriptCanvas/Bus/EditorScriptCanvasBus.h>
|
||||
#include <ScriptCanvas/Execution/RuntimeComponent.h>
|
||||
#include <ScriptCanvas/Variable/VariableBus.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
@@ -34,10 +35,9 @@ namespace ScriptCanvasEditor
|
||||
: public AzToolsFramework::Components::EditorComponentBase
|
||||
, private EditorContextMenuRequestBus::Handler
|
||||
, private AzFramework::AssetCatalogEventBus::Handler
|
||||
, private AzToolsFramework::AssetSystemBus::Handler
|
||||
, private EditorScriptCanvasComponentLoggingBus::Handler
|
||||
, private EditorScriptCanvasComponentRequestBus::Handler
|
||||
, private AssetTrackerNotificationBus::Handler
|
||||
, private AzToolsFramework::AssetSystemBus::Handler
|
||||
, private AzToolsFramework::EditorEntityContextNotificationBus::Handler
|
||||
|
||||
{
|
||||
@@ -46,7 +46,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
EditorScriptCanvasComponent();
|
||||
// EditorScriptCanvasComponent(AZ::Data::Asset<ScriptCanvasAsset> asset);
|
||||
EditorScriptCanvasComponent(AZ::Data::Asset<ScriptCanvasAsset> asset);
|
||||
EditorScriptCanvasComponent(const SourceHandle& sourceHandle);
|
||||
~EditorScriptCanvasComponent() override;
|
||||
|
||||
//=====================================================================
|
||||
@@ -70,14 +70,14 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void OpenEditor();
|
||||
|
||||
void SetName(const AZStd::string& name) { m_name = name; }
|
||||
void SetName(AZStd::string_view name) { m_name = name; }
|
||||
const AZStd::string& GetName() const;
|
||||
AZ::EntityId GetEditorEntityId() const { return GetEntity() ? GetEntityId() : AZ::EntityId(); }
|
||||
AZ::NamedEntityId GetNamedEditorEntityId() const { return GetEntity() ? GetNamedEntityId() : AZ::NamedEntityId(); }
|
||||
|
||||
//=====================================================================
|
||||
// EditorScriptCanvasComponentRequestBus
|
||||
void SetAssetId(const AZ::Data::AssetId& assetId) override;
|
||||
void SetAssetId(const SourceHandle& assetId) override;
|
||||
bool HasAssetId() const override;
|
||||
//=====================================================================
|
||||
|
||||
@@ -85,13 +85,12 @@ namespace ScriptCanvasEditor
|
||||
// EditorContextMenuRequestBus
|
||||
AZ::Data::AssetId GetAssetId() const override;
|
||||
//=====================================================================
|
||||
AZ::EntityId GetGraphEntityId() const;
|
||||
|
||||
|
||||
//=====================================================================
|
||||
// AssetTrackerNotificationBus
|
||||
void OnAssetReady(const ScriptCanvasMemoryAsset::pointer asset) override;
|
||||
void OnAssetSaved(const ScriptCanvasMemoryAsset::pointer asset, bool isSuccessful) override;
|
||||
void OnAssetReloaded(const ScriptCanvasMemoryAsset::pointer asset) override;
|
||||
void OnAssetReady(const ScriptCanvasMemoryAsset::pointer asset) ;
|
||||
void OnAssetSaved(const ScriptCanvasMemoryAsset::pointer asset, bool isSuccessful) ;
|
||||
void OnAssetReloaded(const ScriptCanvasMemoryAsset::pointer asset) ;
|
||||
//=====================================================================
|
||||
|
||||
|
||||
@@ -119,25 +118,30 @@ namespace ScriptCanvasEditor
|
||||
(void)incompatible;
|
||||
}
|
||||
|
||||
void OnCatalogAssetAdded(const AZ::Data::AssetId& assetId) override;
|
||||
void OnCatalogAssetRemoved(const AZ::Data::AssetId& assetId, const AZ::Data::AssetInfo& assetInfo) override;
|
||||
void OnScriptCanvasAssetChanged(AZ::Data::AssetId assetId);
|
||||
// complete the id, load call OnScriptCanvasAssetChanged
|
||||
void SourceFileChanged(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid fileAssetId) override;
|
||||
|
||||
// update the display icon for failure, save the values in the graph
|
||||
void SourceFileRemoved(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid fileAssetId) override;
|
||||
void SourceFileFailed(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid fileAssetId) override;
|
||||
|
||||
void OnScriptCanvasAssetChanged(const SourceHandle& sourceHandle);
|
||||
|
||||
void UpdateName();
|
||||
|
||||
//=====================================================================
|
||||
void OnScriptCanvasAssetReady(const ScriptCanvasMemoryAsset::pointer asset);
|
||||
void OnScriptCanvasAssetReady(const SourceHandle& sourceHandle);
|
||||
//=====================================================================
|
||||
|
||||
void BuildGameEntityData();
|
||||
void ClearVariables();
|
||||
|
||||
private:
|
||||
AZ::Data::AssetId m_removedCatalogId;
|
||||
AZ::Data::AssetId m_previousAssetId;
|
||||
AZStd::string m_name;
|
||||
ScriptCanvasAssetHolder m_scriptCanvasAssetHolder;
|
||||
bool m_runtimeDataIsValid = false;
|
||||
ScriptCanvasBuilder::BuildVariableOverrides m_variableOverrides;
|
||||
SourceHandle m_sourceHandle;
|
||||
SourceHandle m_previousHandle;
|
||||
SourceHandle m_removedHandle;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace GraphCanvas
|
||||
|
||||
namespace ScriptCanvasEditor
|
||||
{
|
||||
AZStd::optional<SourceHandle> CompleteDescription(const SourceHandle& source);
|
||||
|
||||
class Graph;
|
||||
class NodePaletteModel;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
void ReflectComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
SourceHandle::Reflect(context);
|
||||
ScriptCanvas::ScriptCanvasData::Reflect(context);
|
||||
ScriptCanvasAssetHolder::Reflect(context);
|
||||
EditorSettings::EditorWorkspace::Reflect(context);
|
||||
|
||||
@@ -1944,7 +1944,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (auto firstRequestBus = EditorScriptCanvasComponentRequestBus::FindFirstHandler(entity->GetId()))
|
||||
{
|
||||
firstRequestBus->SetAssetId(memoryAsset.Id());
|
||||
firstRequestBus->SetAssetId(memoryAsset.Describe());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1953,7 +1953,7 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (editorComponent->GetAssetId() == oldId)
|
||||
{
|
||||
editorComponent->SetAssetId(memoryAsset.Id());
|
||||
editorComponent->SetAssetId(memoryAsset.Describe());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4377,15 +4377,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (usableRequestBus)
|
||||
{
|
||||
ScriptCanvasMemoryAsset::pointer memoryAsset;
|
||||
// #sc_editor_asset
|
||||
// AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, m_activeGraph);
|
||||
|
||||
if (memoryAsset)
|
||||
{
|
||||
// We need to assign the AssetId for the file asset, not the in-memory asset
|
||||
usableRequestBus->SetAssetId(memoryAsset->GetFileAssetId());
|
||||
}
|
||||
usableRequestBus->SetAssetId(m_activeGraph.Describe());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,6 @@ namespace ScriptCanvasEditor
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
const SourceHandle& Modifier::GetCurrentAsset() const
|
||||
{
|
||||
return m_state == State::GatheringDependencies
|
||||
? m_assets[m_assetIndex]
|
||||
: m_assets[m_dependencyOrderedAssetIndicies[m_assetIndex]];
|
||||
}
|
||||
|
||||
AZStd::unordered_set<size_t>& Modifier::GetOrCreateDependencyIndexSet()
|
||||
{
|
||||
auto iter = m_dependencies.find(m_assetIndex);
|
||||
@@ -101,36 +94,40 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
anyFailures = true;
|
||||
VE_LOG("Modifier: ERROR - Failed to gather dependencies from graph data: %s"
|
||||
, GetCurrentAsset().Path().c_str())
|
||||
, ModCurrentAsset().Path().c_str())
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
anyFailures = true;
|
||||
VE_LOG("Modifier: ERROR - Failed to load asset %s for modification, even though it scanned properly"
|
||||
, GetCurrentAsset().Path().c_str());
|
||||
, ModCurrentAsset().Path().c_str());
|
||||
}
|
||||
|
||||
ModelNotificationsBus::Broadcast
|
||||
( &ModelNotificationsTraits::OnUpgradeDependenciesGathered
|
||||
, GetCurrentAsset()
|
||||
, ModCurrentAsset()
|
||||
, anyFailures ? Result::Failure : Result::Success);
|
||||
|
||||
ReleaseCurrentAsset();
|
||||
|
||||
// Flush asset database events to ensure no asset references are held by closures queued on Ebuses.
|
||||
AZ::Data::AssetManager::Instance().DispatchEvents();
|
||||
}
|
||||
|
||||
SourceHandle Modifier::LoadAsset()
|
||||
{
|
||||
auto outcome = LoadFromFile(GetCurrentAsset().Path().c_str());
|
||||
if (outcome.IsSuccess())
|
||||
auto& handle = ModCurrentAsset();
|
||||
if (!handle.IsValid())
|
||||
{
|
||||
return outcome.TakeValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
auto outcome = LoadFromFile(handle.Path().c_str());
|
||||
if (outcome.IsSuccess())
|
||||
{
|
||||
handle = outcome.TakeValue();
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Modifier::ModificationComplete(const ModificationResult& result)
|
||||
@@ -147,12 +144,19 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
SourceHandle& Modifier::ModCurrentAsset()
|
||||
{
|
||||
return m_state == State::GatheringDependencies
|
||||
? m_assets[m_assetIndex]
|
||||
: m_assets[m_dependencyOrderedAssetIndicies[m_assetIndex]];
|
||||
}
|
||||
|
||||
void Modifier::ModifyCurrentAsset()
|
||||
{
|
||||
m_result = {};
|
||||
m_result.asset = GetCurrentAsset();
|
||||
m_result.asset = ModCurrentAsset();
|
||||
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnUpgradeModificationBegin, m_config, GetCurrentAsset());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnUpgradeModificationBegin, m_config, ModCurrentAsset());
|
||||
|
||||
if (auto asset = LoadAsset(); asset.IsValid())
|
||||
{
|
||||
@@ -169,13 +173,19 @@ namespace ScriptCanvasEditor
|
||||
void Modifier::ModifyNextAsset()
|
||||
{
|
||||
ModelNotificationsBus::Broadcast
|
||||
( &ModelNotificationsTraits::OnUpgradeModificationEnd, m_config, GetCurrentAsset(), m_result);
|
||||
( &ModelNotificationsTraits::OnUpgradeModificationEnd, m_config, ModCurrentAsset(), m_result);
|
||||
ModificationNotificationsBus::Handler::BusDisconnect();
|
||||
m_modifyState = ModifyState::Idle;
|
||||
ReleaseCurrentAsset();
|
||||
++m_assetIndex;
|
||||
m_result = {};
|
||||
}
|
||||
|
||||
void Modifier::ReleaseCurrentAsset()
|
||||
{
|
||||
ModCurrentAsset() = ModCurrentAsset().Describe();
|
||||
}
|
||||
|
||||
void Modifier::ReportModificationError(AZStd::string_view report)
|
||||
{
|
||||
m_result.asset = {};
|
||||
@@ -286,7 +296,7 @@ namespace ScriptCanvasEditor
|
||||
m_dependencyOrderedAssetIndicies.push_back(index);
|
||||
}
|
||||
|
||||
// go straight into ModifyinGraphs
|
||||
// go straight into ModifyingGraphs
|
||||
m_assetIndex = m_assets.size();
|
||||
}
|
||||
}
|
||||
@@ -309,6 +319,7 @@ namespace ScriptCanvasEditor
|
||||
else
|
||||
{
|
||||
GatherDependencies();
|
||||
ReleaseCurrentAsset();
|
||||
++m_assetIndex;
|
||||
}
|
||||
}
|
||||
@@ -370,7 +381,7 @@ namespace ScriptCanvasEditor
|
||||
(ScriptCanvas::k_VersionExplorerWindow.data()
|
||||
, false
|
||||
, "Modifier: Dependency sort has failed during, circular dependency detected for Asset: %s"
|
||||
, modifier->GetCurrentAsset().Path().c_str());
|
||||
, modifier->ModCurrentAsset().Path().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,12 +83,13 @@ namespace ScriptCanvasEditor
|
||||
FileSaveResult m_fileSaveResult;
|
||||
|
||||
void GatherDependencies();
|
||||
const SourceHandle& GetCurrentAsset() const;
|
||||
AZStd::unordered_set<size_t>& GetOrCreateDependencyIndexSet();
|
||||
SourceHandle LoadAsset();
|
||||
SourceHandle& ModCurrentAsset();
|
||||
void ModifyCurrentAsset();
|
||||
void ModifyNextAsset();
|
||||
void ModificationComplete(const ModificationResult& result) override;
|
||||
void ReleaseCurrentAsset();
|
||||
void ReportModificationError(AZStd::string_view report);
|
||||
void ReportModificationSuccess();
|
||||
void ReportSaveResult();
|
||||
|
||||
@@ -32,8 +32,12 @@ namespace ScannerCpp
|
||||
&& entry->GetFullPath().ends_with(".scriptcanvas"))
|
||||
{
|
||||
auto sourceEntry = azrtti_cast<const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry*>(entry);
|
||||
|
||||
AZStd::string fullPath = sourceEntry->GetFullPath();
|
||||
AzFramework::StringFunc::Path::Normalize(fullPath);
|
||||
|
||||
result.m_catalogAssets.push_back(
|
||||
ScriptCanvasEditor::SourceHandle(nullptr, sourceEntry->GetSourceUuid(), sourceEntry->GetFullPath()));
|
||||
ScriptCanvasEditor::SourceHandle(nullptr, sourceEntry->GetSourceUuid(), fullPath));
|
||||
}
|
||||
|
||||
const int rowCount = model.rowCount(index);
|
||||
@@ -79,23 +83,18 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (m_config.filter && m_config.filter(asset) == ScanConfiguration::Filter::Exclude)
|
||||
{
|
||||
VE_LOG("Scanner: Excluded: %s ", GetCurrentAsset().Path().c_str());
|
||||
m_result.m_filteredAssets.push_back(GetCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanFilteredGraph, GetCurrentAsset());
|
||||
VE_LOG("Scanner: Excluded: %s ", ModCurrentAsset().Path().c_str());
|
||||
m_result.m_filteredAssets.push_back(ModCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanFilteredGraph, ModCurrentAsset());
|
||||
}
|
||||
else
|
||||
{
|
||||
VE_LOG("Scanner: Included: %s ", GetCurrentAsset().Path().c_str());
|
||||
m_result.m_unfiltered.push_back(GetCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanUnFilteredGraph, GetCurrentAsset());
|
||||
VE_LOG("Scanner: Included: %s ", ModCurrentAsset().Path().c_str());
|
||||
m_result.m_unfiltered.push_back(ModCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanUnFilteredGraph, ModCurrentAsset());
|
||||
}
|
||||
}
|
||||
|
||||
const SourceHandle& Scanner::GetCurrentAsset() const
|
||||
{
|
||||
return m_result.m_catalogAssets[m_catalogAssetIndex];
|
||||
}
|
||||
|
||||
const ScanResult& Scanner::GetResult() const
|
||||
{
|
||||
return m_result;
|
||||
@@ -103,7 +102,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
SourceHandle Scanner::LoadAsset()
|
||||
{
|
||||
auto fileOutcome = LoadFromFile(GetCurrentAsset().Path().c_str());
|
||||
auto fileOutcome = LoadFromFile(ModCurrentAsset().Path().c_str());
|
||||
if (fileOutcome.IsSuccess())
|
||||
{
|
||||
return fileOutcome.GetValue();
|
||||
@@ -114,6 +113,11 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
SourceHandle& Scanner::ModCurrentAsset()
|
||||
{
|
||||
return m_result.m_catalogAssets[m_catalogAssetIndex];
|
||||
}
|
||||
|
||||
void Scanner::OnSystemTick()
|
||||
{
|
||||
if (m_catalogAssetIndex == m_result.m_catalogAssets.size())
|
||||
@@ -130,17 +134,17 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (auto asset = LoadAsset(); asset.IsValid())
|
||||
{
|
||||
VE_LOG("Scanner: Loaded: %s ", GetCurrentAsset().Path().c_str());
|
||||
VE_LOG("Scanner: Loaded: %s ", ModCurrentAsset().Path().c_str());
|
||||
FilterAsset(asset);
|
||||
}
|
||||
else
|
||||
{
|
||||
VE_LOG("Scanner: Failed to load: %s ", GetCurrentAsset().Path().c_str());
|
||||
m_result.m_loadErrors.push_back(GetCurrentAsset());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanLoadFailure, GetCurrentAsset());
|
||||
VE_LOG("Scanner: Failed to load: %s ", ModCurrentAsset().Path().c_str());
|
||||
m_result.m_loadErrors.push_back(ModCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanLoadFailure, ModCurrentAsset());
|
||||
}
|
||||
|
||||
VE_LOG("Scanner: scan of %s complete", GetCurrentAsset().Path().c_str());
|
||||
VE_LOG("Scanner: scan of %s complete", ModCurrentAsset().Path().c_str());
|
||||
++m_catalogAssetIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace ScriptCanvasEditor
|
||||
ScanResult m_result;
|
||||
|
||||
void FilterAsset(SourceHandle);
|
||||
const SourceHandle& GetCurrentAsset() const;
|
||||
SourceHandle LoadAsset();
|
||||
SourceHandle& ModCurrentAsset();
|
||||
void OnSystemTick() override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/RTTI/AttributeReader.h>
|
||||
@@ -14,9 +15,8 @@
|
||||
#include <AzCore/StringFunc/StringFunc.h>
|
||||
#include <Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h>
|
||||
|
||||
#include "Core.h"
|
||||
#include "Attributes.h"
|
||||
|
||||
#include "Core.h"
|
||||
#include <Core/Graph.h>
|
||||
|
||||
namespace ScriptCanvas
|
||||
@@ -238,6 +238,11 @@ namespace ScriptCanvasEditor
|
||||
return m_data != nullptr;
|
||||
}
|
||||
|
||||
bool SourceHandle::IsValidDescription() const
|
||||
{
|
||||
return !m_id.IsNull() && !m_path.empty();
|
||||
}
|
||||
|
||||
GraphPtr SourceHandle::Mod() const
|
||||
{
|
||||
return m_data ? m_data->ModEditorGraph() : nullptr;
|
||||
@@ -265,6 +270,30 @@ namespace ScriptCanvasEditor
|
||||
return m_path == other.m_path;
|
||||
}
|
||||
|
||||
void SourceHandle::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serializeContext->Class<SourceHandle>()
|
||||
->Version(0)
|
||||
->Field("id", &SourceHandle::m_id)
|
||||
->Field("path", &SourceHandle::m_path)
|
||||
;
|
||||
|
||||
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
|
||||
{
|
||||
editContext->Class<SourceHandle>("Script Canvas Source Handle", "References a source editor file")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::Category, "Scripting")
|
||||
->Attribute(AZ::Edit::Attributes::Icon, "Icons/ScriptCanvas/ScriptCanvas.svg")
|
||||
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/ScriptCanvas/Viewport/ScriptCanvas.svg")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &SourceHandle::m_path);
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AZStd::string SourceHandle::ToString() const
|
||||
{
|
||||
return AZStd::string::format
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#define OBJECT_STREAM_EDITOR_ASSET_LOADING_SUPPORT_ENABLED
|
||||
|
||||
#define EDITOR_ASSET_SUPPORT_ENABLED
|
||||
// #define EDITOR_ASSET_SUPPORT_ENABLED
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -325,6 +325,8 @@ namespace ScriptCanvasEditor
|
||||
AZ_TYPE_INFO(SourceHandle, "{65855A98-AE2F-427F-BFC8-69D45265E312}");
|
||||
AZ_CLASS_ALLOCATOR(SourceHandle, AZ::SystemAllocator, 0);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
SourceHandle() = default;
|
||||
|
||||
SourceHandle(const SourceHandle& data, const AZ::Uuid& id, const AZ::IO::Path& path);
|
||||
@@ -344,6 +346,8 @@ namespace ScriptCanvasEditor
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
bool IsValidDescription() const;
|
||||
|
||||
GraphPtr Mod() const;
|
||||
|
||||
bool operator==(const SourceHandle& other) const;
|
||||
@@ -372,8 +376,8 @@ namespace ScriptCanvas
|
||||
|
||||
AZ_RTTI(ScriptCanvasData, "{1072E894-0C67-4091-8B64-F7DB324AD13C}");
|
||||
AZ_CLASS_ALLOCATOR(ScriptCanvasData, AZ::SystemAllocator, 0);
|
||||
ScriptCanvasData() {}
|
||||
virtual ~ScriptCanvasData() {}
|
||||
ScriptCanvasData() = default;
|
||||
virtual ~ScriptCanvasData() = default;
|
||||
ScriptCanvasData(ScriptCanvasData&& other);
|
||||
ScriptCanvasData& operator=(ScriptCanvasData&& other);
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace GraphCpp
|
||||
VariablePanelSymantics,
|
||||
AddVersionData,
|
||||
RemoveFunctionGraphMarker,
|
||||
FixupVersionDataTypeId,
|
||||
// label your version above
|
||||
Current
|
||||
};
|
||||
@@ -71,11 +72,22 @@ namespace ScriptCanvas
|
||||
componentElementNode.AddElementWithData(context, "m_assetType", azrtti_typeid<RuntimeAsset>());
|
||||
}
|
||||
|
||||
if (componentElementNode.GetVersion() < GraphCpp::GraphVersion::RemoveFunctionGraphMarker)
|
||||
if (componentElementNode.GetVersion() <= GraphCpp::GraphVersion::RemoveFunctionGraphMarker)
|
||||
{
|
||||
componentElementNode.RemoveElementByName(AZ_CRC_CE("isFunctionGraph"));
|
||||
}
|
||||
|
||||
if (componentElementNode.GetVersion() < GraphCpp::GraphVersion::FixupVersionDataTypeId)
|
||||
{
|
||||
if (auto subElement = componentElementNode.FindSubElement(AZ_CRC_CE("versionData")))
|
||||
{
|
||||
if (subElement->GetId() == azrtti_typeid<SlotId>())
|
||||
{
|
||||
componentElementNode.RemoveElementByName(AZ_CRC_CE("versionData"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"Type": "JsonSerialization",
|
||||
"Version": 1,
|
||||
"ClassName": "ScriptCanvasData",
|
||||
"ClassData": {
|
||||
"m_scriptCanvas": {
|
||||
"Id": {
|
||||
"id": 32884619828465
|
||||
},
|
||||
"Name": "Script Canvas Graph",
|
||||
"Components": {
|
||||
"Component_[14322649685925277086]": {
|
||||
"$type": "EditorGraphVariableManagerComponent",
|
||||
"Id": 14322649685925277086,
|
||||
"m_variableData": {
|
||||
"m_nameVariableMap": [
|
||||
{
|
||||
"Key": {
|
||||
"m_id": "{142C0457-38E5-496E-A4F2-67E91852CBCB}"
|
||||
},
|
||||
"Value": {
|
||||
"Datum": {
|
||||
"isOverloadedStorage": false,
|
||||
"scriptCanvasType": {
|
||||
"m_type": 4,
|
||||
"m_azType": "{5CBE5640-DF5C-5A49-9195-D790881A0747}"
|
||||
},
|
||||
"isNullPointer": false,
|
||||
"$type": "{5CBE5640-DF5C-5A49-9195-D790881A0747} AZStd::vector",
|
||||
"value": [
|
||||
[
|
||||
0.0,
|
||||
0.0,
|
||||
-498814079205376.0,
|
||||
0.0
|
||||
],
|
||||
[
|
||||
0.0,
|
||||
0.0,
|
||||
1.1865528051967005e38,
|
||||
0.0
|
||||
]
|
||||
],
|
||||
"label": "Variable 7"
|
||||
},
|
||||
"VariableId": {
|
||||
"m_id": "{142C0457-38E5-496E-A4F2-67E91852CBCB}"
|
||||
},
|
||||
"VariableName": "Variable 7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Key": {
|
||||
"m_id": "{21DD2B3D-ADC9-46E1-B44C-965A6E2AE543}"
|
||||
},
|
||||
"Value": {
|
||||
"Datum": {
|
||||
"isOverloadedStorage": false,
|
||||
"scriptCanvasType": {
|
||||
"m_type": 4,
|
||||
"m_azType": "{9ABF5933-C8FC-53CD-A518-B6AF433CF496}"
|
||||
},
|
||||
"isNullPointer": false,
|
||||
"$type": "{9ABF5933-C8FC-53CD-A518-B6AF433CF496} AZStd::unordered_map",
|
||||
"value": [
|
||||
{
|
||||
"Key": true,
|
||||
"Value": {
|
||||
"roll":
|
||||
Reference in New Issue
Block a user