时间:2023-07-25 07:30:01 | 来源:网站运营
时间:2023-07-25 07:30:01 来源:网站运营
虚幻ImGui网页绘制插件:ImGui_WS仓库地址(详细文档请看仓库中的readmeUShootWeaponBulletDrawer::UShootWeaponBulletDrawer(){ // 标识该Drawer支持的Actor类型 DrawActor = AShootWeaponBullet::StaticClass(); // 绘制的实体半径 Radius = 10.f; // 绘制的颜色 Color = FLinearColor::Red;}
void UShootWeaponBulletDrawer::DrawImGuiDebuggerExtendInfo(const AActor* Actor, const FImGuiWorldViewportContext& DebuggerContext) const{ const AShootWeaponBullet* Bullet = CastChecked<AShootWeaponBullet>(Actor); const FVector EndLocation = Bullet->GetActorLocation(); const FVector StartLocation = EndLocation - Actor->GetVelocity() * DebuggerContext.DeltaSeconds; DebuggerContext.DrawLine(FVector2D{ StartLocation }, FVector2D{ EndLocation }, Color);}
// 声明开关UPROPERTY(Config)uint8 bExampleToggle : 1;// 实现中添加是否开启开关的菜单选项if (ImGui::BeginMenu("Example Menu")){ { bool Value = bExampleToggle; if (ImGui::Checkbox("Example Toggle", &Value)) { bShowGlobalLifeTime = Value; DebuggerContext.MarkConfigDirty(); } } ImGui::EndMenu();}// 逻辑中判断开关,开启的情况再进行调试信息的绘制
UImGuiWorldDebuggerViewportPanel::UImGuiWorldDebuggerViewportPanel(){ // 声明需要显示菜单栏 ImGuiWindowFlags = ImGuiWindowFlags_MenuBar; // 面板命名 Title = LOCTEXT("Viewport", "Viewport"); // 默认在ImGuiWorldDebuggerDefaultLayout布局中的位置为Viewport DefaultDockSpace = { { UImGuiWorldDebuggerDefaultLayout::StaticClass()->GetFName(), UImGuiWorldDebuggerDefaultLayout::EDockId::Viewport } };}
关键词:绘制,虚幻