Editing Exposed Variables

Hi There!!

In this lecture, we learn some more UPROPERTY() specifiers.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "BasePawn.generated.h"

UCLASS()
class TOONTANKS_API ABasePawn : public APawn
{
	GENERATED_BODY()

public:
	// Sets default values for this pawn's properties
	ABasePawn();

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
	int32 VisibleAnywhereInt = 12;

	UPROPERTY(EditAnywhere, BlueprintReadOnly)
	int32 EditAnywhereInt = 22;

	UPROPERTY(VisibleInstanceOnly)
	int32 VisibleInstanceOnlyInt = 82;

	UPROPERTY(VisibleDefaultsOnly)
	int32 VisibleDefaultsOnlyInt = 45;

	UPROPERTY(EditDefaultsOnly)
	int32 EditDefaultsOnlyInt = 96;

	UPROPERTY(EditInstanceOnly)
	int32 EditInstanceOnlyInt = 78;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	int32 Damage = 41;

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

private:
	UPROPERTY()
	class UCapsuleComponent* CapsuleComp;
	UPROPERTY()
	UStaticMeshComponent* BaseMesh;
	UPROPERTY()
	UStaticMeshComponent* TurretMesh;
	UPROPERTY()
	USceneComponent* ProjectileSpawnPoint;
public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};

In the public section, compared to the last post, you’ll find some new specifiers.

VisibleDefaultsOnly - Makes the variable visible in the defaults panel only.

EditDefaultsOnly - Makes the variable editable only in the defaults panel.

EditInstanceOnly - Makes the variable editable only in the instance panel.

We can’t expose any of these variables in our blueprints though, so let’s have look at that.

The UPROPERTY() can take more than one argument.

you can understand this much better in the lecture. It’s a new and useful thing, so make sure you learn it nicely.

Previous Toon Tanks post: Instance vs Default

Thanks for reading,
Good Bye!!

2 Likes

UPROPERTY is very helpful! Nice post :+1:

1 Like

Indeed, UPROPERTY() can save up a lot of time.

1 Like

My hero

1 Like

Mine too!