The procedural Scenes
script contains constants corresponding to the index of each scene in your build settings so that instead of SceneManager.LoadScene("Main Menu")
you can use SceneManager.LoadScene(Scenes.MainMenu)
.
It also includes an IndexToName
method which can tell you the name of the scene at a given build settings index.
Scenes Panel
The Scenes panel in the Weaver Window allows the procedural script to be entirely disabled and shows the following options for customising it (Pro-Only):
Option | Description |
---|---|
Include Scene Index Fields | If enabled: the script will contain a const int field holding the build settings index of each scene. |
Include Scene Name Fields | If enabled: the script will contain a const string field holding the name of each scene. |
Use Full Path Names | If enabled: fields will be named using the scene's full asset path instead of just the file name. |
Use Nested Classes | If enabled: the fields for each scene will be grouped inside nested classes corresponding to the directories in their asset path. Otherwise they will all be located in the root Scenes class. |
Sample Output
// This file was procedurally generated by Weaver. Any modifications will be overwritten.
#pragma warning disable // All.
namespace Weaver
{
/// <summary>This class was procedurally generated by Weaver.</summary>
public static class Scenes
{
/// <summary>Assets/Plugins/Weaver/Examples/01 Frame Rate/01 Frame Rate.unity</summary>
public const int _01FrameRate = 0;
/// <summary>Assets/Plugins/Weaver/Examples/02 Floating Text/02 Floating Text.unity</summary>
public const int _02FloatingText = 1;
/// <summary>Assets/Plugins/Weaver/Examples/03 Building/03 Building.unity</summary>
public const int _03Building = 2;
/// <summary>Assets/Plugins/Weaver/Examples/04 Missiles/04 Missiles.unity</summary>
public const int _04Missiles = 3;
/// <summary>Assets/Plugins/Weaver/Examples/05 Missile Command/05 Missile Command.unity</summary>
public const int _05MissileCommand = 4;
/// <summary>Assets/Plugins/Weaver/Examples/06 Meta Asset List/06 Meta Asset List.unity</summary>
public const int _06MetaAssetList = 5;
/// <summary>Returns the name of the scene associated with the specified scene 'index' in the build settings.</summary>
public static string IndexToName(int index)
{
switch (index)
{
case 0: return "01 Frame Rate";
case 1: return "02 Floating Text";
case 2: return "03 Building";
case 3: return "04 Missiles";
case 4: return "05 Missile Command";
case 5: return "06 Meta Asset List";
default: return null;
}
}
}
}