public float GetAdHeightInPercentage() { // calculate the percentage of the screen that the banner takes up float bannerPercent = 0.09f; #if UNITY_IPHONE && !UNITY_EDITOR float scale = 1.0f; if (Screen.dpi > 163.0f) { // every device with a dpi over 163 is retina scale = 2.0f; } float bannerHeight = _psdkMgr.GetBannersService().GetAdHeight(); float pointsHeight = Screen.height / scale; bannerPercent = bannerHeight / pointsHeight; PsdkUtils.NativeLog(" ScreenDPI: " + Screen.dpi.ToString() + " Banner Height: " + bannerHeight.ToString() + " Screen Height: " + Screen.height.ToString() + " Banner Percent: " + bannerPercent.ToString()); #elif UNITY_ANDROID float bannerHeight = _psdkMgr.GetBannersService().GetAdHeight(); float bannerScale = Screen.dpi / 160.0f; bannerPercent = (bannerHeight * bannerScale) / Screen.height; Debug.Log(" ScreenDPI: " + Screen.dpi.ToString() + " BannerScale: " + bannerScale.ToString() + " Banner Height: " + bannerHeight.ToString() + " Screen Height: " + Screen.height.ToString() + " Banner Percent: " + bannerPercent.ToString()); #elif UNITY_EDITOR bannerPercent = 0.06578948F; #endif return(bannerPercent); }
static string psdkVersions() { string versions = ""; try { string versionsFile = "psdk"; versionsFile = System.IO.Path.Combine(versionsFile, "versions"); versionsFile = System.IO.Path.Combine(versionsFile, "versions.txt"); versions = PsdkUtils.ReadStreamingAssetsFile(versionsFile); } catch (System.Exception e) { Debug.LogException(e); } return(versions); }
static PsdkInternalSettingsData CreateMySeriliazbleDataObject() { //AssetDatabase.DeleteAsset(PsdkSerializedData.ASSET_PATH); PsdkInternalSettingsData asset = AssetDatabase.LoadAssetAtPath(PsdkInternalSettingsData.ASSET_PATH, typeof(PsdkInternalSettingsData)) as PsdkInternalSettingsData; if (asset == null) // Didn't found asset, create one { asset = PsdkInternalSettingsData.CreateInstance <PsdkInternalSettingsData>(); if (asset == null) { return(null); } string dir = System.IO.Path.GetDirectoryName(PsdkInternalSettingsData.ASSET_PATH); string parentDir = System.IO.Path.GetDirectoryName(dir); if (!System.IO.Directory.Exists(dir)) { AssetDatabase.CreateFolder(parentDir, "Resources"); } AssetDatabase.CreateAsset(asset, PsdkInternalSettingsData.ASSET_PATH); } if (!asset.socialGamePackage) { try { string psdkJson = PsdkUtils.ReadPsdkConfigFromFile(); IDictionary <string, object> dict = TabTale.Plugins.PSDK.Json.Deserialize(psdkJson) as IDictionary <string, object>; if (dict != null) { if (dict.ContainsKey("socialGame") && (bool)(dict ["socialGame"] as IDictionary <string, object>) ["included"]) { UnityEngine.Debug.Log("Updating PsdkInternalSettings.socialGame=true according to psdk.json"); asset.socialGamePackage = true; } } else { Debug.LogError("PSDK json dict is null, no updating PsdkInternalSettings.socialGame"); } } catch (System.Exception e) { Debug.LogException(e); } } return(asset); }