Table of Contents

Class UtilityModule

Namespace
Titipi.MocaLib2

Shared helpers used internally by all MocaLib2 modules. Provides structured logging, platform identification, app version access, locale detection, device memory-tier classification, and IAP receipt parsing. Always available — no define guard required.

public static class UtilityModule
Inheritance
UtilityModule
Inherited Members

Properties

IsLowRamDevice

Convenience check for Low using the default RAM cutoff. Handy as a keyOverride selector for Resolve<T>(T, string) — e.g. serving a variant config to low-RAM devices.

IsMocaLib2InfoLogEnabled

Whether MocaLib2's informational logs (MocaLib2Log(string, string) — including the entry log every public module method emits) are written to the console. Defaults to true in the Editor and false in builds, so the library is silent on players unless asked; warnings and errors are always logged regardless of this flag.

Methods

DelayedCallAsync(float, Action, bool)

Invokes callback after delay seconds. When ignoreTimeScale is true (default), the wait is based on real time so it is unaffected by Time.timeScale pausing or slow-motion. When false, Unity's scaled time is used via Awaitable.WaitForSecondsAsync.

DisableMocaLib2InfoLog()

Turns MocaLib2's informational logs back off (see EnableMocaLib2InfoLog()). Warnings and errors keep being logged.

EnableMocaLib2InfoLog()

Turns on MocaLib2's informational logs for this session. Named with the MocaLib2 prefix to make clear it only affects logging from inside the library — the game's own Debug.Log output is untouched. Call it as early as possible (e.g. in a #if DEVELOPMENT_BUILD block or from a debug menu) so the entry logs of the first InitializeAsync calls are captured too.

GetAndroidReceiptSignature(string)

Parses a Unity IAP receipt string (from order.Info.Receipt) for an Android purchase and returns the Google Play signature.

GetAppBuildNumber()

Returns the application build number string defined in GameVersionInfo.BUILD_NUMBER.

GetAppVersion()

Returns the application version string defined in GameVersionInfo.BUILD_VERSION.

GetDeviceLocale()

Returns the device's two-letter ISO 3166 region code (e.g. "US", "TH").

GetDeviceMemoryTier(int, int)

Classifies the device into a DeviceMemoryTier from its system RAM (SystemInfo.systemMemorySize, in MB). RAM is the only signal — CPU/GPU performance is not considered, so treat this as a memory bucket, not an overall speed rating. Note: on Android this under-reports physical RAM (OS-reserved memory is excluded), so a nominally 4GB device often reports ~3600MB — the default cutoffs account for that.

GetIOSReceiptPayload(string)

Parses a Unity IAP receipt string (from order.Info.Receipt) for an iOS purchase and returns the raw StoreKit receipt payload.

GetPlatformFriendlyName()

Returns a human-readable platform name for the current runtime (e.g. "Android", "iOS", "Unity Editor (macOS)").

GetUTCString()

Returns the device's UTC offset as a formatted string (e.g. "UTC+7", "UTC-5:30").

Is_iOS_14_5_Or_Higher()

Returns true when running on iOS 14.5 or later. Always false in the editor and on non-iOS platforms.

Is_iOS_17_Or_Higher()

Returns true when running on iOS 17 or later. Always false in the editor and on non-iOS platforms.

MocaLib2Log(string, string)

Logs an informational message prefixed with the MocaLib2 tag and the given module tag. Silent unless IsMocaLib2InfoLogEnabled is true.

MocaLib2LogError(string, string)

Logs an error message prefixed with the MocaLib2 tag and the given module tag.

MocaLib2LogWarning(string, string)

Logs a warning message prefixed with the MocaLib2 tag and the given module tag.

NormalizeTrackingEventName(string)

Normalizes an event name to snake_case, stripping non-alphanumeric characters. Used to produce consistent event names across analytics SDKs.

RunInBackground(Func<Awaitable>)

Runs an async operation fire-and-forget: returns immediately without blocking the caller, and any exception thrown by work is caught and logged instead of being left unobserved. This is the one sanctioned place for async void in MocaLib2 — use it for background work whose completion the caller does not need to await (e.g. warming up the ad SDK during startup without blocking the loading screen).