Skip to main content

RealTime

Important Attention Reminder

Coding Style wiki​


RealTime is a static utility that records the application startup time. The main program (a Main MonoBehaviour Awake) calls InitStartupTime() to initialize it (only the first call takes effect); afterwards the startup time can be read from timeSinceStartup, serving as a global game startup time base.

NamespaceOxGKit.TimeSystem
Typepublic static class RealTime
SourceRealTime.cs
using OxGKit.TimeSystem;

Quick Start​

using OxGKit.TimeSystem;
using UnityEngine;

public class Main : MonoBehaviour
{
private void Awake()
{
// Initialized by the main program at startup (first call only)
RealTime.InitStartupTime();
}

private void Start()
{
if (RealTime.IsInitStartupTime())
{
// Read the game startup time
System.DateTime startup = RealTime.timeSinceStartup;
}
}
}

Reminder Call InitStartupTime() at main program startup so the recorded value is the actual game startup time.


Members​

MemberDescription
public static DateTime timeSinceStartup { get; }The application startup time (system time recorded by InitStartupTime).

Methods​

Method Overview​

MethodDescription
InitStartupTimeInitializes the startup time (first call only).
IsInitStartupTimeChecks whether the startup time has been initialized.

InitStartupTime​

public static void InitStartupTime()

Records the current system time (DateTime.Now) as the startup time; only the first call takes effect — subsequent calls are ignored.

IsInitStartupTime​

public static bool IsInitStartupTime()

Checks whether the startup time has been initialized; if not, a log hint is printed (Please call RealTime.InitStartupTime() in main program first) and false is returned.