Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor.SceneTemplate; using UnityEngine.SceneManagement; public class NewBehaviourScript : MonoBehaviour { public string test = "hello"; // Start is called before the first frame update void Start() { SceneTemplateService.CreateSceneTemplate(test); } } That's my script, I append it to a cube, press play and I get this error message: Code (CSharp): UnityException: Creating asset at path champ failed. UnityEditor.SceneTemplate.SceneTemplateService.CreateTemplateFromScene (UnityEditor.SceneAsset sourceSceneAsset, System.String sceneTemplatePath, UnityEditor.SceneTemplate.SceneTemplateAnalytics+TemplateCreationType creationType) (at <49dd6fba630a4485a2d84fe09bd6a4a6>:0) UnityEditor.SceneTemplate.SceneTemplateService.CreateSceneTemplate (System.String sceneTemplatePath) (at <49dd6fba630a4485a2d84fe09bd6a4a6>:0) NewBehaviourScript.Start () (at Assets/Scenes/NewBehaviourScript.cs:13)
Never used this API but pretty much every other editor asset creation API in Unity requires that you tell it the full path, which would probably be prefixed with "Assets/" and suffixed with ".unity" Did you try using a string such as "Assets/FoobarDoodle.unity ?