I had a quite simple script that kept count of the number of enemies in my scene and when that reached zero it loaded the next scene. Now I have multiple scenes I needed to change the variable number in the inspector for each scene rather than have a new script each time.
But for some reason the changing the variable to a public one has not let it show up in the inspector?
using UnityEngine;
using System.Collections;
public class LevelCleared : MonoBehaviour
{
public static int enemyNumbers = 10;
void Awake()
{
//enemyNumbers = 21;
}
void Update()
{
if(enemyNumbers <= 0)
{
var i = Application.loadedLevel;
AutoFade.LoadLevel(i+1 ,2,1,Color.black);
//Parameter 1 - LevelName or LevelIndex
//Parameter 2 - FadeOutTime - time in seconds until the level actually starts loading
//Parameter 3 - FadeInTime - time in seconds until the fade-in process is completed.
//Parameter 4 - FadeColor - this is the color the screen fades to.
}
}
}
The variable was originally a static in, now public static. The commented out line in the awake function is just a left over from when there was a single scene.
I’m getting no compiler errors and the script still does what I need depending on what number I set the int variable to. It just doesn’t show in the inspector so I have to manually change the script.
Any ideas
???
edit…
Script is attached to a sceneManager object in my scene and accessed from another script using -
LevelCleared.enemyNumbers -= 1;
???