UE5 学习记录

>> 往场景里添加物体

  1. 点击Window菜单 → Place Actors
  2. 搜索自己写的类,或用官方默认的类。拖拽进场景

Untitled

>> 脚本挂载

  1. C++类(继承了Actor的)都可以从Place Actors拖拽进场景
  2. C++类(继承了ActorComponent的)都可挂载在场景里的 对象的Detail下

Untitled

>> 使字段可拖拽绑定/显示在Detail面板

  1. 在类里声明 UPROPERTY(EditAnywhere)
  2. 在蓝图里即可像Unity的[SerializeField]一样
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ClientMain.generated.h"

UCLASS()
class AClientMain : public AActor
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere)
	TSubclassOf<AActor> rolePrefab;

	UPROPERTY(EditAnywhere)
	float restTime;

	UPROPERTY()
	int count;

public:	

	// Sets default values for this actor's properties
	AClientMain();
	virtual void Tick(float DeltaTime) override;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

};

Untitled

>> 如何从蓝图(prefab)生成一个世界对象

https://www.bilibili.com/video/BV1HL4y1T7nV