Friday, 19 May 2017

Unity Level Editor for a special case - Editor Extension (Source Code)


I needed lately to design levels of a special characteristics where everything is made of tiles and there shouldn't be restrictions on angles between different surfaces -- a group of tiles that lie on the same plane.


So I built a special editor that would help me do such a thing easily, of course using Unity editor scripting, and I'm sharing the code with everyone.



As you can notice from the Video, the editor let you lay out copies of a targeted GameObject on imaginary plane, doing that feels like painting. To create a new plane, you need to toggle on "addNewPlane", I know very awful design, but you can alter that to fit your needs.

I'm sorry I didn't comment the code, it was a one purpose editor, but I built it in away that could be expanded to achieve more than its purpose as always, I just like doing that. All the data needed to drive the Editor is in the "Lib.cs" file, this will let you alter the behavior safely. You can contact me if you have any question.

Source Code - BitBucket Repository

Problems :
1) Uncommented Code.
2) Most of the Behavior implementation of this Editor is in one File (EditorWindow.cs), this make things a little messy, I'm not sure if you can follow my code, but as I said contact me.
3) The UI and the Gizmo are bad and ugly. As you can see from the video the circle with an arrow pointing randomly is so awful, and I must change it.

Good Points :
1) The needed Data structure of the Editor are under the NameSpace "Lib" (Must change this name in Future versions), They're well structured so you can alter the behavior safely.
2) If you followed the code carefully, you will learn about Editor Scripting and Quaternions.
2) You can contact me :).

Source Code - BitBucket Repository