Unity Editor Scripting Tutorial

In this post I am going to share one of the awesome feature of Unity . I really love this feature. if you are an artist or 3d designer(not sure about programmers) you are going to love this .As you may have expected it’s about Editor extension of Unity . Unity allows us to extend it’s editor so that we can build our custom tools .

Consider the following case I have one road, It was created using “Easy Roads 3D”. Easy Roads 3D is a free plugin that allows you to place roads easily on an uneven terrain . see the picture below


It looks cool but there is  one problem as you can see there are no side objects like fence etc . There are two ways to add fence or any other kind of object .

i)Place them one by one and adjust their position and rotation .This method requires a huge amount of time and you may get frustrated doing the same thing again and again .

ii)Automate the process of placing them .In this method you have to write code to automate this process.  I & whole world recommends this.

Below is a script that takes the Road object and places capsules(you can use anything ) .Please note this script doesn’t handle rotation of the side objects . That’s easy to implement though .

Here is the result of the script .


In order to use this script you have to put this  inside editor folder in Unity . It’s only for demo of the feature It’s not a full fledged auto placer you can modify the script if you need advanced features .

Thanks for visiting .






I do what I love. There is a famous quote "Love the process not the product " & I think this is what differentiates developers from consumers .