Hello. I started making a game recently and everything goes very well so far except for that I get an annoying error that just spams without end in the console. I can enter testmode but it just keeps spamming and spamming… Here it is:
NullReferenceException: Object reference not set to an instance of an object
UnityStandardAssets.Utility.PlatformSpecificContent.EnableContent (Boolean enabled) (at Assets/Standard Assets/Utility/PlatformSpecificContent.cs:103)
UnityStandardAssets.Utility.PlatformSpecificContent.CheckEnableContent () (at Assets/Standard Assets/Utility/PlatformSpecificContent.cs:74)
UnityStandardAssets.Utility.PlatformSpecificContent.Update () (at Assets/Standard Assets/Utility/PlatformSpecificContent.cs:51)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:222)
I have no idea what causes this and how to fix it. Seems to be a script error as it says but its a standart assets script so why would it cause errors… It started after I tried switching to Windows Store and then to android then back to pc. I also have lots more errors when building the game but I think this one error causes them all since its the only one spamming or just the only error that occurs when building the game.
Any help would be appreciated, I really need it! 
By the way, here is the script:
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityStandardAssets.Utility
{
#if UNITY_EDITOR
[ExecuteInEditMode]
#endif
public class PlatformSpecificContent : MonoBehaviour
{
private enum BuildTargetGroup
{
Standalone,
Mobile
}
[SerializeField] private BuildTargetGroup m_BuildTargetGroup;
[SerializeField] private GameObject[] m_Content = new GameObject[0];
[SerializeField] private MonoBehaviour[] m_MonoBehaviours = new MonoBehaviour[0];
[SerializeField] private bool m_ChildrenOfThisObject;
#if !UNITY_EDITOR
void OnEnable()
{
CheckEnableContent();
}
#endif
#if UNITY_EDITOR
private void OnEnable()
{
EditorUserBuildSettings.activeBuildTargetChanged += Update;
EditorApplication.update += Update;
}
private void OnDisable()
{
EditorUserBuildSettings.activeBuildTargetChanged -= Update;
EditorApplication.update -= Update;
}
private void Update()
{
CheckEnableContent();
}
#endif
private void CheckEnableContent()
{
#if (UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_TIZEN || UNITY_STV )
if (m_BuildTargetGroup == BuildTargetGroup.Mobile)
{
EnableContent(true);
} else {
EnableContent(false);
}
#endif
#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_TIZEN || UNITY_STV )
if (m_BuildTargetGroup == BuildTargetGroup.Mobile)
{
EnableContent(false);
}
else
{
EnableContent(true);
}
#endif
}
private void EnableContent(bool enabled)
{
if (m_Content.Length > 0)
{
foreach (var g in m_Content)
{
if (g != null)
{
g.SetActive(enabled);
}
}
}
if (m_ChildrenOfThisObject)
{
foreach (Transform t in transform)
{
t.gameObject.SetActive(enabled);
}
}
if (m_MonoBehaviours.Length > 0)
{
foreach (var monoBehaviour in m_MonoBehaviours)
{
monoBehaviour.enabled = enabled;
}
}
}
}
}
Error at this line:
monoBehaviour.enabled = enabled;
I don’t know whats wrong about it either.
Please use code tags when inserting code!! Using code tags properly - Unity Engine - Unity Discussions
I’d recommend deleting the Standard Assets and downloading them again from the Asset Store, since generally they shouldn’t be throwing any errors.
Alright I fixed the code in the post. I also just deleted the script yesterday and no errors, but Im pretty sure something will go wrong anyway. I don’t really want to delete standart assets because my game is an autosimulator game and it (maybe currently) uses the standart assets car physics. I think if delete it and redownload again the game and prefabs will just break. But thanks for the suggestion anyways.