In the new alpha release there’s a patch node:
.
What does it mean?
In the new alpha release there’s a patch node:
.
What does it mean?
The online scripting reference doesn’t seem to be up to date with the latest alpha, but if you install the docs locally, they should be. Search for PreviewSceneStage
.
Examples of stages include Main Stage (where your regular scenes live) and Prefab Stage (where you edit Prefabs). Stages show up in the breadcrumb bar at the top of the Scene View, except when you’re in Main Stage. By making a class that inherits from PreviewSceneStage, you can now make your own type of stage as well, for custom editor tooling purposes.
Hey @runevision I haven’t had a chance to play with this yet, but this new feature reminds me of a feedback post that I made a few weeks ago:
It sounds like this is exactly what I was looking for? Would my post be a good use case?
It might serve your purposes. For now, what you can do with PreviewSceneStage is similar to Prefab Mode in isolation - that is, you won’t see your normal scenes at the same time while your custom stage is open.
The docs have been updated and you can now see the docs for the class online here:
Oh boy, I’m so excited this is a thing!!!
Sounds great, but how do to get started with this?
I have this so far but calling Show() doesn’t do anything. What else is required?
public class StageTest : PreviewSceneStage
{
protected override GUIContent CreateHeaderContent()
{
return new GUIContent("Test");
}
protected override void OnCloseStage()
{
Debug.Log("Bye Stage");
}
[MenuItem("stages/test")]
static void Show()
{
var inst = CreateInstance<StageTest>();
inst.scene = EditorSceneManager.NewPreviewScene();
inst.OnFirstTimeOpenStageInSceneView(SceneView.currentDrawingSceneView);
inst.OnOpenStage();
}
}
Oh those links in the docs are completely wrong. We’ll get it fixed! In the mean time, have a look at
I know this is question probably doesn’t fit here, but I’ve struggled to find anything about stage for 2019.4, even though I can use the experimental PrefabStage and PrefabStageUtility, I can’t find any way to open those stages, any chance you can put me in the right right direction. Is there any proper use of stages for 2019.4?
You can’t manually create a new stage in 2019.4; only the functionality here is exposed:
https://docs.unity3d.com/2019.4/Documentation/ScriptReference/SceneManagement.StageUtility.html
A new stage is automatically created if you open a Prefab Asset using AssetDatabase.OpenAsset:
https://docs.unity3d.com/2019.4/Documentation/ScriptReference/AssetDatabase.OpenAsset.html
@runevision Here’s a little video of something I worked on to allow for multiple scene views to be open. There’s an issue where it won’t work unless you have a prefab staged but it works well to explain the concept. http://samuelarminana.com/u/1478894f9-6efc-46bf-a972-50eaeab4bd69.mp4
Do you see a future where the ability to open/close stages is opened?
Also I noticed that the stage breadcrumbs for the prefab editing is always one layer deep, is there situations where that isn’t the case?
It’d be really awesome if you opened prefabs into different scene views and the hierarchy updated based on the focus or preview scene views had their own internal hierarchy.
Here’s the code for any reference, its simple.
public class PreviewWindow : SceneView
{
public UnityEngine.Object selectedObj;
public Scene sceneLoaded;
[MenuItem("Assets/Preview/Preview Asset")]
public static void ShowWindow()
{
if (Selection.objects.Length > 1)
{
Debug.LogError("Your selection must include a single object.");
return;
}
else if (Selection.objects.Length <= 0)
{
Debug.LogError("No object selected to preview.");
return;
}
if (Selection.activeGameObject == null)
{
Debug.LogError("No Game Objects selected, only GameObjects/Prefabs are supported now");
return;
}
// Create the window
PreviewWindow window = CreateWindow<PreviewWindow>("Preview");
// Get the object you're selecting in the Unity Editor
window.selectedObj = Selection.activeObject;
window.titleContent = window.GetName();
// Load a new preview scene
scene = EditorSceneManager.NewPreviewScene();
window.sceneLoaded = scene;
window.sceneLoaded.name = window.name;
window.customScene = window.sceneLoaded;
window.drawGizmos = false;
window.SetupScene();
window.Repaint();
}
private static Scene scene;
public override void OnEnable()
{
base.OnEnable();
// Set title name
titleContent = GetName();
}
public override void OnDisable()
{
base.OnDisable();
}
private new void OnDestroy()
{
base.OnDestroy();
}
void SetupScene()
{
// Create lighting
GameObject lightingObj = new GameObject("Lighting");
lightingObj.transform.eulerAngles = new Vector3(50, -30, 0);
lightingObj.AddComponent<Light>().type = UnityEngine.LightType.Directional;
// Create the object we're selecting
GameObject obj = GameObject.Instantiate(selectedObj as GameObject);
// Move the objects to the preview scene
EditorSceneManager.MoveGameObjectToScene(obj, customScene);
EditorSceneManager.MoveGameObjectToScene(lightingObj, customScene);
Selection.activeObject = obj;
// Zoom the scene view into the new object
FrameSelected();
}
private GUIContent GetName()
{
if (selectedObj == null)
return new GUIContent("NuLL");
// Setup the title GUI Content (Image, Text, Tooltip options) for the window
GUIContent titleContent = new GUIContent(selectedObj.name);
if (selectedObj is GameObject)
{
titleContent.image = EditorGUIUtility.IconContent("GameObject Icon").image;
}
else if (selectedObj is SceneAsset)
{
titleContent.image = EditorGUIUtility.IconContent("SceneAsset Icon").image;
}
return titleContent;
}
new void OnGUI()
{
base.OnGUI();
}
}
We considered something like that (along with other variations of addressing the same use case) when we originally developed the improved Prefabs featureset for 2018.3 but there’s a range of technical challenges that would need to be solved to be able to make it work nicely and robustly and it was not viable at the time.
It’s something we’re aware of, but we’re currently deeming it not as vital as many other requested Prefab improvements (that are also requested much more frequently), so we do not currently have plans to work on it in the foreseeable future.
Is there a roadmap or anything similar for what the prefab department is working on? What are these ‘frequently requested improvements’? Sounds like your department has a plan, why not share that on the roadmap page.
I’ll forward the feedback about the roadmap page.
Too see some of the things we’ve been working on lately, have a look at this video:
Right now we’re primarily focused on fixing bugs though.
Bump
It’s quite tricky to find documentation about those subjects, aside from @Samuel411 findings (nice investigation btw).