Skip to content

Button(JavaScript) ​

Button ​

Scripting Name:Insight.Button

按钮。

Properties ​


colors ​

type : Insight.ColorBlock

(只读)该按钮的 ColorBlock。

interactable ​

type :boolean

按钮是否可交互。

spriteState ​

type : Insight.SpriteState

(只读)按钮的 Sprite 状态。

Methods ​


tostring ​

public string toString(Button button);

将 button 内容以一定格式转为 string 类型。

Static Methods ​


AddClick ​

public static void addClick( Insight.Button button, module_instance, func );

注册点击监听事件。

Parameters

  • button : Insight.Button 要注册点击事件的按钮
  • module_instance 脚本本身实例
  • func 回调的 js 方法
//sample:
self.button = Insight.GameObject.find( "ExampleButton" ).getComponent("Button");Insight.Button.AddClick( self.button, self, self.onClick);var onClick = function(){        Insight.Debug.Log("Button Clicked");}

Inherited Properties(继承自 Component) ​


enabled ​

type : boolean

该组件是否是可用的。

gameObject ​

type :Insight.GameObject

(只读)该组件所依附的 GameObject。

isActiveAndEnabled ​

type : boolean

(只读)该组件是否可用,且其依附的 GameObject 是否是活跃状态。

name ​

type : string

(只读)所依附的 GameObject 的名称。

tag ​

type : string

(只读)所依附的 GameObject 的 Tag。

⚠️ 暂时未启用

transform ​

type : Insight.Transform

(只读)所依附的 GameObject 的 transform。

Messages (仅 Unity 和 Native 使用) ​


OnPointerDown ​

手指按下事件

var OnPointerDown = function(){    Insight.Debug.Log( "JS ButtonClick Update: GetPointerDown\n" );}

OnPointerUp ​

手指抬起事件

var OnPointerUp = function(){    Insight.Debug.Log( "JS ButtonClick Update: GetPointerUp\n" );}