기술 자료

​
​

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

SDK Event class

Learn how to extend the Event class to create type-safe custom event implementations in your code.
읽는 시간 2분
최근 업데이트: 9달 전

The Unity Analytics SDK is designed to help you match your game code with your event schemas as defined in the dashboard. While Analytics provides helper classes for all of the standard events that you might encounter, you must make your own helper classes to support the custom events that are unique to your game. This is done through making sub-classes of the abstract
Event
class, giving you type safety when working with the same event across multiple locations, and can help you to prevent validation errors when the events are uploaded.
While the
Event
class is primarily a container for passing data into the Analytics SDK, it also offers some advanced functions. You may also provide additional functionality through extending the
Validate()
and
Reset()
methods.

Validate

The
Validate()
method is called just before event serialization and can be used during development to check locally whether an event matches its schema or not. For example, many of the standard events offered by the SDK display warnings if they are missing required fields using this method. You can also prevent an invalid event from being recorded at all by throwing an exception inside
Validate()
.
Note that events that are recorded and uploaded are validated more thoroughly by the back-end, so take care in allowing invalid events to get through so that they are visible outside the application itself. This mechanism is primarily intended to provide fast feedback to assist initial implementation and debugging, where a loud failure may be useful.
protected override void Validate(){ base.Validate(); if (!ParameterHasBeenSet("requiredParameter")) { Debug.LogWarning("A value for requiredParameter must be set!"); // Event will be recorded but a warning will be displayed in the log. } if (!ParameterHasBeenSet("doubleRequiredParameter")) { throw new Exception("A value for doubleRequiredParameter REALLY must be set!"); // Event will not be recorded at all. }}

Reset

The
Event
class is designed to be pooled, so you can create a single instance and re-use it for the entire application lifecycle. Once an
Event
has been serialized to the Analytics buffer, the
Reset
method is invoked to clear the
Event
of all its parameters, returning it to a blank state for re-use.
If you added any extra logic or fields of your own to your sub-class and want to make use of object pooling, you must extend the
Reset
method to clear up any additional state you might have accumulated.
public override void Reset(){ base.Reset(); m_MyExtraSystemValue = null;}

Copyright © 2026 Unity Technologies
법률 정보개인정보 처리방침쿠키Documentation Terms of Use개인 정보 판매 또는 공유 금지개인정보 보호 선택(쿠키 설정)

'Unity', Unity 로고 및 기타 Unity 상표는 미국 및 기타 지역 내 Unity Technologies 또는 그 계열사의 상표 또는 등록상표입니다(자세한 내용은 여기에서 확인하세요). 기타 명칭 또는 브랜드는 해당 소유자의 상표입니다.

일부 페이지는 편의를 위해 기계 번역되었으며 부정확한 내용이 있을 수 있습니다. 정보가 상충되는 경우, 영어 버전을 우선으로 참조하세요.

  • 보고 있는 페이지
    • Validate

    • Reset


이 페이지의 문제 보고