hi guys my script instance is not created.
using UnityEngine;
using System.Collections;
public class Loader : MonoBehaviour {
public GameObject gameManager;
void Awake() {
if (GameManager.instance = null) {
Instantiate(gameManager);
}
}
}
and this is the script I want to be called
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
public static GameManager instance = null;
public GameObject spawnPoint;
public GameObject[] enemies;
public int maxEnemiesOnScreen;
public int totalEnemies;
public int enemiesPerSpawn;
private int enemiesOnScreen = 0;
void Awake() {
if (instance = null){
instance = this;
} else if(instance != this){
Destroy(gameObject);
DontDestroyOnLoad(gameObject);
}
}
// Use this for initialization
void Start () {
print("Called");
spawnEnemy();
}
void spawnEnemy(){
if (enemiesPerSpawn > 0 && enemiesOnScreen < totalEnemies){
print("working");
for (int i = 0; i < enemiesPerSpawn; i++){
if(enemiesOnScreen < maxEnemiesOnScreen){
GameObject newEnemy = Instantiate(enemies*) as GameObject;*
-
newEnemy.transform.position = spawnPoint.transform.position;*
-
enemiesOnScreen +=1;*
-
}*
-
}*
-
}*
- }*
}
***************************************************************************************
the first script is attached to the main camera