80 lines
2.1 KiB
C++
80 lines
2.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "RigVMCore/RigVMExternalVariable.h"
|
|
#include "RigVMModel/RigVMNode.h"
|
|
#include "EdGraphSchema_K2.h"
|
|
#include "RigVMDeveloperTypeUtils.h"
|
|
#include "RigVMVariableDescription.generated.h"
|
|
|
|
/**
|
|
* The variable description is used to convey information
|
|
* about unique variables within a Graph. Multiple Variable
|
|
* Nodes can share the same variable description.
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct FRigVMGraphVariableDescription
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
// comparison operator
|
|
bool operator ==(const FRigVMGraphVariableDescription& Other) const
|
|
{
|
|
return Name == Other.Name;
|
|
}
|
|
|
|
// The name of the variable
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = RigVMGraphVariableDescription)
|
|
FName Name;
|
|
|
|
// The C++ data type of the variable
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = RigVMGraphVariableDescription)
|
|
FString CPPType;
|
|
|
|
// The Struct of the C++ data type of the variable (or nullptr)
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = RigVMGraphVariableDescription)
|
|
TObjectPtr<UObject> CPPTypeObject = nullptr;
|
|
|
|
UPROPERTY()
|
|
FName CPPTypeObjectPath;
|
|
|
|
// The default value of the variable
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = RigVMGraphVariableDescription)
|
|
FString DefaultValue;
|
|
|
|
// The category of the variable
|
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = RigVMGraphVariableDescription)
|
|
FText Category;
|
|
|
|
// Returns nullptr external variable matching this description
|
|
FRigVMExternalVariable ToExternalVariable() const
|
|
{
|
|
return RigVMTypeUtils::ExternalVariableFromRigVMVariableDescription(*this);
|
|
}
|
|
|
|
FEdGraphPinType ToPinType() const
|
|
{
|
|
return RigVMTypeUtils::PinTypeFromRigVMVariableDescription(*this);
|
|
}
|
|
|
|
bool ChangeType(const FEdGraphPinType& PinType)
|
|
{
|
|
UObject* Object = nullptr;
|
|
const bool bSuccess = RigVMTypeUtils::CPPTypeFromPinType(PinType, CPPType, &Object);
|
|
CPPTypeObject = Object;
|
|
if (CPPTypeObject)
|
|
{
|
|
CPPTypeObjectPath = *CPPTypeObject->GetPathName();
|
|
}
|
|
else
|
|
{
|
|
CPPTypeObjectPath = NAME_None;
|
|
}
|
|
return bSuccess;
|
|
}
|
|
|
|
};
|