查看: 1|回复: 0

如何获取Activity的统计信息?

[复制链接]

主题

0

回帖

544

积分

中级会员

积分
544
发表于 2022-11-29 15:17:44 | 显示全部楼层 |阅读模式
[i=s] 本帖最后由 zorsite 于 2022-11-29 15:42 编辑 [/i]

如何获取Activity的统计信息?
3D实体的属性面板中可以查看统计信息。

同时可以通过Object.stats属性来获取相关信息。

Activity也有属性面板

但是Activity却没有stats属性,无法通过属性获取统计信息。

原因在于当我们使用current关键字的时候,current被声明为Object对象,而activity被声明为treenode对象。
treenode作为Object的父类,其属性和方法不如其子类Object那样丰富。

作为treenode的子类,Object对象除了有treenode的属性外,还具有以下属性:

其中就有stats属性,可以获取统计信息。

那如何使用代码获取Activity的统计信息呢?
第1种方法,使用getstat命令。
getstat (node object, str name, int flag [, var p1, var p2, var p3])
Returns the statistic value for the given objectDescription
It is preferred to use Object.stats instead. Gets the specified statistic from the given object.
Example:
[code]getstat(activity, "Content", STAT_CURRENT)[/code][code]getstat(activity, "Input", STAT_CURRENT)[/code][code]getstat(activity, "Staytime", STAT_AVERAGE)[/code]
[code]double avgContent = getstat(
// getstat requires between 4 and 6 parameters:
activity, // 1. the object (shared asset or activity) that has the statistic
"Content", // 2. the name of the statistic
STAT_AVERAGE, // 3. the desired value from the statistic (could also be STAT_CURRENT, STAT_MIN, or STAT_MAX)
// 4. an optional parameter the instance object (usually current)
// 5. an additional parameter to help resolve which data to get
// 6. an additional parameter to help resolve which data to get
);[/code]
第2种方法,转换activity的类型。
既然Object对象有stats属性,那把activity从treenode类型转换为Object类型不就可以了?
转换的方式有2种:
方法1,使用as关键字:
[code]activity.as(Object).stats.input.value;
[/code]
方法2,将activity声明为Object类型的变量:
[code]Object Obj_activity=activity;
return Obj_activity.stats.input.value;[/code]







本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:admin@discuz.vip

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|京ICP备14043114号-2

在本版发帖
关注公众号
QQ客服返回顶部