Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Instantiate object in front of editor camera?

Discussion in 'Editor & General Support' started by jessee03, Nov 25, 2022 at 2:35 AM.

  1. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    697
    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,232
unityunity