Search Unity

Question Instantiate object in front of editor camera?

Discussion in 'Editor & General Support' started by jessee03, Nov 25, 2022.

  1. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    How can I Instantiate an object in front of the editor scene camera?

    This would be the normal way using a ingame camera
    Code (CSharp):
    1. Camera.main.transform.position + Camera.main.transform.forward * distance;
    Reading some documentation it looks like this is how you access the editor camera but am running into errors. Don't think I am able to use transform.forward with this.
    Code (CSharp):
    1. UnityEditor.SceneView.lastActiveSceneView;
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909