Skip to content
AdsButton

界面 / AdsButton

AdsButton Class
​

广告按钮,请注意广告按钮不允许被遮挡

需要在游戏中使用 onshow/onclose 才能播放广告

当其上方有任何非隐藏/折叠的UI时,广告按钮将无法生效

Hierarchy ​

Table of contents ​

Accessors
​

autoAdjust(): boolean client
获取字体是否自适应调整大小:boolean(为True时,文本内容字体大小将自动改变,尽可能大的充满整个文本框,而文本框大小不会变化)
fontColor(): LinearColor client
获取字体颜色
fontLetterSpace(): number client
获取字体间距
fontSize(): number client
获取字体大小
glyph(): UIFontGlyph client
获取字体字形
onClose(): MulticastDelegate<(isSuccess: boolean) => void> client
用户手动关闭广告的回调
onShow(): MulticastDelegate<(isReady: boolean) => void> client
点击按钮的回调,播放广告前执行
outlineColor(): LinearColor client
获取字体描边颜色
outlineSize(): number client
获取字体描边宽度
shadowColor(): LinearColor client
获取字体阴影颜色
shadowOffset(): Vector2 client
获取字体阴影偏移
strikethroughEnable(): boolean client
获取是否开启字体删除线
text(): string <Badge type="tip" text="client" />
获取按钮文字
textAlign(): TextJustify client
获取字体对齐方式
textVerticalAlign(): TextVerticalJustify client
获取字体垂直对齐方式
underlineEnable(): boolean client
返回是否开启字体下划线

Methods
​

addKey(key: Keys): void client
同一按键同时只能操控一个UI控件,最新绑定的UI控件会覆盖之前的绑定;脚本中添加的绑定无法覆盖编辑器按键绑定菜单中绑定相同按键的UI控件,但当两个UI控件分别通过代码和菜单绑定到同一按键时,使用代码绑定的优先级更高
getKeys(): Keys[] client
获取当前UI控件绑定的所有键盘按键,包括编辑器按键绑定菜单和用代码绑定的按键
removeKey(key: Keys): void client
此操作只会解绑动态绑定的按键无法解除编辑器按键绑定菜单中绑定的按键
newObject(parent?: Canvas, inName?: string): AdsButton client
创建 Button 控件

Accessors ​

autoAdjust
​

• get autoAdjust(): boolean client

• set autoAdjust(isAdjust): void client

获取字体是否自适应调整大小:boolean(为True时,文本内容字体大小将自动改变,尽可能大的充满整个文本框,而文本框大小不会变化)

Returns ​

boolean字体是否自适应调整大小

设置字体是否自适应调整大小:boolean(为True时,文本内容字体大小将自动改变,尽可能大的充满整个文本框,而文本框大小不会变化)

Parameters ​

isAdjust boolean字体是否自适应调整大小

fontColor
​

• get fontColor(): LinearColor client

• set fontColor(inColor): void client

获取字体颜色

Returns ​

LinearColor字体颜色,Type.LinearColor类型,数据范围0~1

设置字体颜色

Parameters ​

inColor LinearColor字体颜色,Type.LinearColor类型,数据范围0~1

fontLetterSpace
​

• get fontLetterSpace(): number client

• set fontLetterSpace(fontLetterSpace): void client

获取字体间距

Returns ​

number字体间距

设置字体间距

Parameters ​

fontLetterSpace number间距

fontSize
​

• get fontSize(): number client

• set fontSize(FontSize): void client

获取字体大小

Returns ​

number字体大小

设置字体大小

Parameters ​

FontSize number大小

glyph
​

• get glyph(): UIFontGlyph client

• set glyph(inGlyph): void client

获取字体字形

Returns ​

UIFontGlyph字体字形

设置字体字形

Parameters ​

inGlyph UIFontGlyph字体字形的类型

onClose
​

• get onClose(): MulticastDelegate<(isSuccess: boolean) => void> client

用户手动关闭广告的回调

Returns ​

MulticastDelegate<(isSuccess: boolean) => void>返回事件的代理

