Search Unity

Place prefab at certain position with editor script

Discussion in 'Editor & General Support' started by Verdemis, Jul 10, 2020.

  1. Verdemis

    Verdemis

    Joined:
    Apr 27, 2013
    Posts:
    92
    Hello,

    I'm trying to get familiar with the unity editor extrension. I'm trying to write a script which allows me to place prefabs at specific positions. I can add the prefab with PrefabUtility.InstantiatePrefab so far. But the Object always appears at position 0,0,0 ... I tried to manipulate the transform of the created object inside my editor script, but this seams to do nothing.

    Hopefully some has a usefull hint for me :)
     
  2. Verdemis

    Verdemis

    Joined:
    Apr 27, 2013
    Posts:
    92
    Ok I fixed it myself. I accidentally commented out the section where I'm setting the x and z value for the position. It works now.
     
  3. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    196
    just make sure later on you be careful when editing the localPostition vs position.