📜  如何制作随机字符串虚幻引擎蓝图 (1)

📅  最后修改于: 2023-12-03 15:08:31.322000             🧑  作者: Mango

如何制作随机字符串虚幻引擎蓝图

在虚幻引擎中,我们可以使用蓝图制作随机字符串的生成器。本文将为大家介绍如何在虚幻引擎中制作随机字符串生成器的蓝图。

步骤
  1. 创建蓝图

在虚幻引擎中,我们需要创建一个新蓝图。右键点击Content Browser,选择“Blueprint Class”,选择“Actor”作为父类,填写好名称后点击“Create Blueprint”按钮。创建好后,双击打开该蓝图。

  1. 添加变量

在蓝图中,我们需要添加一个字符串类型的变量。在蓝图编辑器中,点击右侧Variable窗口的“+”按钮,选择“Add Variable”,填写名称和类型为“String”。这个变量将用于保存我们生成的随机字符串。

  1. 添加生成随机字符串的节点

我们需要添加一个节点来生成随机字符串。在蓝图编辑器中,按下“B”键打开Search窗口,输入“Random String”并选择“Make Literal String(Random)”节点。将该节点拖到蓝图中。

  1. 连接节点并保存

我们需要将生成的随机字符串节点连上该蓝图的字符串变量节点。将生成的随机字符串节点的输出插入到蓝图的字符串变量节点的赋值输入。最后,记得要保存该蓝图!

代码

以下为我们的蓝图代码片段:

Begin Object Class=/Script/BlueprintGraph.K2Node_VariableGet Name="K2Node_VariableGet_0"
   VariableReference=(MemberName="RandomString",MemberGuid=11CB058A4E8BAD3D3D3A8382B2F8A9E4)
   SelfContextInfo=NotSelfContext
   NodePosX=-144
   NodePosY=-176
   NodeGuid=F6E9C0494AC2CC59412D6BBEAA6FAEB8
   CustomProperties Pin (PinId=A2EA43B74420E15F4A92969A7D4C07E4,PinName="RandomString",Direction="EGPD_Output",PinType.PinCategory="string",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinValueType=(),PinType.bIsMap=False,PinType.bIsSet=False,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="If first time opened: Open me!",AutogeneratedDefaultValue="",LinkedTo=(K2Node_CallFunction_5 12A5EAC2409BA65CFBB736A3CD2E2032,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_5"
   FunctionReference=(MemberParent=Class'/Script/Engine.KismetStringLibrary',MemberName="RandomString")
   NodePosX=96
   NodePosY=-176
   NodeGuid=AB9EF67E4F0940063D3FDF8DCEA2E35C
   AdvancedPinDisplay=EAdvancedPinDisplay.Hidden
   NodeType=K2Node_CallFunction
   bIsPureFunc=True
   bIsConstFunc=True
   NodeComment=""
   FunctionResult=(Type=PinHelpers.EConfigurationType.Linear,PinType=(PinCategory="string",PinSubCategory="",PinSubCategoryObject=None,PinValueType=(),bIsMap=False,bIsSet=False,bIsArray=False,bIsReference=False,bIsConst=False,bIsStrongReference=False,bIsWeakPointer=False,DefaultValue=""))
   CustomProperties Pin (PinId=12A5EAC2409BA65CFBB736A3CD2E2032,PinName="execute",PinToolTip="\nExecute",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinValueType=(),PinType.bIsMap=False,PinType.bIsSet=False,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,LinkedTo=(K2Node_VariableGet_0 A2EA43B74420E15F4A92969A7D4C07E4,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=13938F74419D58B4A02ED4AF4A4E50AA,PinName="then",PinToolTip="\nExec",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinValueType=(),PinType.bIsMap=False,PinType.bIsSet=False,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=3145F2CA4E204E43111A3FBBF604A664,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet String Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=Class'/Script/Engine.KismetStringLibrary',PinType.PinValueType=(),PinType.bIsMap=False,PinType.bIsSet=False,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultObject="/Script/Engine.Default__KismetStringLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=DC09B276402F36F121754C9A9F1F968A,PinName="InStringLength",PinToolTip="In String Length\nInteger\n\nthe number of characters in the output string",PinType.PinCategory="int",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinValueType=(),PinType.bIsMap=False,PinType.bIsSet=False,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="10",AutogeneratedDefaultValue="4",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
   CustomProperties Pin (PinId=3916ADA44CA6BBD57FF781A8EFB521E6,PinName="RandomCase",PinToolTip="Random Case\nBoolean\n\nif true, the returned string has random upper or lowercase letters",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinValueType=(),PinType.bIsMap=False,PinType.bIsSet=False,PinType.bIsArray=False,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,DefaultValue="false",AutogeneratedDefaultValue="false",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
结论

本文介绍了如何在虚幻引擎中制作随机字符串生成器的蓝图。我们添加了一个字符串类型的变量,并使用了“Make Literal String(Random)”节点来生成随机字符串。最后,我们将生成的随机字符串节点与字符串变量节点连接起来,以保存我们生成的随机字符串。