zoukankan      html  css  js  c++  java
  • Ue4 BatteryCollector 教程笔记

    H

    UFUNCTION(BlueprintNativeEvent)

    void EventName();

    virtual void EventName_Implementation();

    EventName事件发生时会调用这个函数

    CPP

    void ClassName::EventName_Implementation()

    这个宏是UE4的强制内联函数,用于优化,返回Mesh的指针给Pickup

    FORCEINLINE class UStaticMeshComponent *GetMesh() const { return PickupMesh;}

    //BlueprintPure 此函数不会以任何方式影响其从属对象,并且可在蓝图或关卡蓝图图表中执行。

    UFCUNTION相关

    https://docs.unrealengine.com/latest/CHN/Programming/UnrealArchitecture/Reference/Functions/index.html

    UFUNCTION(BlueprintPure, Category = "PickUp")

    UFUNCTION(BlueprintCallable, Category = "PickUp")

    UFUNCTION(BlueprintNativeEvent)

    UFUNCTION(BlueprintImplementableEvent,Category="Power")

    UPROPERTY相关

    https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/index.html

    //这个属性就是可以让你在编辑器中修改组件,因为目前版本不加这个可能会无法修改吧,到时候试试看

    UPROPERTY(EditAnywhere,BlueprintReadWrite,Category="Power",Meta=(BlueprintProtected="true"))

    UPROPERTY(VisibleAnywhere,BlueprintReadOnly,Category="Pickup",meta=(AllowPrivateAccess ="true"))

    class UStaticMeshComponent *PickupMesh;

    ———————————————————————————————

    总结一下,需要与蓝图交互的函数与变量会使用UFUNCTION,UPROPERTY宏,不需要的这不需要使用这些宏。

    案例中使用的随机数相关代码

    包含头文件

    #include "Kismet/KismetMathLibrary.h"

    FMath::FRandRange(float inMin,float inMax)

    HUD部分

    之前需要在项目中的CS文件中添加UMG模块之后,在对应的CPP文件中添加,不过我不太建议在C++文件中做HUD操作

    PrivateDependencyModuleNames.AddRange(newstring[]{"Slate","SlateCore"});

    #include "Blueprint/UserWidget.h"

    UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))

    TSubclassOf<class UUserWidget> HUDWidgetClass;

    HUD实例

    UPROPERTY()

    class UUserWidget *CurrentWidget;

    if (HUDWidgetClass!=nullptr)

    {

            CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), HUDWidgetClass);

            if (CurrentWidget!=nullptr)

            {

                        CurrentWidget->AddToViewport();

            }

    }

  • 相关阅读:
    LeetCode 32.使数组唯一的最小增量
    LeetCode 31. 最小的k个数 快速排序+堆排序+二叉搜索树
    LeetCode 30. 最长回文串
    LeetCode 29. 矩形重叠 反向思维
    LeetCode 28. 拼写单词 HashMap赋值给另一个HashMap
    LeetCode 27. 字符串压缩
    Java SSM Spring+Spring MVC+Mybatis整合
    LeetCode 26.岛屿的最大面积 DFS深度遍历问题
    LeetCode 25.最长上升子序列 动态规划
    LeetCode 24.找出数组中出现次数大于二分之一数组长度的数
  • 原文地址:https://www.cnblogs.com/blueroses/p/5189675.html
Copyright © 2011-2022 走看看