public static void Init() { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); if (jc == null) return; AndroidJavaObject joactivety = jc.GetStatic<AndroidJavaObject>("currentActivity"); if (joactivety == null) return; AndroidJavaObject context = joactivety.Call<AndroidJavaObject>("getApplicationContext"); // 初始化HttpDns AndroidJavaObject joDnsClass = new AndroidJavaObject("com.tencent.msdk.dns.MSDKDnsResolver"); Debug.Log(" WGGetHostByName ===========" + joDnsClass); if (joDnsClass == null) return; m_dnsJo = joDnsClass.CallStatic<AndroidJavaObject>("getInstance"); Debug.Log(" WGGetHostByName ===========" + m_dnsJo); if (m_dnsJo == null) return; m_dnsJo.Call("init", context); // 初始化灯塔 AndroidJavaObject joBeaconClass = new AndroidJavaObject("com.tencent.beacon.event.UserAction"); if (joBeaconClass == null) return; m_dnsJo.Call("initUserAction", context); }
public override AndroidJavaObject toAndroidJavaObject(AndroidJavaObject jniUnityStoreAssets) { AndroidJavaObject jniHashMap = jniUnityStoreAssets.CallStatic<AndroidJavaObject>("createStringIntegerHashMap"); foreach(KeyValuePair<string, int> kvp in currencyValue) { jniUnityStoreAssets.CallStatic("voidPutIntoStringIntegerHashMap", jniHashMap, kvp.Key, kvp.Value); } return new AndroidJavaObject("com.soomla.store.domain.data.StaticPriceModel", jniHashMap); }
public override AndroidJavaObject toAndroidJavaObject(AndroidJavaObject jniUnityStoreAssets) { AndroidJavaObject jniArrayListHashMap = jniUnityStoreAssets.CallStatic<AndroidJavaObject>("createStringIntegerHashMapArrayList"); foreach(Dictionary<string, int> curval in currencyValuePerBalance) { AndroidJavaObject jniHashMap = jniUnityStoreAssets.CallStatic<AndroidJavaObject>("createStringIntegerHashMap"); foreach(KeyValuePair<string, int> kvp in curval) { jniUnityStoreAssets.CallStatic("voidPutIntoStringIntegerHashMap", jniHashMap, kvp.Key, kvp.Value); } jniArrayListHashMap.Call<bool>("add", jniHashMap); } return new AndroidJavaObject("com.soomla.store.domain.data.BalanceDrivenPriceModel", jniArrayListHashMap); }
public void Report(string json) { using (AndroidJavaObject reportWrapper = new AndroidJavaObject("com.fyber.unity.reporters.ReporterWrapper")) { reportWrapper.CallStatic("report", json); } }
public void Settings(string json) { using (AndroidJavaObject settingsWrapper = new AndroidJavaObject("com.fyber.unity.settings.SettingsWrapper")) { settingsWrapper.CallStatic("perform", json); } }
public AndroidJavaObject toAndroidJavaObject(AndroidJavaObject jniUnityStoreAssets) { return jniUnityStoreAssets.CallStatic<AndroidJavaObject>("createVirtualCategory" , this.Name , this.Id , this.Equipping.toInt()); }
public AndroidJavaObject toAndroidJavaObject(AndroidJavaObject jniUnityStoreAssets) { return jniUnityStoreAssets.CallStatic<AndroidJavaObject>("createGoogleMarketItem" , this.ProductId , (int)(this.consumable) , this.Price); }
public void Cache(string action) { using (AndroidJavaObject cacheManager = new AndroidJavaObject("com.fyber.unity.cache.CacheWrapper")) { cacheManager.CallStatic(action); } }
public void StartAd(string json) { using (AndroidJavaObject adWrapper = new AndroidJavaObject("com.fyber.unity.ads.AdWrapper")) { adWrapper.CallStatic("start", json); } }
public void EnableLogging(bool shouldLog) { //com.fyber.utils.FyberLogger.enableLogging using (AndroidJavaObject logger = new AndroidJavaObject("com.fyber.utils.FyberLogger")) { logger.CallStatic<bool>("enableLogging", shouldLog); } }
void Start() { #if UNITY_ANDROID AndroidJNI.AttachCurrentThread(); jc = new AndroidJavaClass("com.android.plava.spiderspy.CallStatusBridge"); jc.CallStatic("setCallBack", new object[2] {gameObject.name, "OnCallStateChange"}); #endif }
public void GetImageFromGallery() { loader.enableLoader (); AndroidJNI.AttachCurrentThread (); AndroidJavaClass unity = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"); AndroidJavaObject profClass = new AndroidJavaObject ("com.gamedonia.medical.UnityBinder"); profClass.CallStatic ("OpenGallery", unity.GetStatic<AndroidJavaObject> ("currentActivity")); }
public static void Init(string wechatID) { Debug.Log("Unity Init"); if (Application.platform == RuntimePlatform.Android) { var pluginClass = new AndroidJavaClass("com.yym.wechatplugin.WeChatPlugin"); shareItem = pluginClass.CallStatic<AndroidJavaObject>("instance"); shareItem.CallStatic("_initWeChat", wechatID); } }
public static string GetAndroidAdMobID() { UnityEngine.AndroidJavaClass up = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); UnityEngine.AndroidJavaObject currentActivity = up.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"); UnityEngine.AndroidJavaObject contentResolver = currentActivity.Call <UnityEngine.AndroidJavaObject>("getContentResolver"); UnityEngine.AndroidJavaObject secure = new UnityEngine.AndroidJavaObject("android.provider.Settings$Secure"); string deviceID = secure.CallStatic <string>("getString", contentResolver, "android_id"); return(Md5Sum(deviceID).ToUpper()); }
public void Awake() { if(Application.platform == RuntimePlatform.Android) { UnityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); UnityJavaContext = UnityClass.GetStatic<AndroidJavaObject>("currentActivity"); AndroidMediaAccess = new AndroidJavaClass("com.bitera.rytmos.MediaAccessActivity"); AndroidMediaAccess.CallStatic("initContext",UnityJavaContext); } }
private static void initialize() { #if UNITY_ANDROID && !UNITY_EDITOR unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); unityRootActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"); speechActivityClass = new AndroidJavaClass("com.ntx24.speechservice.speechservice.SpeechController"); speechActivityClass.CallStatic("StartSpeechFragment", unityRootActivity); #endif smInitialized = true; }
void initStore() { cls_StorePurchaser = new AndroidJavaClass("com.storetest.StorePurchaser"); using (AndroidJavaClass cls = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (AndroidJavaObject obj_Activity = cls.GetStatic<AndroidJavaObject>("currentActivity")) { cls_StorePurchaser.CallStatic("initStore", obj_Activity, publicAndroidKey); } } }
public void StartSDK(string json) { using (AndroidJavaClass mediationStarter = new AndroidJavaClass("com.fyber.mediation.MediationAdapterStarter")) { FyberSettings settings = FyberSettings.Instance; mediationStarter.CallStatic("setup", settings.BundlesInfoJson(), settings.BundlesCount()); } using (AndroidJavaClass mediationStarter = new AndroidJavaClass("com.fyber.mediation.MediationConfigProvider")) { FyberSettings settings = FyberSettings.Instance; mediationStarter.CallStatic("setup", settings.BundlesConfigJson()); } using (AndroidJavaObject plugin = new AndroidJavaObject("com.fyber.unity.FyberPlugin")) { plugin.CallStatic("setPluginParameters", Fyber.Version, Application.unityVersion); plugin.CallStatic("start", json); } }
public VirtualCategory(AndroidJavaObject jniVirtualCategory) { this.Name = jniVirtualCategory.Call<string>("getName"); using(AndroidJavaObject jniItemIds = jniVirtualCategory.CallStatic<AndroidJavaObject>("getGoodsItemIds")) { for(int i=0; i<jniItemIds.Call<int>("size"); i++) { using(AndroidJavaObject jniItemId = jniItemIds.Call<AndroidJavaObject>("get", i)) { GoodItemIds.Add(jniItemId.Call<string>("toString")); } } } }
// Use this for initialization void Start () { #if UNITY_ANDROID AndroidJavaObject nativeObj = new AndroidJavaObject("com.ariequ.alarm.AlarmReceiver"); if (nativeObj != null) { Debug.Log("get AlarmReceover"); } nativeObj.CallStatic("startAlarm", new object[5]{"title","title", "msg", 10, 1}); #endif }
public static bool UPvr_CallStaticMethod(UnityEngine.AndroidJavaObject jobj, string name, params object[] args) { try { jobj.CallStatic(name, args); return(true); } catch (AndroidJavaException e) { Debug.LogError("CallStaticMethod Exception calling activity method " + name + ": " + e); return(false); } }
public static string GetVersion() { #if UNITY_EDITOR return PlayerSettings.bundleVersion; #elif UNITY_IOS return GetVersionName_(); #elif UNITY_ANDROID AndroidJavaObject ajo = new AndroidJavaObject("net.sanukin.UniVersionManager"); return ajo.CallStatic<string>("GetVersionName"); #else return "0"; #endif }
void OnGUI() { if (GUI.Button(new Rect(5, 5, 300, 100), "Send Notification in 5 seconds")) { #if UNITY_ANDROID && !UNITY_EDITOR //send notification here AndroidJavaObject ajc = new AndroidJavaObject("com.zeljkosassets.notifications.Notifier"); ajc.CallStatic("sendNotification", "Test Name", "Test Title", "Test Label", 5); #else Debug.LogWarning("This asset is for Android only. It will not work inside the Unity editor!"); #endif } }
public static bool IsSupported(int width, int height, float framerate) { #if UNITY_EDITOR return(true); #elif UNITY_IPHONE return(isVideoSupportedFormat(width, height, framerate)); #elif UNITY_ANDROID var jo = new UnityEngine.AndroidJavaObject("asus4.videosupportedplugin.VideoSupportedPlugin"); return(jo.CallStatic <bool>("isVideoSupportedFormat", width, height, framerate)); #else Debug.LogError("Not supported platform"); return(false); #endif }
public static void PostMessage(ServiceType type, string text, string url) { string packageName = string.Empty; if(type.Equals(ServiceType.Twitter)){ packageName = "com.twitter.android"; }else if (type.Equals(ServiceType.Facebook)){ packageName = "com.facebook.katana"; } AndroidJavaObject intent = new AndroidJavaObject ( "android.content.Intent" ); intent.Call<AndroidJavaObject> ( "setPackage", packageName ); intent.Call<AndroidJavaObject> ( "setType", "text/plain" ); intent.Call<AndroidJavaObject> ( "putExtra", "android.intent.extra.TEXT" , text + "\t" + url ); activity.Call ("startActivity", intent.CallStatic<AndroidJavaObject>( "createChooser", intent, "Sorry" )); intent.Dispose (); }
private void OnGUI() { jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); if (GUI.Button(new Rect(0, 0, 200, 150), "SelectImage")) { //Create new java class instance and activity //Call function from MyPlugin jo.Call("getImageLoc"); } if (GUI.Button(new Rect(200, 0, 200, 150), "SelectImage")) { //Create new java class instance and activity //Call function from MyPlugin string b = jo.CallStatic<string>("returnImageLoc"); //jo.Call("showMessage", b); } }
public void Start () { switch (traceFormat) { case "json": this.traceFormatter = new SimpleJsonFormat (); break; case "xapi": this.traceFormatter = new XApiFormat (); break; default: this.traceFormatter = new DefaultTraceFromat (); break; } switch (storageType) { case "net": storage = new NetStorage (this, host, trackingCode); break; default: String path = Application.persistentDataPath; #if UNITY_ANDROID AndroidJavaObject env = new AndroidJavaObject("android.os.Environment"); AndroidJavaObject file = env.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"); path = file.Call<String>("getAbsolutePath"); #endif if (!path.EndsWith ("/")) { path += "/"; } path += "traces"; if (debug) { Debug.Log ("Storing traces in " + path); } storage = new LocalStorage (path); break; } storage.SetTracker (this); this.startListener.SetTraceFormatter (this.traceFormatter); this.Connect (); this.nextFlush = flushInterval; UnityEngine.Object.DontDestroyOnLoad (this); }
private static void _Share(string text, string url, string textureUrl) { using (var intent = new AndroidJavaObject ("android.content.Intent")) { intent.Call<AndroidJavaObject> ("setAction", "android.intent.action.SEND"); intent.Call<AndroidJavaObject> ("setType", string.IsNullOrEmpty (textureUrl) ? "text/plain" : "image/png"); if (!string.IsNullOrEmpty (url)) text += "\t" + url; if (!string.IsNullOrEmpty (text)) intent.Call<AndroidJavaObject> ("putExtra", "android.intent.extra.TEXT", text); if (!string.IsNullOrEmpty (textureUrl)) { var uri = new AndroidJavaClass ("android.net.Uri"); var file = new AndroidJavaObject ("java.io.File", textureUrl); intent.Call<AndroidJavaObject> ("putExtra", "android.intent.extra.STREAM", uri.CallStatic<AndroidJavaObject> ("fromFile", file)); } var chooser = intent.CallStatic<AndroidJavaObject> ("createChooser", intent, ""); chooser.Call<AndroidJavaObject> ("putExtra", "android.intent.extra.EXTRA_INITIAL_INTENTS", intent); activity.Call ("startActivity", chooser); } }
void Start() { m_establishOriginal = m_establishPanel.transform.position; m_joinOriginal = m_joinPanel.transform.position; AndroidJavaClass ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ajo = new AndroidJavaObject("com.XavierStudio.PickPhoto.UnityBinder"); ajo.CallStatic("StartUtility", new object[]{ ajc.GetStatic<AndroidJavaObject>("currentActivity"), "GET_IP"}); galleryImage = new Texture2D(1, 1); string path = XMLConsole.Read(GameManager.GetXMLPath(), "/Root/UserInfo", "Avatar"); if (path != "NULL") { WWW www; www = new WWW("file://" + path);//start downloading that image while (!www.isDone) { } www.LoadImageIntoTexture(galleryImage); textureLoaded = true; } }
public string GeneratePath() { String path = Application.persistentDataPath; #if UNITY_ANDROID AndroidJavaObject env = new AndroidJavaObject ("android.os.Environment"); AndroidJavaObject file = env.CallStatic<AndroidJavaObject> ("getExternalStorageDirectory"); path = file.Call<String> ("getAbsolutePath"); #endif if (!path.EndsWith ("/")) { path += "/"; } path += "traces"; if (debug) { Debug.Log ("Storing traces in " + path); } return path; }
private void Awake() { // Only allow one instance at runtime. if (instance != null) { enabled = false; DestroyImmediate(this); return; } instance = this; System.Version netVersion = OVRPlugin.wrapperVersion; System.Version ovrVersion = OVRPlugin.version; Debug.Log("Unity v" + Application.unityVersion + ", " + "Oculus Integration v" + netVersion + ", " + "OVRPlugin v" + ovrVersion + "."); // Detect whether this platform is a supported platform RuntimePlatform currPlatform = Application.platform; isSupportedPlatform |= currPlatform == RuntimePlatform.Android; isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer; isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor; isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer; isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor; isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer; if (!isSupportedPlatform) { Debug.LogWarning("This platform is unsupported"); return; } #if !UNITY_ANDROID || UNITY_EDITOR if (OVRUnityVersionChecker.hasBuiltInVR) { Debug.LogWarning("The Oculus Unity Legacy Integration is only supported in Unity 4.x releases. For Unity 5.x, please migrate to the Oculus Utilities for Unity package and use Unity's built-in VR support (available in Unity 5.1 and later)."); isVRPresent = false; } else if (!ovrIsInitialized) { //HACK: For some reason, Unity doesn't call UnitySetGraphicsDevice until we make the first P/Invoke call. OVRPluginEvent.eventBase = OVRPluginEvent.eventBase; #if !UNITY_ANDROID || UNITY_EDITOR //Handle all log messages OVR_FlushLog(OnLogMessage); #endif // If unable to load the Oculus Runtime. if (!OVRPlugin.initialized) { bool isBadWinRenderer = ((Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) && !SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11")); if (isBadWinRenderer) Debug.LogWarning("Only D3D11 is supported on Windows."); else Debug.LogWarning("Runtime is not present or no Rift attached. Running without VR."); // Runtime is not installed if ovr_Initialize() fails. isVRPresent = false; // Go monoscopic in response. monoscopic = true; } else { OVRPluginEvent.Issue(RenderEventType.InitRenderThread); isVRPresent = true; #if UNITY_EDITOR if (!OVRUnityVersionChecker.hasEditorVRSupport) { // Only allow VR in standalones. isVRPresent = false; Debug.LogWarning("VR rendering is not supported in the editor. Please update to 4.6.7p4 or build a stand-alone player."); } #endif if (netVersion.Major > ovrVersion.Major || netVersion.Major == ovrVersion.Major && netVersion.Minor > ovrVersion.Minor) { isVRPresent = false; Debug.LogWarning("Version check failed. Please make sure you are using OVRPlugin " + Ovr.Hmd.OVR_VERSION_STRING + " or newer."); } OVRPlugin.queueAheadFraction = 0f; ovrIsInitialized = true; } } SetEditorPlay(Application.isEditor); #else // UNITY_ANDROID && !UNITY_EDITOR: Start of Android init. // Android integration does not dynamically load its runtime. isVRPresent = true; // log the unity version Debug.Log( "Unity Version: " + Application.unityVersion ); // don't allow the application to run if orientation is not landscape left. if (Screen.orientation != ScreenOrientation.LandscapeLeft) { Debug.LogError("********************************************************************************\n"); Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" + "***** Stopping application.\n"); Debug.LogError("********************************************************************************\n"); Debug.Break(); Application.Quit(); } // don't enable gyro, it is not used and triggers expensive display calls if (Input.gyro.enabled) { Debug.LogError("*** Auto-disabling Gyroscope ***"); Input.gyro.enabled = false; } // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the // main window surface with front buffer rendering enabled. The view will // render black. // On Adreno KitKat, some tiling control modes will cause the view to render // black. if (QualitySettings.antiAliasing > 1) { Debug.LogError("*** Antialiasing must be disabled for Gear VR ***"); } // we sync in the TimeWarp, so we don't want unity // syncing elsewhere QualitySettings.vSyncCount = 0; // try to render at 60fps Application.targetFrameRate = 60; // don't allow the app to run in the background Application.runInBackground = false; // Disable screen dimming Screen.sleepTimeout = SleepTimeout.NeverSleep; if (!androidJavaInit) { AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); // Prepare for the RenderThreadInit() SetInitVariables(activity.GetRawObject(), System.IntPtr.Zero); #if USE_ENTITLEMENT_CHECK AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker"); entitlementChecker.CallStatic("doAutomatedCheck", activity); #else Debug.Log( "Inhibiting Entitlement Check!" ); #endif androidJavaInit = true; } // We want to set up our touchpad messaging system OVRTouchpad.Create(); InitVolumeController(); // set an event delegate like this if you wish to handle events like "reorient". //SetVrApiEventDelegate( VrApiEventDefaultDelegate ); #endif // End of android init. prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing; prevEyeTextureDepth = OVRManager.instance.eyeTextureDepth; prevEyeTextureFormat = OVRManager.instance.eyeTextureFormat; prevNativeTextureScale = OVRManager.instance.nativeTextureScale; prevVirtualTextureScale = OVRManager.instance.virtualTextureScale; prevMonoscopic = OVRManager.instance.monoscopic; prevHdr = OVRManager.instance.hdr; if (tracker == null) tracker = new OVRTracker(); if (display == null) display = new OVRDisplay(); else wasRecreated = true; if (input == null) input = new OVRInput(); if (resetTrackerOnLoad) display.RecenterPose(); #if !UNITY_ANDROID || UNITY_EDITOR // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps(). if (timeWarp) { bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"); QualitySettings.vSyncCount = useUnityVSync ? 1 : 0; QualitySettings.maxQueuedFrames = 0; } #endif #if UNITY_STANDALONE_WIN if (!OVRUnityVersionChecker.hasD3D9ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9")) { MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. " + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version." , "VR Configuration Warning", 0); } if (!OVRUnityVersionChecker.hasD3D11ExclusiveModeSupport && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11")) { MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. " + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version." , "VR Configuration Warning", 0); } #endif }
private void Awake() { // Only allow one instance at runtime. if (instance != null) { enabled = false; DestroyImmediate(this); return; } instance = this; #if !UNITY_ANDROID || UNITY_EDITOR if (!ovrIsInitialized) { OVR_Initialize(); OVRPluginEvent.Issue(RenderEventType.Initialize); ovrIsInitialized = true; } var netVersion = new System.Version(Ovr.Hmd.OVR_VERSION_STRING); var ovrVersion = new System.Version(Ovr.Hmd.GetVersionString()); if (netVersion > ovrVersion) Debug.LogWarning("Using an older version of LibOVR."); #endif // Detect whether this platform is a supported platform RuntimePlatform currPlatform = Application.platform; isSupportedPlatform |= currPlatform == RuntimePlatform.Android; isSupportedPlatform |= currPlatform == RuntimePlatform.LinuxPlayer; isSupportedPlatform |= currPlatform == RuntimePlatform.OSXEditor; isSupportedPlatform |= currPlatform == RuntimePlatform.OSXPlayer; isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsEditor; isSupportedPlatform |= currPlatform == RuntimePlatform.WindowsPlayer; if (!isSupportedPlatform) { Debug.LogWarning("This platform is unsupported"); return; } #if UNITY_ANDROID && !UNITY_EDITOR // don't allow the application to run if orientation is not landscape left. if (Screen.orientation != ScreenOrientation.LandscapeLeft) { Debug.LogError("********************************************************************************\n"); Debug.LogError("***** Default screen orientation must be set to landscape left for VR.\n" + "***** Stopping application.\n"); Debug.LogError("********************************************************************************\n"); Debug.Break(); Application.Quit(); } // don't enable gyro, it is not used and triggers expensive display calls if (Input.gyro.enabled) { Debug.LogError("*** Auto-disabling Gyroscope ***"); Input.gyro.enabled = false; } // NOTE: On Adreno Lollipop, it is an error to have antiAliasing set on the // main window surface with front buffer rendering enabled. The view will // render black. // On Adreno KitKat, some tiling control modes will cause the view to render // black. if (QualitySettings.antiAliasing > 1) { Debug.LogError("*** Antialiasing must be disabled for Gear VR ***"); } // we sync in the TimeWarp, so we don't want unity // syncing elsewhere QualitySettings.vSyncCount = 0; // try to render at 60fps Application.targetFrameRate = 60; // don't allow the app to run in the background Application.runInBackground = false; // Disable screen dimming Screen.sleepTimeout = SleepTimeout.NeverSleep; if (!androidJavaInit) { AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); javaVrActivityClass = new AndroidJavaClass("com.oculusvr.vrlib.VrActivity"); // Prepare for the RenderThreadInit() SetInitVariables(activity.GetRawObject(), javaVrActivityClass.GetRawClass()); #if !INHIBIT_ENTITLEMENT_CHECK AndroidJavaObject entitlementChecker = new AndroidJavaObject("com.oculus.svclib.OVREntitlementChecker"); entitlementChecker.CallStatic("doAutomatedCheck", activity); #else Debug.Log( "Inhibiting Entitlement Check!" ); #endif androidJavaInit = true; } // We want to set up our touchpad messaging system OVRTouchpad.Create(); InitVolumeController(); #else SetEditorPlay(Application.isEditor); #endif prevEyeTextureAntiAliasing = OVRManager.instance.eyeTextureAntiAliasing; prevEyeTextureDepth = OVRManager.instance.eyeTextureDepth; prevEyeTextureFormat = OVRManager.instance.eyeTextureFormat; prevNativeTextureScale = OVRManager.instance.nativeTextureScale; prevVirtualTextureScale = OVRManager.instance.virtualTextureScale; prevMonoscopic = OVRManager.instance.monoscopic; prevHdr = OVRManager.instance.hdr; if (display == null) display = new OVRDisplay(); if (tracker == null) tracker = new OVRTracker(); if (resetTrackerOnLoad) display.RecenterPose(); #if !UNITY_ANDROID || UNITY_EDITOR // Except for D3D9, SDK rendering forces vsync unless you pass ovrHmdCap_NoVSync to Hmd.SetEnabledCaps(). if (timeWarp) { bool useUnityVSync = SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9"); QualitySettings.vSyncCount = useUnityVSync ? 1 : 0; } #endif #if (UNITY_STANDALONE_WIN && (UNITY_4_6 || UNITY_4_5)) bool unity_4_6 = false; bool unity_4_5_2 = false; bool unity_4_5_3 = false; bool unity_4_5_4 = false; bool unity_4_5_5 = false; #if (UNITY_4_6) unity_4_6 = true; #elif (UNITY_4_5_2) unity_4_5_2 = true; #elif (UNITY_4_5_3) unity_4_5_3 = true; #elif (UNITY_4_5_4) unity_4_5_4 = true; #elif (UNITY_4_5_5) unity_4_5_5 = true; #endif // Detect correct Unity releases which contain the fix for D3D11 exclusive mode. string version = Application.unityVersion; int releaseNumber; bool releaseNumberFound = Int32.TryParse(Regex.Match(version, @"\d+$").Value, out releaseNumber); // Exclusive mode was broken for D3D9 in Unity 4.5.2p2 - 4.5.4 and 4.6 builds prior to beta 21 bool unsupportedExclusiveModeD3D9 = (unity_4_6 && version.Last(char.IsLetter) == 'b' && releaseNumberFound && releaseNumber < 21) || (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) || (unity_4_5_3) || (unity_4_5_4); // Exclusive mode was broken for D3D11 in Unity 4.5.2p2 - 4.5.5p2 and 4.6 builds prior to f1 bool unsupportedExclusiveModeD3D11 = (unity_4_6 && version.Last(char.IsLetter) == 'b') || (unity_4_5_2 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber >= 2) || (unity_4_5_3) || (unity_4_5_4) || (unity_4_5_5 && version.Last(char.IsLetter) == 'f') || (unity_4_5_5 && version.Last(char.IsLetter) == 'p' && releaseNumberFound && releaseNumber < 3); if (unsupportedExclusiveModeD3D9 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 9")) { MessageBox(0, "Direct3D 9 extended mode is not supported in this configuration. " + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version." , "VR Configuration Warning", 0); } if (unsupportedExclusiveModeD3D11 && !display.isDirectMode && SystemInfo.graphicsDeviceVersion.Contains("Direct3D 11")) { MessageBox(0, "Direct3D 11 extended mode is not supported in this configuration. " + "Please use direct display mode, a different graphics API, or rebuild the application with a newer Unity version." , "VR Configuration Warning", 0); } #endif }
public void OpenGallery() { textureLoaded = false; AndroidJavaClass ajc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ajo = new AndroidJavaObject("com.XavierStudio.PickPhoto.UnityBinder"); ajo.CallStatic("SetDuplicatePath", new object[] { Application.persistentDataPath }); ajo.CallStatic("OpenGallery", ajc.GetStatic<AndroidJavaObject>("currentActivity")); }