In newest version 6.0.0, when I edit app id in GoogleMobileAdsSettings, then reopen Unity, I discover that app id not be saved
for those who waiting for an official solution, you can hardcode appid at Assets\GoogleMobileAds\Editor\GoogleMobileAdsSettings.cs
I had the same issue, you can also just manually add your IDs to the GoogleMobileAdsSettings.assett file by opening it in a text editor.
\Assets\GoogleMobileAds\Resources\GoogleMobileAdsSettings.assett
I also got the same issue, the app ids become empty every time I quit Play mode. But after I try to click Reset button in Unity inspector of GoogleMobileAdsSettings scriptable object, it become normal again, data can now be persisted. I use Unity 2020.3.8.
I'm having the same issue as well.
If you tick/untick the Delay App Measurement checkbox it saves the settings, including the App IDs
Just wanted to acknowledge that this is on our radar, but lower priority than a few other bugs such as https://github.com/googleads/googleads-mobile-unity/issues/1616 and this probably won't make it into the first patch release post 6.0.0 given the suggested workarounds above.
If you tick/untick the Delay App Measurement checkbox it saves the settings, including the App IDs
this workaround worked for me.
Just chiming in that I had this issue as well with 6.0.1 and solved it by manually entering in the values via the .asset file
@ericleich
Google SDK should be tested before release, this shouldn't happens and I found another issue that make the app crash even with blank projects.
Every big issue I have is with Google SDK, last time it was the Google Cardboard SDK, I've lost days of work making fixes for Google untested SDKs! Grrr
For all who are interested in a proper solution:
public override void OnInspectorGUI()
{
EditorGUILayout.LabelField("Google Mobile Ads App ID", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
GoogleMobileAdsSettings.Instance.GoogleMobileAdsAndroidAppId =
EditorGUILayout.TextField("Android",
GoogleMobileAdsSettings.Instance.GoogleMobileAdsAndroidAppId);
GoogleMobileAdsSettings.Instance.GoogleMobileAdsIOSAppId =
EditorGUILayout.TextField("iOS",
GoogleMobileAdsSettings.Instance.GoogleMobileAdsIOSAppId);
EditorGUILayout.HelpBox(
"Google Mobile Ads App ID will look similar to this sample ID: ca-app-pub-3940256099942544~3347511713",
MessageType.Info);
EditorGUI.indentLevel--;
EditorGUILayout.Separator();
EditorGUILayout.LabelField("AdMob-specific settings", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
GoogleMobileAdsSettings.Instance.DelayAppMeasurementInit =
EditorGUILayout.Toggle(new GUIContent("Delay app measurement"),
GoogleMobileAdsSettings.Instance.DelayAppMeasurementInit);
if (GoogleMobileAdsSettings.Instance.DelayAppMeasurementInit) {
EditorGUILayout.HelpBox(
"Delays app measurement until you explicitly initialize the Mobile Ads SDK or load an ad.",
MessageType.Info);
}
EditorGUI.indentLevel--;
EditorGUILayout.Separator();
if (EditorGUI.EndChangeCheck())
{
OnSettingsChanged();
}
}
Greetings Ben
I'm having this error also on v6.0.1
Have same issue with version 6.1.0
Found two workarounds.
1 - Tick / untick "Delay App Measurement" checkbox, as our colleague says on previous comments or
2 - Edit \Assets\GoogleMobileAds\Resources\GoogleMobileAdsSettings.asset, and add manually your appID.
Both workarounds is working fine.
Solucionado escribiendo manualmente el ID en el archivo GoogleMobileAdsSettings de forma:
[SerializeField]
private string adMobAndroidAppId = "ca-app-pub-123123123123123~123123123123";
El ID es ejemplo, recuerde buscar su ID en AdMob All Apps.
As of 6.0.1 none of those work in Unity 2020.3.19. Any ideas?
Hello everyone,
I am using Unity 2020.2.6, and GoogleMobileAds-v6.1.1.unitypackage
I had the pre-mentioned issue as well, meaning they still haven't fixed the issue.
Also, previous workarounds don't work on my version. So I had to rewrite the editor script...
Here is a solution that works perfectly, [2-steps]
_Note: if you tried the solution and it doesn't work then you are using a different version, so I recommend reimporting the original 2 scripts from the unity package._
_@Mention me if you need a solution for your version_
1. Replace everything in the file
Assets\GoogleMobileAds\Editor\GoogleMobileAdsSettingsEditor.cswith the following:
I also trimmed the AppId in case it was pasted with spaces "Idk I find that bothering for me"
using UnityEditor;
namespace GoogleMobileAds.Editor {
[InitializeOnLoad]
[CustomEditor (typeof (GoogleMobileAdsSettings))]
public class GoogleMobileAdsSettingsEditor : UnityEditor.Editor {
SerializedProperty m_Android;
SerializedProperty m_IOS;
SerializedProperty m_DelayAppeasurementInit;
[MenuItem ("Assets/Google Mobile Ads/Settings...")]
public static void OpenInspector () {
Selection.activeObject = GoogleMobileAdsSettings.Instance;
}
private void OnEnable () {
m_Android = serializedObject.FindProperty ("adMobAndroidAppId");
m_IOS = serializedObject.FindProperty ("adMobIOSAppId");
m_DelayAppeasurementInit = serializedObject.FindProperty ("delayAppMeasurementInit");
}
public override void OnInspectorGUI () {
serializedObject.Update ();
EditorGUILayout.PropertyField (m_Android);
EditorGUILayout.PropertyField (m_IOS);
EditorGUILayout.Space (5);
EditorGUILayout.HelpBox ("Google Mobile Ads App ID will look similar to this sample ID: ca-app-pub-3940256099942544~3347511713", MessageType.Info);
EditorGUILayout.Space (15);
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (m_DelayAppeasurementInit);
if (m_DelayAppeasurementInit.boolValue)
EditorGUILayout.HelpBox ("When DelayAppMeasurementInit is on it delays app measurement until you explicitly initialize the Mobile Ads SDK or load an ad.", MessageType.Info);
if (serializedObject.hasModifiedProperties) {
GoogleMobileAdsSettings.Instance.GoogleMobileAdsAndroidAppId = m_Android.stringValue.Trim ();
GoogleMobileAdsSettings.Instance.GoogleMobileAdsIOSAppId = m_IOS.stringValue.Trim ();
GoogleMobileAdsSettings.Instance.DelayAppMeasurementInit = m_DelayAppeasurementInit.boolValue;
GoogleMobileAdsSettings.Instance.WriteSettingsToFile ();
serializedObject.ApplyModifiedProperties ();
EditorUtility.SetDirty ((GoogleMobileAdsSettings) target);
}
}
}
}
- I found this instance bug, maybe only in this version, but you need to go to
GoogleMobileAdsSettings.csand find the Instance property and replace it with this code [I added a check if already found in Resources don't create and override]
public static GoogleMobileAdsSettings Instance
{
get
{
if (instance != null)
{
return instance;
}
instance = Resources.Load<GoogleMobileAdsSettings>(MobileAdsSettingsFile);
if (instance) {
return instance;
}
Directory.CreateDirectory(MobileAdsSettingsResDir);
instance = CreateInstance<GoogleMobileAdsSettings>();
string assetPath = Path.Combine(MobileAdsSettingsResDir, MobileAdsSettingsFile);
string assetPathWithExtension = Path.ChangeExtension(assetPath, MobileAdsSettingsFileExtension);
AssetDatabase.CreateAsset(instance, assetPathWithExtension);
return instance;
}
}
I worked around the issue by forcing the asset to save by toggling the "Delay app measurement" toggle on and off. Then it shows up in my source control. All good.
Most helpful comment
If you tick/untick the Delay App Measurement checkbox it saves the settings, including the App IDs