This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Runtime.InteropServices; | |
| using UnityEngine.UI; | |
| using UnityEngine; | |
| public class CapsuleController : MonoBehaviour { | |
| [SerializeField] private Vector3 moveUp = new Vector3(0, 1, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UnityGameActivity : UnityPlayerActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| // Do something | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UnityPlayerActivity extends Activity implements IUnityPlayerLifecycleEvents { | |
| protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code | |
| protected String updateUnityCommandLineArguments(String cmdLine) { | |
| return cmdLine; | |
| } | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UnityGameActivity : UnityPlayerActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| mUnityPlayer += MaterialButton(this).apply { | |
| ... | |
| text = "RANDOMIZE COLOR" | |
| setOnClickListener { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Default Locale of your application | |
| val defaultLocale = Locale.getDefault() | |
| // Locale from a given IETF BCP 47 language tag | |
| val localeByTag = Locale.forLanguageTag("fr-CA") | |
| val localeFrCA = Locale("fr", "CA") | |
| // Used as the language/country neutral locale | |
| // for the locale sensitive operations | |
| val root = Locale.ROOT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android { | |
| defaultConfig { | |
| resConfigs "en", "fr", "de" // All supported languages in your app | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Default Locale of your application | |
| val defaultLocale = Locale.getDefault() | |
| // Current Locale of your device | |
| val fLocale = Resources.getSystem().configuration.locales[0] // Since API 24 | |
| val fLocale = ConfigurationCompat.getLocales(Resources.getSystem().configuration)[0] // Compat method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setupWebview() // init and load webview | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
| val res = context.resources | |
| val config = res.configuration | |
| val appLanguage = languageGateWay.getAppLocale() // get app locale from pref, storage... | |
| config.setLocale(appLanguage) | |
| res.updateConfiguration(config, res.displayMetrics) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun attachBaseContext(newBase: Context) { | |
| var base: Context = newBase | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
| val config = resources.configuration | |
| val locales = languageGateWay.getSupportedLocales() | |
| config.setLocales(locales) | |
| base = createConfigurationContext(config) | |
| } | |
| super.attachBaseContext(base) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val nf = NumberFormat.getInstance(Locale.FRENCH) // 89 786,5 | |
| val ne = NumberFormat.getInstance(Locale.ENGLISH) // 89,786.5 | |
| val nc = NumberFormat.getInstance(Locale.CHINESE) // 89,786.5 | |
| val nroot = NumberFormat.getInstance(Locale.ROOT) // 89,786.5 | |
| val cfr = NumberFormat.getCurrencyInstance(Locale.FRANCE) // 67 889 786,50 € | |
| val cen = NumberFormat.getCurrencyInstance(Locale.CANADA_FRENCH) // 67 889 786,50 $ | |
| val cde = NumberFormat.getCurrencyInstance(Locale.GERMANY) // 67.889.786,50 € | |
| val czh = NumberFormat.getCurrencyInstance(Locale.CHINA) // ¥67,889,786.50 | |
| val croot = NumberFormat.getCurrencyInstance(Locale.ROOT) // ¤ 67,889,786.50 |