UNPKG

com.phantomsxr.xrmodpackagetools

Version:

XR-MOD is a derivative based on Unity ARFoundation. Using the technical concept of MOD in the game allows XR creators to develop their own AR creative interactive experience. This tool is an extension of XR-MOD, used to generate XR-MOD identifiable resour

84 lines (73 loc) 3.09 kB
// // /*=============================================================================== // // 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<string> HelloTextBindable = new BindableProperty<string>(); /// <summary> /// XRMOD Engine API. /// </summary> internal API XRMODAPI; /// <summary> /// Localization system /// </summary> 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<TextAsset>("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 } /// <summary> /// Exit current experience(or quit app) /// </summary> /// <param name="_quitApplication">True to quit app</param> internal void Exit(bool _quitApplication = false) { if (!_quitApplication) XRMODAPI.ReleaseProject(nameof(#NAMESPACE#)); else Application.Quit(); } public void Dispose() { localizationManager = null; } } }