// // /*=============================================================================== // // Copyright (C) 2024 PhantomsXR Ltd. All Rights Reserved. // // // // This file is part of the Phantom.XRMOD.PackageTools.Editor. // // // // The AVPPlatform cannot be copied, distributed, or made available to // // third-parties for commercial purposes without written permission of PhantomsXR Ltd. // // // // Contact info@phantomsxr.com for licensing requests. // // ===============================================================================*/ using System; using UnityEngine; using UnityEngine.Assertions; using Phantom.XRMOD.XRMODAPI.Runtime; using Phantom.XRMOD.Localization.Runtime; namespace #NAMESPACE#.Runtime { public class SharedData : IDisposable { private static SharedData _SHARED_DATA; public static SharedData GetInstance => _SHARED_DATA ??= new SharedData(); // Add your fields below. // e.g. public string HelloText = "Hello Text"; // e.g. public BindableProperty HelloTextBindable = new BindableProperty(); /// /// XRMOD Engine API. /// internal API XRMODAPI; /// /// Localization system /// internal LocalizationManager localizationManager = LocalizationManager.Instance; private SharedData() { XRMODAPI = new API(nameof(#NAMESPACE#)); PrepareAssets(); } private async void PrepareAssets() { // If the language does not exist in the localization table, set default to English. var tmp_CurrentSystemLanguage = Application.systemLanguage; if (tmp_CurrentSystemLanguage != SystemLanguage.ChineseSimplified && tmp_CurrentSystemLanguage != SystemLanguage.English) { tmp_CurrentSystemLanguage = SystemLanguage.English; } var tmp_LocalizationTableAsset = await XRMODAPI.LoadAssetAsync("LocalizationTable"); Assert.IsNotNull(tmp_LocalizationTableAsset,"Localization table asset can not empty."); localizationManager.Initialized(nameof(#NAMESPACE#), tmp_LocalizationTableAsset.bytes, tmp_CurrentSystemLanguage.ToString(), AvailablePlace.InExperiences); } internal async void LoadAssets() { // Load your assets in here } /// /// Exit current experience(or quit app) /// /// True to quit app internal void Exit(bool _quitApplication = false) { if (!_quitApplication) XRMODAPI.ReleaseProject(nameof(#NAMESPACE#)); else Application.Quit(); } public void Dispose() { localizationManager = null; } } }