1.创建
2、属性
USTRUCT()
struct FTouchInputControl
{
GENERATED_USTRUCT_BODY()
//自由活动图片
// basically mirroring SVirtualJoystick::FControlInfo but as an editable class
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, this is the Thumb"))
UTexture2D* Image1;
//底图
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, this is the Background"))
UTexture2D* Image2;
//中心位置
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The center point of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
FVector2D Center;
//可见范围
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The size of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
FVector2D VisualSize;
//自由活动图片的尺寸
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="For sticks, the size of the thumb (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
FVector2D ThumbSize;
//触摸响应范围
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The interactive size of the control (if <= 1.0, it's relative to screen, > 1.0 is absolute)"))
FVector2D InteractionSize;
//输入力度/强度
UPROPERTY(EditAnywhere, Category = "Control", meta = (ToolTip = "The scale for control input"))
FVector2D InputScale;
//按键:触发与ProjectSetting中对应按键相同的输入事件
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The main input to send from this control (for sticks, this is the horizontal axis)"))
FKey MainInputKey;
//按键:触发与ProjectSetting中对应ALT+按键相同的输入事件
UPROPERTY(EditAnywhere, Category="Control", meta=(ToolTip="The alternate input to send from this control (for sticks, this is the vertical axis)"))
FKey AltInputKey;
FTouchInputControl()
: Image1(nullptr)
, Image2(nullptr)
, Center(ForceInitToZero)
, VisualSize(ForceInitToZero)
, ThumbSize(ForceInitToZero)
, InteractionSize(ForceInitToZero)
, InputScale(1.f, 1.f)
{
}
};
UCLASS(Blueprintable, BlueprintType)
class ENGINE_API UTouchInterface : public UObject
{
GENERATED_UCLASS_BODY()
//控制的元素列表
UPROPERTY(EditAnywhere, Category="TouchInterface")
TArray<FTouchInputControl> Controls;
//激活状态的透明度
UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Opacity (0.0 - 1.0) of all controls while any control is active"))
float ActiveOpacity;
//非激活状态的透明度
UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Opacity (0.0 - 1.0) of all controls while no controls are active"))
float InactiveOpacity;
//进去非激活状态的时间,一旦没有输入就开始计时
UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after user interaction will all controls fade out to Inactive Opacity"))
float TimeUntilDeactive;
//复位的时间
UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after going inactive will controls reset/recenter themselves (0.0 will disable this feature)"))
float TimeUntilReset;
//延迟激活
UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="How long after joystick enabled for touch (0.0 will disable this feature)"))
float ActivationDelay;
//不准复位
UPROPERTY(EditAnywhere, Category="TouchInterface", meta=(ToolTip="Whether to prevent joystick re-center"))
bool bPreventRecenter;
//
UPROPERTY(EditAnywhere, Category = "TouchInterface", meta = (ToolTip = "Delay at startup before virtual joystick is drawn"))
float StartupDelay;
//与JoyStick耦合的接口
/** Make this the active set of touch controls */
void Activate(TSharedPtr<SVirtualJoystick> VirtualJoystick);
};