During the last week, I have spent a lot of time focusing on creating tools in Unity for shortcuts and usefulness during the next project. At the moment, some of these tools seem incomplete to me, but I’m sure as I find needs to use them, I will realise what is missing and will be able to expand upon them to make them even more useful.
1. Transform Extension
I created a small extension for the transform compoent that adds buttons in that allows me to reset the position, rotation and scale sperately. Many times I have found I am tying 0, then pressing tab, then typing 0 again just to reset one of the three. If you right click on the transform compoent, there is a reset option, but that resets all of them back to 0. Majority of the time, that is not what I want, so I created this small tool to add the buttons.
2. Reset PlayerPrefs
In the past when I was creating a highscore table and saving the highscore in playerprefs, I found that sometimes I would want to reset all the data and I would have to put that in the code, then comment it out when I didn’t need it. Sometimes I forgot to uncomment when I needed to and that messed with me a little. So I created a really simple tool that just resets all the playerprefs. In the future, I want to expand it so you can specify which one to delete.
3. Text mesh Extension
Another really simple tool here. I have always disliked how text meshes only have 1 line which you can write stuff. If I needed multiple lines, I would have to write it in notepad or some other equivalent then copy it into the text mesh text field. I struggled with this one because ororiginallyanted to override the original text field with my own which would mean implementing everything again. I was using a text area, but that requires a rectangle parameter, and I couldn’t find a good way to get the correct position because (0,0) is the top left of the whole inspector, not just that component. In the end, I just settled for adding a larger text area at the end of the component which updates the single line text one when modified to keep consistency.
4. Path builder
This one was created for the project I am currently working on. As it has tower defense in it, I thought that we would need paths for them to follow. So I created a tool that allows the player to place points, choose the path object and click a button to create the path so it perfectly lines up. During the creation of this tool, I ran into an issue with rotating to look at objects in a 2D space. I forgot that LookAt was a 3D space function and it was making them do weird things. So I used a bit of trigonometry to work out the angle, and then it was all good. My problem with this tool is that the paths overlap and if you have a sprite, it will look weird. I will need to reconsider how to do this in the future to make it more useful. This and my next tool are ones I really want to keep working on to make them much more useful.
5. GUI Anchor Points
This one I am quite happy with so far, mainly because I completed it while I was half asleep at 3am in the morning. This tool allows a user to give it sprites and an anchor point then press the button to automatically apply them to the camera as a child. It makes aligning things a lot easier. My main problem I ran into here was that getting the camera size in ortho was the height and not the width. So if the size was 5, that is 5 up and down, but not left to right. This meant that anchors are not exactly on the side. To counter this, I added a padding section allowing the user to move them left and right as well and up and down as desired after they were anchored. At the moment, it will support any gameobjects, so that means it can be quite flexible by allowing the user to put sprites and even text in there, but I want to do more with this tool. I wanted to make a preview window so the user can see what it will look like before it is generated, but so far, I haven’t found a really good solution to that. So in the mean time, there is a delete GUI button to remove it without the user having to manually delete the objects. Anyway, enough rambling, here are the pics.