I'm using the following code to implement a banner ad at the bottom on my game screen in unity.
using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdScript : MonoBehaviour {
// Use this for initialization
void Start () {
showBannerAd();
}
private void showBannerAd()
{
string adID = "ca-app-pub-***********";
//***For Testing in the Device***
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("***********") // My test device.
.Build();
//***For Production When Submit App***
//AdRequest request = new AdRequest.Builder().Build();
BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner, AdPosition.Bottom);
bannerAd.LoadAd(request);
}
// Update is called once per frame
void Update () {
}
}
When I run it I get a notification on the log of:
Dummy .ctor
Dummy Createbannerview
Dummy LoadAd
but not a mock pop up banner saying "a banner ad will be implemented here"
Will the ads be implemented when published or did I misunderstand a step in the tutorial?
Admob banners will only be displayed when building to ios or Android and running it on a target device. You will never see a banner in the unity editor.
It does not matter if you run test ads or not, they just won't show in the editor.
Related
So i am writing a game and everything was fine until i stopped the game in unity editor but it still shows me as playing it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Discord;
public class DiscordController : MonoBehaviour {
public Discord.Discord discord;
// Use this for initialization
void Start () {
discord = new Discord.Discord(764652301289259078, (System.UInt64)Discord.CreateFlags.Default);
var activityManager = discord.GetActivityManager();
var activity = new Discord.Activity
{
State = "Beta",
Details = "- In Devolpment DM me for a beta if you want"
};
activityManager.UpdateActivity(activity, (res) =>
{
if (res == Discord.Result.Ok)
{
Debug.LogError("Everything is fine!");
}
});
}
// Update is called once per frame
void Update () {
discord.RunCallbacks();
}
}
please help its annoying.
thanks for reading,
I figured it out, unity editor is still runnning the code when i stop it.
I have created a vr app in unity using google vr sdk. Currently i could click on the screen to start the video. When i use the vr headset, i need to use the bluetooth controller to play/stop the video. Can someone help me do this?
You need to identify how unity map your controller buttons, once you identify what button do you want to press and how unity mapped in his Input Manager (Edit->Project Settings->Input) you just need to call you function from the Update like this:
void Update()
{
if(Input.GetButtonUp("Fire1"))
{
playVideoFuncion();
}
}
Where playVideoFunction() is your own fuction.
In this example I used "Fire1" but maybe in your case is different.
For example for the Xbox Controller you have this configuration explained in Xbox 360 Controller Input on Unity
If you can't find anything related on your controller you can do something like:
void Update()
{
if(Input.GetButtonUp("Fire1"))
{
Debug.Log("Fire 1 Pressed");
}
if(Input.GetButtonUp("Fire2"))
{
Debug.Log("Fire 1 Pressed");
}
if(Input.GetButtonUp("0"))
{
Debug.Log("Button 0 pressed");
}
// Add more buttons and logs
}
There are maybe other ways to identify the input from random controllers but I don't know how. I needed the mapping for the Xbox controller and that page was useful.
You can create a script and attach to the video player so that when a user clicks on the player the commands are run. I assume you already have the unity package for Google VR(GVR). Add the following sample script and modify to suit your need.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VideoPlayer : MonoBehaviour {
private bool _isPlaying;
// Use this for initialization
void Start () {
_isPlaying = false
}
// Update is called once per frame
void Update () {
if (GvrController.ClickButtonUp && _isPlaying) {
PlayVideo();
}
else if (GvrController.ClickButtonUp && !_isPlaying){
StopVideo ();
}
}
public void PlayVideo{
//Logic to Play Video
}
public void StopVideo{
//Logic to Stop Video
}
}
I am making a game now. I have also make a save game and load game.
What i want is when i load the game (this mean code to load) i will show loading progress until code load execution is finish.
For example (LoadGame.cs):
using UnityEngine;
using System.Collections;
public class Load_Timer_Merchant : MonoBehaviour {
CloudSaver CloudSave;
// Use this for initialization
void Start () {
CloudSave = GameObject.FindGameObjectWithTag("CloudSave").GetComponent<CloudSaver>();
CloudSave.Load_Timer_Merchant ();
}
// Update is called once per frame
void Update () {
}
}
I want to make the progress loading of that file script LoadGame.cs
Is that possible to do it ?
Thanks
Dennnis
You have required Co-routine to do this task
For instance, You want to log successful text as image load from a url something like this
IEnumerator DoImageLoad()
{
WWW txTexture = new WWW(m_szTexturePath);
yield return txTexture;
renderer.material.mainTexture = txTexture.texture;
Debug.Log("Image Loaded. This message will show as image loaded");
}
Start(){
StartCoroutine("DoImageLoad");
}
After show and close an Interstitial banner on ios8, the app freeze.
The app back to full operate after pressing Home button and re-activate it.
I'm working with unity 4.5.4f1, xcode6. This is the pseudo code that we're using:
...
ADInterstitialAd.onInterstitialWasLoaded += OnFullscreenLoaded;
...
private ADInterstitialAd fullscreenAd=null;
fullscreenAd = new ADInterstitialAd(true);
...
void OnFullscreenLoaded()
{
if(!fullscreenAd.loaded) return;
fullscreenAd.Show();
}
Issue of unity fixed on 4.5.6
http://issuetracker.unity3d.com/issues/the-app-freezes-after-closing-an-adinterstitialad
I just published a game I made using Unity3D to Google Play. When I made tests before putting the game on the strore - I was able to see test ads. Now, that my game is on the store - I can't see any banner ads.
This is my code for showing adds, what's wrong here?
BannerView BV;
string adUnitId = "ca-app-pub-123456789/987654321";
void Start()
{
BV = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
RB(); //Request Banner
SB(); //Show Banner
}
private AdRequest createAdRequest()
{
return new AdRequest.Builder()
.AddKeyword("Game")
.SetGender(Gender.Male)
.SetBirthday(new DateTime(1988, 9, 4))
.TagForChildDirectedTreatment(true)
.Build();
}
void RB()
{
BV.LoadAd(createAdRequest());
}
internal void SB()
{
BV.Show();
}
Look at your log. It will tell you if an ad request has been made and what the result was.
If there are no ads to display, it will test you.
I suspect that is what is happening.