private void SetupGeolocator() { if (!_useLocation) { return; } try { UnityApp.EnableLocationService(true); Geolocator geolocator = new Geolocator(); geolocator.ReportInterval = 5000; IAsyncOperation <Geoposition> op = geolocator.GetGeopositionAsync(); op.Completed += (asyncInfo, asyncStatus) => { if (asyncStatus == AsyncStatus.Completed) { Geoposition geoposition = asyncInfo.GetResults(); UnityApp.SetupGeolocator(geolocator, geoposition); } else { UnityApp.SetupGeolocator(null, null); } }; } catch (Exception) { UnityApp.SetupGeolocator(null, null); } }
// Constructor public MainPage() { var bridge = new UnityBridge(); UnityApp.SetBridge(bridge); InitializeComponent(); bridge.Control = DrawingSurfaceBackground; }
private void PhoneApplicationPage_BackKeyPress(object sender, CancelEventArgs e) { e.Cancel = UnityApp.BackButtonPressed(); btnBuy.Visibility = System.Windows.Visibility.Visible; btnPause.Visibility = System.Windows.Visibility.Collapsed; }
// Constructor public MainPage() { var bridge = new UnityBridge(); UnityApp.SetBridge(bridge); InitializeComponent(); bridge.Control = DrawingSurfaceBackground; WindowsGateway.OnClickPlay = OnClickPlay; }
// Constructor public MainPage() { var bridge = new UnityBridge(); UnityApp.SetBridge(bridge); InitializeComponent(); bridge.Control = DrawingSurfaceBackground; Interop.ShowInterstitialEvent += Interop_ShowInterstitialEvent; Interop.LoadInterstitialEvent += Interop_LoadInterstitialEvent; }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (!_unityStartedLoading) { _unityStartedLoading = true; UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); }); int physicalWidth, physicalHeight; object physicalResolution; var content = Application.Current.Host.Content; var nativeWidth = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5); var nativeHeight = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5); if (DeviceExtendedProperties.TryGetValue("PhysicalScreenResolution", out physicalResolution)) { var resolution = (System.Windows.Size)physicalResolution; physicalWidth = (int)resolution.Width; physicalHeight = (int)resolution.Height; } else { physicalWidth = nativeWidth; physicalHeight = nativeHeight; } UnityApp.SetNativeResolution(nativeWidth, nativeHeight); UnityApp.SetRenderResolution(physicalWidth, physicalHeight); UnityPlayer.UnityApp.SetOrientation((int)Orientation); DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler()); if (isShowAds == 1) { bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = "ca-app-pub-6844968633010430/8322003504" }; bannerAd.FailedToReceiveAd += OnFailedToReceiveAd; bannerAd.ReceivedAd += OnReceivedAd; AdRequest adRequest = new AdRequest(); //adRequest.ForceTesting = true;//here rem here adGridAdmob.Children.Add(bannerAd); bannerAd.LoadAd(adRequest);//hinh nh cai nay thua. Can kiem tra lai // toanstt_Refresh_admob(); } } }
private void PhoneApplicationPage_BackKeyPress(object sender, CancelEventArgs e) { // If the Facebook overlay is visible, hide it if (MainPage.Current.FacebookGrid.Visibility == Visibility.Visible) { MainPage.Current.FacebookGrid.Visibility = Visibility.Collapsed; e.Cancel = true; } else { e.Cancel = UnityApp.BackButtonPressed(); } }
// Constructor public MainPage() { var bridge = new UnityBridge(); UnityApp.SetBridge(bridge); InitializeComponent(); bridge.Control = DrawingSurfaceBackground; _extendedSplashTimer = new DispatcherTimer(); _extendedSplashTimer.Interval = TimeSpan.FromMilliseconds(50); _extendedSplashTimer.Tick += ExtendedSplashTimer_Tick; _extendedSplashTimer.Start(); // ensure we listen to when unity tells us game is ready WindowsGateway.UnityLoaded = OnUnityLoaded; }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (!_unityStartedLoading) { _unityStartedLoading = true; UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); }); var content = Application.Current.Host.Content; var width = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5); var height = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5); UnityApp.SetNativeResolution(width, height); UnityApp.SetRenderResolution(width, height); UnityPlayer.UnityApp.SetOrientation((int)Orientation); DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler()); } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (!UnityApp.IsLocationEnabled()) { return; } if (IsolatedStorageSettings.ApplicationSettings.Contains("LocationConsent")) { _useLocation = (bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"]; } else { MessageBoxResult result = MessageBox.Show("Can this application use your location?", "Location Services", MessageBoxButton.OKCancel); _useLocation = result == MessageBoxResult.OK; IsolatedStorageSettings.ApplicationSettings["LocationConsent"] = _useLocation; IsolatedStorageSettings.ApplicationSettings.Save(); } }
// Constructor public MainPage() { var bridge = new UnityBridge(); UnityApp.SetBridge(bridge); InitializeComponent(); bridge.Control = DrawingSurfaceBackground; // WP8Statics.WP8FunctionHandleSMSOpen += WP8Statics_OpenSMSHandle; WP8Statics.WP8FunctionHandleStopAds += WP8Statics_StopAds; WP8Statics.WP8FunctionHandleShowAds += WP8Statics_ShowAds; WP8Statics.WP8FunctionHandleRateApp += WP8Statics_RateApp; WP8Statics.WP8FunctionHandle2FbShared += WP8Statics_FbClickHandle; MainPage._mainPage = this; isShowAds = 1; if (isShowAds == 1) { VservAdControl VMB = VservAdControl.Instance; //full ads VMB.DisplayAd("7d2532e8", LayoutRoot); //n_m_hoang VMB.VservAdClosed += new EventHandler(VACCallback_OnVservAdClosing); VMB.VservAdError += new EventHandler(VACCallback_OnVservAdNetworkError); VMB.VservAdNoFill += new EventHandler(VACCallback_OnVservAdNoFill); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (!_unityStartedLoading) { _unityStartedLoading = true; //UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); }); var content = Application.Current.Host.Content; var nativeWidth = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5); var nativeHeight = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5); var physicalWidth = nativeWidth; var physicalHeight = nativeHeight; object physicalResolution; if (DeviceExtendedProperties.TryGetValue("PhysicalScreenResolution", out physicalResolution)) { var resolution = (System.Windows.Size)physicalResolution; var nativeScale = content.ActualHeight / content.ActualWidth; var physicalScale = resolution.Height / resolution.Width; // don't use physical resolution for devices that don't have hardware buttons (e.g. Lumia 630) if (Math.Abs(nativeScale - physicalScale) < 0.01) { physicalWidth = (int)resolution.Width; physicalHeight = (int)resolution.Height; } } UnityApp.SetNativeResolution(nativeWidth, nativeHeight); UnityApp.SetRenderResolution(physicalWidth, physicalHeight); UnityApp.SetOrientation((int)Orientation); DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler()); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (!_unityStartedLoading) { _unityStartedLoading = true; UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); }); int physicalWidth, physicalHeight; object physicalResolution; var content = Application.Current.Host.Content; var nativeWidth = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5); var nativeHeight = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5); if (DeviceExtendedProperties.TryGetValue("PhysicalScreenResolution", out physicalResolution)) { var resolution = (System.Windows.Size)physicalResolution; physicalWidth = (int)resolution.Width; physicalHeight = (int)resolution.Height; } else { physicalWidth = nativeWidth; physicalHeight = nativeHeight; } UnityApp.SetNativeResolution(nativeWidth, nativeHeight); UnityApp.SetRenderResolution(physicalWidth, physicalHeight); UnityPlayer.UnityApp.SetOrientation((int)Orientation); DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler()); } }
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) { UnityApp.SetOrientation((int)e.Orientation); }
/*private void Unity_Loaded() * { * }*/ private void PhoneApplicationPage_BackKeyPress(object sender, CancelEventArgs e) { e.Cancel = UnityApp.BackButtonPressed(); }
public void InvokeOnAppThread(Action callback) { UnityApp.BeginInvoke(() => callback()); }