- Home /
A namespace can only contain types and namespace declarations
Hello,
I'm trying to integrate adbuddiz in my Android app. I've looked at this tutorial that shows how to integrate it:
Part 1: https://www.youtube.com/watch?v=YU8DK9665ms Part 2: https://www.youtube.com/watch?v=WNkz-uKpEXk
In part 2, he puts some lines of code on one of his scripts. I'm using a different script. When I put those lines of code, I get this error:
error CS0116: A namespace can only contain types and namespace declarations
Here is the script:
using UnityEngine;
using System.Collections;
public static int AdsCounts =0;
public class PlayButtonTween : MonoBehaviour {
// Use this for initialization
void Start () {
iTween.ScaleTo (gameObject, iTween.Hash ("scale", new Vector3 (1.06f, 1.06f, 0), "time", 0.5f, "easetype", iTween.EaseType.linear, "looptype", iTween.LoopType.pingPong));
AdsCount += 1;
if (AdsCount > 2) {
AdBuddizBinding.ShowAd();
AdsCount=0;
}
}
}
It tells me the error on the line 4. I'm not really good at coding. If you know how to fix this please tell me. Help Would be appreciated.
Answer by Dave-Carlile · Jun 12, 2015 at 12:53 AM
This:
public static int AdsCounts =0;
Needs to be inside the class declaration. Move to line 6.
Thank you so much. But now the problem is that it's giving me 3 errors that say "The name AdsCounts does not exist in the current context". Thanks in advance.
You declare the variable as AdsCounts and you finally use AdsCount...