跳转至

AssetSetCommandCBFunc

格式

AssetSetCommandCBFunc(asset, callback)

简介

当资源类的资源对象收到广播时执行回调函数,广播的发送详见SendCommand

参数

名称 类型 描述
asset 资源类
callback 回调函数

实例

当收到广播为"A"时打印123。

import fg

asset = fg.AssetCreate()
asset.name = 'Main Scene'
asset.state = fg.STATE.VOXMODEL
asset.vmFile = 'mainScene'
asset.icon='icon.png'

fg.AssetRegister(asset)

def onStart(self):
    fg.SendCommand("A")

def onCommands(self,command):
    if command=="A":
        print(123)
    pass

fg.AssetSetStartCBFunc(asset, onStart)
fg.AssetSetCommandCBFunc(asset, onCommands)