// Unity fires off this function void Awake() { // save main thread Id mainThread = System.Threading.Thread.CurrentThread; // used for float.TryParse mainThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; mainThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; // Set specific configuration for Android if (Application.platform == RuntimePlatform.Android) { // activate crashlytics DebugManager.Enable(); // deactivate screen timeount while in Valkyrie Screen.sleepTimeout = SleepTimeout.NeverSleep; } // Find the common objects we use. These are created by unity. cc = GameObject.FindObjectOfType <CameraController>(); uICanvas = GameObject.Find("UICanvas").GetComponent <Canvas>(); boardCanvas = GameObject.Find("BoardCanvas").GetComponent <Canvas>(); tokenCanvas = GameObject.Find("TokenCanvas").GetComponent <Canvas>(); tokenBoard = GameObject.FindObjectOfType <TokenBoard>(); heroCanvas = GameObject.FindObjectOfType <HeroCanvas>(); monsterCanvas = GameObject.FindObjectOfType <MonsterCanvas>(); // Create some things uiScaler = new UIScaler(uICanvas); config = new ConfigFile(); GameObject go = new GameObject("audio"); audioControl = go.AddComponent <Audio>(); updateList = new List <IUpdateListener>(); stats = new StatsManager(); stats.DownloadStats(); if (config.data.Get("UserConfig") == null) { // English is the default current language config.data.Add("UserConfig", "currentLang", "English"); config.Save(); } currentLang = config.data.Get("UserConfig", "currentLang"); string vSet = config.data.Get("UserConfig", "editorTransparency"); if (vSet == "") { editorTransparency = 0.3f; } else { float.TryParse(vSet, out editorTransparency); } string s_debug_tests = config.data.Get("Debug", "tests"); if (s_debug_tests != "") { s_debug_tests = s_debug_tests.ToLower(); if (s_debug_tests == "true" || s_debug_tests == "1") { debugTests = true; } } // On android extract streaming assets for use if (Application.platform == RuntimePlatform.Android) { System.IO.Directory.CreateDirectory(ContentData.ContentPath()); using (ZipFile jar = ZipFile.Read(Application.dataPath)) { foreach (ZipEntry e in jar) { if (!e.FileName.StartsWith("assets")) { continue; } if (e.FileName.StartsWith("assets/bin")) { continue; } e.Extract(ContentData.ContentPath() + "../..", ExtractExistingFileAction.OverwriteSilently); } } } DictionaryI18n valDict = new DictionaryI18n(); foreach (string file in System.IO.Directory.GetFiles(ContentData.ContentPath() + "../text", "Localization*.txt")) { valDict.AddDataFromFile(file); } LocalizationRead.AddDictionary("val", valDict); roundControl = new RoundController(); // Read the version and add it to the log TextAsset versionFile = Resources.Load("version") as TextAsset; version = versionFile.text.Trim(); // The newline at the end stops the stack trace appearing in the log ValkyrieDebug.Log("Valkyrie Version: " + version + System.Environment.NewLine); #if UNITY_STANDALONE_WIN SetScreenOrientationToLandscape(); #endif // Bring up the Game selector gameSelect = new GameSelectionScreen(); }