onShow
​

• get onShow(): MulticastDelegate<(isReady: boolean) => void> client

点击按钮的回调,播放广告前执行

Returns ​

MulticastDelegate<(isReady: boolean) => void>返回事件的代理

outlineColor
​

• get outlineColor(): LinearColor client

• set outlineColor(inOutlineColor): void client

获取字体描边颜色

Returns ​

LinearColor字体描边颜色,Type.LinearColor类型,数据范围0~1

设置字体描边颜色

Parameters ​

inOutlineColor LinearColor描边颜色,Type.LinearColor类型,数据范围0~1

outlineSize
​

• get outlineSize(): number client

• set outlineSize(inOutlineSize): void client

获取字体描边宽度

Returns ​

number字体描边宽度

设置字体描边宽度

Parameters ​

inOutlineSize number设置的大小

shadowColor
​

• get shadowColor(): LinearColor client

• set shadowColor(inShadowColor): void client

获取字体阴影颜色

Returns ​

LinearColor字体阴影颜色,Type.LinearColor类型,数据范围0~1

设置字体阴影颜色

Parameters ​

inShadowColor LinearColor输入的颜色,Type.LinearColor类型,数据范围0~1

shadowOffset
​

• get shadowOffset(): Vector2 client

• set shadowOffset(inOffset): void client

获取字体阴影偏移

Returns ​

Vector2字体阴影偏移

设置字体阴影偏移

Parameters ​

inOffset Vector2阴影偏移量

strikethroughEnable
​

• get strikethroughEnable(): boolean client

• set strikethroughEnable(inEnableStrikethrough): void client

获取是否开启字体删除线

Returns ​

boolean是否开启字体删除线

设置是否开启字体删除线

Parameters ​

inEnableStrikethrough boolean是否开启

text
​

• get text(): string client

• set text(InString): void client

获取按钮文字

Returns ​

string返回文字

设置按钮文字

Parameters ​

InString string文字

新文本


textAlign
​

• get textAlign(): TextJustify client

• set textAlign(InTextJustify): void client

获取字体对齐方式

Returns ​

TextJustify字体对齐方式

设置字体对齐方式

Parameters ​

InTextJustify TextJustify对齐方式的枚举

textVerticalAlign
​

• get textVerticalAlign(): TextVerticalJustify client

• set textVerticalAlign(inTextVerticalJustify): void client

获取字体垂直对齐方式

Returns ​

TextVerticalJustify字体垂直对齐方式

设置字体垂直对齐方式

Parameters ​

inTextVerticalJustify TextVerticalJustify对齐方式

underlineEnable
​

• get underlineEnable(): boolean client

• set underlineEnable(inEnableUnderline): void client

返回是否开启字体下划线

Returns ​

boolean获取是否开启字体下划线

设置是否开启字体下划线

Parameters ​

inEnableUnderline boolean设置是否开启下划线

Methods ​


addKey
​

• addKey(key): void client

同一按键同时只能操控一个UI控件,最新绑定的UI控件会覆盖之前的绑定;脚本中添加的绑定无法覆盖编辑器按键绑定菜单中绑定相同按键的UI控件,但当两个UI控件分别通过代码和菜单绑定到同一按键时,使用代码绑定的优先级更高

Parameters ​

key Keys按键

getKeys
​

• getKeys(): Keys[] client

获取当前UI控件绑定的所有键盘按键,包括编辑器按键绑定菜单和用代码绑定的按键

Returns ​

Keys[]返回当前控件绑定的按键,可能为空

removeKey
​

• removeKey(key): void client

此操作只会解绑动态绑定的按键无法解除编辑器按键绑定菜单中绑定的按键

Parameters ​

key Keys按键

newObject
​

• Static newObject(parent?, inName?): AdsButton client

创建 Button 控件

Parameters ​

parent? Canvas创建控件的外parent对象 default: null
inName? string创建控件的名称 default:null range:设置合理的名称即可

Returns ​

AdsButton返回创建的对象

当parent和inName与已有的对象相同时,旧的对象会被销毁