I have a editor script I call FastSceneCreator which converts scenes into a prefab.
Here is the script:
public class FastSceneCreator : EditorWindow
{
[MenuItem("UNDERUNITY/Convert to Fast Scene %#.", false, 0)]
public static void Convert()
{
// EditorUtility.DisplayDialog("Convert to Fast Scene", "Converting...", "Okay");
CreateScenePrefab(new GameObject(SceneManager.GetActiveScene().name).transform);
}
public static void CreateScenePrefab(Transform p)
{
p.gameObject.AddComponent<FastScene>();
GameObject[] gameobjects = GameObject.FindObjectsOfType<GameObject>();
for (int i = 0; i < gameobjects.Length + 1; i++)
{
if (i < gameobjects.Length)
{
if (gameobjects*.transform.parent == null)*
{
gameobjects*.transform.SetParent(p);*
continue;
}
}
else
{
if (AssetDatabase.LoadAssetAtPath(SceneManager.GetActiveScene().path.Replace(“.unity”, “”) + “.prefab”) != true)
{
PrefabUtility.CreatePrefab(SceneManager.GetActiveScene().path.Replace(“.unity”, “”) + “.prefab”, p.gameObject);
}
else
{
p.GetComponent().Additive = AssetDatabase.LoadAssetAtPath(SceneManager.GetActiveScene().path.Replace(“.unity”, “”) + “.prefab”).GetComponent().Additive;
PrefabUtility.ReplacePrefab(p.gameObject, AssetDatabase.LoadAssetAtPath(SceneManager.GetActiveScene().path.Replace(“.unity”, “”) + “.prefab”), ReplacePrefabOptions.ReplaceNameBased);
}
RemoveChildrenAndDelete(p);
break;
}
}
}
public static void RemoveChildrenAndDelete(Transform p)
{
EditorUtility.DisplayDialog(“Convert to Fast Scene”, “Finishing things up…”, “…”);
p.DetachChildren();
if (Resources.Load(“fastsettings”).NotifySceneConvert == true)
{
EditorUtility.DisplayDialog(“Convert to Fast Scene”, “Scene successfuly converted.”, “Okay”);
}
}
}
When I use the Convert to Fast Scene menu item, the editor hangs without going into “Not Responding”, then it crashes.
If you need the error log, tell me!