I'm taking an online class for game development using unity, the instructor can at sometimes be vague. I am under the impression that using gameobject is the same as using the game objects name(in this case it is MusicPlayer), but when I try and replace MusicPlayer instance with gameobject instance, I get the errorCS0246: The type or namespace name `gameobject' could not be found. Are you missing a using directive or an assembly reference? I am just trying to understand the difference between the two. Thank you in advance.
using UnityEngine;
using System.Collections;
public class MusicPlayer : MonoBehaviour {
static MusicPlayer instance = null;
void Awake(){
if (instance != null){
Destroy(gameObject);
Debug.Log("Duplicate MusicPlayer Destroyed");
}
else{
instance = this;
GameObject.DontDestroyOnLoad(gameObject);
Debug.Log("Original MusicPlayer Created!");
}
}
}
This is the code that I am getting error with:
using UnityEngine;
using System.Collections;
public class MusicPlayer : MonoBehaviour {
public static gameobject instance = null;
void Awake(){
if (instance != null){
Destroy(gameObject);
Debug.Log("Duplicate MusicPlayer Destroyed");
}
else{
instance = this;
GameObject.DontDestroyOnLoad(gameObject);
Debug.Log("Original MusicPlayer Created!");
}
}
}