public PlatformConfiguration CreatePlatformConfiguration() { var config = AndroidPlatformConfiguration.Create(); using (var activity = AndroidTokenClient.GetActivity()) { config.SetActivity(activity.GetRawObject()); config.SetOptionalIntentHandlerForUI((intent) => { // Capture a global reference to the intent we are to show. This is required // since we are launching the intent from the game thread, and this callback // will return before this happens. If we do not hold onto a durable reference, // the code calling us will clean up the intent before we have a chance to display // it. var intentRef = AndroidJNI.NewGlobalRef(intent); PlayGamesHelperObject.RunOnGameThread(() => { try { LaunchBridgeIntent(intentRef); } finally { // Now that we've launched the intent, release the global reference. AndroidJNI.DeleteGlobalRef(intentRef); } }); }); } return(config); }
public PlatformConfiguration CreatePlatformConfiguration(PlayGamesClientConfiguration clientConfig) { AndroidPlatformConfiguration androidPlatformConfiguration = AndroidPlatformConfiguration.Create(); AndroidJavaObject activity = AndroidTokenClient.GetActivity(); try { androidPlatformConfiguration.SetActivity(activity.GetRawObject()); androidPlatformConfiguration.SetOptionalIntentHandlerForUI(delegate(IntPtr intent) { IntPtr intentRef = AndroidJNI.NewGlobalRef(intent); PlayGamesHelperObject.RunOnGameThread(delegate { try { LaunchBridgeIntent(intentRef); } finally { AndroidJNI.DeleteGlobalRef(intentRef); } }); }); if (!clientConfig.IsHidingPopups) { return(androidPlatformConfiguration); } androidPlatformConfiguration.SetOptionalViewForPopups(CreateHiddenView(activity.GetRawObject())); return(androidPlatformConfiguration); } finally { ((IDisposable)activity)?.Dispose(); } }
public void Dispose() { if (_instance != IntPtr.Zero) { AndroidJNI.DeleteGlobalRef(_instance); _instance = IntPtr.Zero; } }
private void SafeRelease(ref IntPtr ptr) { if (ptr != IntPtr.Zero) { AndroidJNI.DeleteGlobalRef(ptr); ptr = IntPtr.Zero; } }
public static void DeleteGlobalRef(IntPtr globalref) { if (!(globalref != IntPtr.Zero)) { return; } AndroidJNI.DeleteGlobalRef(globalref); }
/** * 移除javaObject对象从this对象 * @param lRef 与attachJavaObject保持一致, 并无含义 */ public void detachJavaObject(IntPtr lRef) { IntPtr gRef = (IntPtr)javaObject; if (0 != (long)gRef) { AndroidJNI.DeleteGlobalRef(gRef); javaObject = (IntPtr)0; } }
internal static PlatformConfiguration CreatePlatformConfiguration() { #if UNITY_ANDROID var config = AndroidPlatformConfiguration.Create(); config.EnableAppState(); using (var activity = GetActivity()) { config.SetActivity(activity.GetRawObject()); config.SetOptionalIntentHandlerForUI((intent) => { // Capture a global reference to the intent we are to show. This is required // since we are launching the intent from the game thread, and this callback // will return before this happens. If we do not hold onto a durable reference, // the code calling us will clean up the intent before we have a chance to display // it. IntPtr intentRef = AndroidJNI.NewGlobalRef(intent); PlayGamesHelperObject.RunOnGameThread(() => { try { LaunchBridgeIntent(intentRef); } finally { // Now that we've launched the intent, release the global reference. AndroidJNI.DeleteGlobalRef(intentRef); } }); }); } return(config); #endif #if UNITY_IPHONE if (!GameInfo.IosClientIdInitialized()) { throw new System.InvalidOperationException("Could not locate the OAuth Client ID, " + "provide this by navigating to Google Play Games > iOS Setup"); } if (GameInfo.WebClientIdInitialized()) { _GooglePlayEnableProfileScope(); } var config = IosPlatformConfiguration.Create(); config.SetClientId(GameInfo.IosClientId); return(config); #endif }
public byte[] readAllBytes() { var availbleBytes = getFileSize(); var byteArray = AndroidJNI.NewByteArray(availbleBytes); int readCout = AndroidJNI.CallIntMethod(_stream.GetRawObject(), METHOD_read, new[] { new jvalue() { l = byteArray } }); var bytes = AndroidJNI.FromByteArray(byteArray); AndroidJNI.DeleteGlobalRef(byteArray); return(bytes); }
public void Dispose() { Dispatcher.onFrame -= OnFrame; surfaceTexture.Call(@"release"); surface.Call(@"release"); surfaceTexture.Dispose(); surface.Dispose(); Texture2D.Destroy(nativeTexture); AndroidJNI.DeleteGlobalRef(transformMatrix); Dispatcher.Dispatch( Dispatcher.Target.RenderThread, () => GLBlitEncoderClass.CallStatic(@"releaseTexture", texturePtr.ToInt32()) ); }
public void OnStop() { AndroidJNI.DeleteGlobalRef(javaBuf); }