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();

            }

    }

  • 相关阅读:
    nginx reload 与 restart 的区别
    求解一个数n的阶乘(递归求解 与 循环求解)
    类的加载机制
    JVM基础知识
    File类中常用的方法以及搜索路径下的包含指定词的文件
    给定10万数据,数据范围[0~1000),统计出现次数最多的10个数据,并打印出现次数
    TreeMap以及自定义排序的Comparable和Comparator的实现
    HashTable与LinkedHashMap
    HashMap
    Map接口
  • 原文地址:https://www.cnblogs.com/blueroses/p/5189675.html
Copyright © 2011-2022 走看看