限制范围:
meta=(ClampMin = float,ClampMax = float,UIMin = float, UIMax = float)
限制范围:
meta=(ClampMin = float,ClampMax = float,UIMin = float, UIMax = float)
//在Editor中限制最大值,最小时
UPROPERTY(EditDefaultsOnly, Category = "My Actor Propertys | Vector", meta = (ClampMin = -5.0f, ClampMax = 5.0f, UIMin = -5.0f, UIMax = 5.0f)
UCLASS()
class STATICMESHSAMPLE_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
UPROPERTY(VisibleAnyWhere, Category = "My Actor Components")
UStaticMeshComponent *StaticMesh;
//大多数属性都有 Edit 和 Visible, 但是 VisiableAnyWhere 不推荐使用 Edit 属性
UPROPERTY(EditInstanceOnly, Category = "My Actor Propertys | Vector")
FVector InitLocation;
UPROPERTY(VisibleInstanceOnly, Category = "My Actor Propertys | Vector")
FVector PacedLocation;
UPROPERTY(EditDefaultsOnly, Category = "My Actor Propertys | Vector")
bool bGotoInitLocation;
UPROPERTY(VisibleDefaultsOnly, Category = "My Actor Propertys | Vector")
FVector WorldOrigin;
UPROPERTY(EditAnywhere, Category = "My Actor Propertys | Vector", meta = (ClampMin = -5.0f, ClampMax = 5.0f, UIMin = -5.0f, UIMax = 5.0f))
FVector TickLocationOffset;
UPROPERTY(EditAnywhere, Category = "My Actor Propertys | Vector")
bool ShouldMove;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
408
1.不要将UStaticMesh * MyStaticMesh的UPROPERTY()设置为EditAnywhere,不然会有意想不到的效果
2.在FVector TickLocationOffset变量的UPROPERTY()中添加:
meta=(ClampMin=-5.0f,ClampMax=5.0f,UIMin=-5.0f,UIMax=5.0f)