文档

​
​

Development

User Acquisition

Monetization

工业

Analytics

Unity SDK

Client API

Analytics

此页面不支持所选语言。
LiveOps
​
​
Analytics
  • Overview
  • Get started
  • Pricing
  • Concepts
  • Tutorials
  • Reference
    • Standard events
    • Standard audiences
    • Reserved parameter names
    • Data Explorer V1 metrics
    • Data Explorer V2 measures and metrics
    • SDK Event class
    • SDK CustomEvent class
    • SDK behavior
    • SQL Data Explorer queryable tables
    • SQL Data Explorer cookbook
    • Data Access available views
    • Glossary
  • Privacy and consent
  • FAQ
  1. Unity Analytics

The CustomEvent class

Use the generic CustomEvent class to record events without creating dedicated event classes.
阅读时间1 分钟
最后更新于 7 个月前

For simplicity and quick turn-around, the Analytics SDK offers a generic
CustomEvent
class that you can use for any custom event in a very similar way to the plain dictionary API used in earlier SDK versions. This comes at the cost of the type safety and validation options offered by using dedicated sub-classes for each type of event, but may be useful during migration or prototyping.
CustomEvent myEvent = new CustomEvent("MyEvent"){ { "fabulousString", "woah!" }, { "peculiarBool", true }, { "sparklingInt", 1337 }, { "spectacularFloat", 313.37f }, { "timelessTimestamp", DateTime.Now }};AnalyticsService.Instance.RecordEvent(myEvent);
警告
Although the parameter values are taken in as
object
type, values must actually be one of the following types:
string
,
int
,
long
,
float
,
double
,
bool
or
DateTime
. If you attempt to add a value of an unsupported type, the
CustomEvent
class throws an
ArgumentException
.
DateTime
support was introduced in version 6.2.0 of the SDK.

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。


    报告此页面的问题