Hi,
I’m trying to write a plugin that will extend the editor by allowing creation of a custom asset(something like Sound Cue).
Plugin has two modules, runtime module and editor module.
In runtime module we wrote a class UStory which mimics USoundCue’s behaivour. We’re having issues because in Story.cpp we had to include StoryGraph header which rests in the editor module.
This caused circular dependencies between modules. As far as i know runtime module shouldn’t depend on editor module.
This is what UStory class looks like.
UCLASS()
class UStory : public UObject
{
GENERATED_BODY()
public:
#if WITH_EDITOR
UStoryGraph* GetGraph();
#endif
#if WITH_EDITOR
void PostInitProperties() override;
void CreateGraph();
#endif
private:
#if WITH_EDITORONLY_DATA
UPROPERTY() UEdGraph* StoryGraph;
#endif
};
To fix the problem we decided to create UStoryGraph object in runtime module instead of editor module and add a setter function to UStory class.
So we created the StoryGraph object inside the UStoryFactory::FactoryCreateNew(in runtime moduel) function and call the UStory::SetGraph function. We also had to change GetGraph’s return
value to UedGraph* because we can’t depend anythin on the editor module.
class UStory : public UObject
{
GENERATED_BODY()
public:
#if WITH_EDITOR
UEdGraph* GetGraph();
void SetGraph(UEdGraph*);
#endif
private:
#if WITH_EDITORONLY_DATA
UPROPERTY() UEdGraph* StoryGraph;
#endif
};
It didn’t solve our problems, Unreal Editor crashes every time UStory::GetGraph gets called. Does anyone have a better idea, or why ue4 crashes?