Search Unity

Where is getPreviewSceneAt and getAllPreviewScenes function?

Discussion in 'Prefabs' started by Thaina, Aug 1, 2019.

  1. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    We have function
    EditorSceneManager.NewPreviewScene
    that cannot do anything. And if we don't cache it ourselves. It will stay in the editor. It will leave it trace only in
    EditorSceneManager.previewSceneCount
    but we have no way to interact with it after that

    Even the source has only
    internal OpenPreviewScene
    (why it was internal though? I think it should be exposed to) I think unity should have put all created PreviewScene in some collection anyway. Please expose that so we could find and close it when it don' needed
     
    forestrf likes this.
  2. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
  4. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,168
    I know that NewPreviewScene will return the created scene. What I mean is, if we lose track of it, it was not garbage collected and it will be leaked forever

    Meanwhile the existence
    previewSceneCount
    indicate existence of the list that contain created previewscenes. So making the list ourselves and save it from `NewPreviewScene` is redundant

    Could you please elaborate how to using stage to solve this problem?
     
  5. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Right, sorry, I was a bit too tired when I answered that post.

    Yeah, it totally makes sense that all the existing preview scenes should be available in some manner. I guess the idea is that other systems ought to own preview scenes, and that killing preview scenes that other windows might own could be bad, but that's just something that should be solved by the user not being an idiot.
     
    Thaina likes this.