As the title says, I have a script that procedurally generates a level,
For example, while the project is running, if I press F11, the level will be regenerated.
I was wondering how I can re-generate the level without having to stop and re-playing the project.
Do I just call the Start / Awake function if F11 has been pressed?
not sure if you need it, but you can create the level in editor mode by creating a folder called Editor in Assets,
and create your own function in your level creation script and create the level there instead of in Start or Awake,
then put this script i called MapInspector in Editor folder:
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(LevelCreationScriptName))]
public class MapInspector : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector ();
if(GUILayout.Button ("generate level"))
{
Camera.main.GetComponent<LevelCreationScriptName>().LevelCreationFunctionName();
}
}
}
your level creation script needs to be attached to main camera, also you have to edit the script name and function name to match yours. it will make a button in your main camera’s inspector for calling your level creation function