在博客里贴UE蓝图的一个示例 | Blurred code

在博客里贴UE蓝图的一个示例

2023/09/13

LastMod:2023/09/13

Categories: UE

蓝图Web渲染示例-2023-09-13-23-00-38

折腾了一下在网页端渲染蓝图,主要是有的时候可能会贴点代码。 蓝图直接复制,编辑器会帮忙格式化成文本形式表示。

一个有趣的事实是编辑器里复制一个节点也是走的这个流程

void FBlueprintEditor::CopySelectedNodes()
{
	// Export the selected nodes and place the text on the clipboard
	const FGraphPanelSelectionSet SelectedNodes = GetSelectedNodes();

	FString ExportedText;

	for (FGraphPanelSelectionSet::TConstIterator SelectedIter(SelectedNodes); SelectedIter; ++SelectedIter)
	{
		if(UEdGraphNode* Node = Cast<UEdGraphNode>(*SelectedIter))
		{
			Node->PrepareForCopying();
		}
	}

    // 序列化节点为文本
	FEdGraphUtilities::ExportNodesToText(SelectedNodes, /*out*/ ExportedText); 
    // 调用系统的剪贴板
	FPlatformApplicationMisc::ClipboardCopy(*ExportedText);
}

在Github上发现有个有点意思的项目,用JS渲染蓝图,可以在网页端渲染。

参考:barsdeveloper/ueblueprint: Unreal Engine's Blueprint editing web library

用法也比较简单,参考ReadMe.md里的来就行了。用Markdown静态博客框架的话可能需要注意一下不要让静态博客程序转义蓝图里的东西,否则可能渲染不出来。

其实也有一个商业项目是类似的功能(https://blueprintue.com/),但是我担心他哪天倒闭了。 用开源库的风险就是随着虚幻版本迭代可能哪天格式变了,开源库没人维护估计格式就挂了。

Zoom 1:1
Event BeginPlay
Switch Has Authority
Execute
Authority
Remote
Print String
In String
Server
Print to Screen
Print to Log
Text Color
Duration
Development Only
Print String
In String
Client
Print To Screen
Print To Log
Text Color
Duration
Development Only
Comment
Event BeginPlay
Switch Has Authority
Execute
Authority
Remote
Print String
In String
Server
Print to Screen
Print to Log
Text Color
Duration
Development Only
Print String
In String
Client
Print To Screen
Print To Log
Text Color
Duration
Development Only