Hi, I’m having a problem with UnityADS downloaded from AssetStore, in Unity 5.4, take a look:
Can someone help me on this?
AddComponent with MonoBehaviour is not allowed. Create a class that derives from MonoBehaviour and add it instead.
UnityEngine.Advertisements.Advertisement:Initialize(String, Boolean)
This error point me on this line: coroutineHost = asyncExecGameObject.AddComponent(); from the file AsyncExec.cs from the UnityEngine.Advertisements Class. (line 17)
Same problem here. Started occurring after the update to Unity 5.4. Also getting the following error in the console.
AddComponent with MonoBehaviour is not allowed. Create a class that derives from MonoBehaviour and add it instead. Error points to the line where I call Advertisement.Initialize
I use exactly the same code as shown in the example (Integration Guide):
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements; // Using the Unity Ads namespace.
public class ShowAdOnStart : MonoBehaviour
{
#if !UNITY_ADS // If the Ads service is not enabled...
public string gameId; // Set this value from the inspector.
public bool enableTestMode = true;
#endif
IEnumerator Start ()
{
#if !UNITY_ADS // If the Ads service is not enabled...
if (Advertisement.isSupported) { // If runtime platform is supported...
Advertisement.Initialize(gameId, enableTestMode); // ...initialize.
}
#endif
// Wait until Unity Ads is initialized,
// and the default ad placement is ready.
while (!Advertisement.isInitialized || !Advertisement.IsReady()) {
yield return new WaitForSeconds(0.5f);
}
// Show the default ad placement.
Advertisement.Show();
}
}
I’m receiving errors like these: AddComponent with MonoBehaviour is not allowed. Create a class that derives from MonoBehaviour and add it instead. UnityEngine.Advertisements.Advertisement:Initialize(String, Boolean) c__Iterator89:MoveNext() (at Assets/ShowAdOnStart.cs:16) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
I’m using the version from Asset Store, not using the “Services” tab from Unity Editor.
Also, I’m having this another problem when trying to “archive” in xCode:
Same problem here. I can not understand you.How could you publish this version without checking it? .Hire more testers please or hire your girlfriends as testers,if you have financial problems:)
Just in case anyone runs into these type of problems, make sure you completely remove any unityad plugins or files in the asset folder(s). After getting rid of anything unityad related, then proceed with importing the new SDK and setting up the coding. Should work without any issues.
I had a clean version of the SDK but still had the errors. This gentleman there posted a solution that works, but it should be something the Unity dev should have a look at:
Correct, an interface has been changed in Unity 5.4, so you get the “AddComponent with MonoBehaviour is not allowed” message in playmode in editor. However this doesn’t affect games deployed to mobile.
The solution is to upgrade to Unity Ads SDK 2.0 which can be downloaded from https://www.assetstore.unity3d.com/en/#!/content/66123. Ads SDK 2.0 will be integrated in Unity 5.5, and we’re working on deprecating SDK 1.x as soon as possible.
This is a problem I met some days ago. The problem come because if you are using unity ads 1.1 SDK then you update the version unity ads 2.0 asset. So they are 2 assets so if you want to use unity ads 2.0 you need to clear all of files of version 1.1 include “Assets/Standard Assets/UnityAds” (what I missed). Hope it 's helpful.