Choose your Own Shortcut for Quick Unity3D Doc Access Within VS2019
If you’re using Visual Studio 2019, there’s a handy shortcut you can use to quickly jump to the documentation of any Unity Engine API object or method. You click on the object, press CTRL + SHIFT + M and then press CTRL + H. However, I find this is a bit too fiddly so I found a way to quickly change it to a shortcut I prefer.
Simply go to Tools...Options...Keyboard (on the left)...
Search for “unity” in the “Show commands containing” textbox
Select Help.UnityAPIReference
Click in the Press shortcut keys textbox
Press the key combination you’d like to use and click “Assign”. I preferred CTRL+SHIFT+ALT+H but you can choose what you like (just be careful not to choose a combination that overrides an existing keyboard shortcut)
That’s it! Click on your object in your code, press the combination you selected, and VS will open up the documentation without you having to leave the IDE.
If the gif below is too small, click here for a larger version
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
I posted a comment over on Reddit where someone was asking how people maintain discipline when developing games (although a lot of the theory could be applicable in other fields). I posted an answer with a few points and figured I’d post it here for future reference too.
I find discipline becomes easier when seeing progress so I always try to look back at what's been achieved every few weeks, however small, and be proud of it. Not to make it sound like a feel-good wishy-washy thing but I think it's easy to forget how much you've achieved relative to your skillset and resources when it's so often compared to other people's work (which may be further down the line).
If you still like the game idea, clearly something else is stopping you. Identify what it is. For me, as more of a programmer than an artist, testing the visual side of things seemed like a pain (setting up Unity, making sure camera is correct, finding an image to use etc..). To counter this, I've now created an ever-growing folder of assets I accumulate from the web and set up a prototype project for my game where I can quickly test ideas. This includes backgrounds, sprite-sheets, random images, sound effects, music etc... Therefore whenever I want to prototype anything, I can focus on the programming more than the environment setup.
Find out what your bottlenecks are during development. For me, my PC was slowing down too much and Unity would take a while to load up (didn't take too long but when you're not motivated enough anyway, it's another excuse to 'do it later'), which took me out my zone so I upgraded the RAM and installed an SSD drive. A faster machine makes so much of a difference to me when developing.
I now maintain a personal dev diary with screenshots. In order to be good at this, I customised my workflow to help take GIFs quickly without losing focus (wrote a post here).
The internet is probably the biggest distraction so I now make time at the end of the day to catch up on articles that look interesting but aren't necessarily pertinent to what I'm doing at that time. I wrote a post on here on how I did that.
Play to your mood. If you're really motivated, work on the more 'boring' things if possible such as non-visual/backend stuff. When you're not in the mood, work on something that can give instant feedback which I usually find has visual aspects. The latter also works for when you want to share your work with others here or on Twitter or something and get feedback. (Of course, that's just for me, you may find the backend aspects much more rewarding)
Essentially investing time up front on improving work flow and reducing friction is what got me out of a rut. Doing this felt productive, even if it was something simple as gathering assets for my prototype folder. Then it's a positive cycle as you develop more, you become more self-motivated and I find it perpetuates - just be sure not to burn out and pace yourself; nothing wrong with taking up other hobbies IMHO.
System's not perfect and I still hit developer's block but it's the best thing I've found that works for me personally.
Common Issues when Installing Kali Linux on VirtualBox
I wanted to do some penetration testing against an app of mine and decided to use Kali Linux instead of downloading certain tools individually. In order to do this, I used VirtualBox to run Kali as a guest OS instead of dual booting/replacing my main machine. During setup, I ran into a few issues but fortunately they had easy fixes. However, finding the fixes meant jumping from various forums to forums so I’ve centralised the issues I ran into and the fixes for them below for your convenience.
This was done on a fresh install in a virtual environment so I wasn’t worried about breaking anything. If you’re using any of this on an existing build with existing work, standard disclaimers apply (use at your own risk, backup important files etc…).
Installation Step Failed - Failing step is: Install the system
For me, the fix was to increase the hard drive space allocated to this VM. When creaing the VDI, I used the default 8gb. I recreated the VDI but allocated 30gb instead and it worked fine. (12gb worked fine too but I found that installing updates and upgrades ate into the 12gb very quickly so decided to be more generous)
What’s my username?
This one might seem obvious but if you installed Kali with the Graphical Install, you may have missed the username selection (or maybe that’s just me clicking through after multiple install attempts trying to solve other issues). Either way, the default username when logging in is root and the password is whatever you set during install.
Monitor resolution is not supported in VirtualBox
This one’s an interesting one. I found two separate approaches where one of them worked but I’m not sure if it worked because I performed the first step or if it would’ve worked anyway. The second step below is the one that worked but I performed the first one anyway before it.
Open Terminal and enter apt-get install -y linux-headers-$(uname -r)
You may get an error, like I did, but this doesn’t seem to be an issue
From the VirtualBox window that’s hosting Kali, select Device...Install Guest Additions...
In the terminal, navigate to cd /media/cdrom
Type ls to ensure the VirtualBox additions are present
Type sh VBoxLinuxAdditions.run
Once that’s complete, type reboot to reboot the system (make sure you have anything saved if you’ve been working on something else)
This seemed to have enabled the correct resolution to be fixed for some people but not for me. Once the system is rebooted, open Terminal again
Type in apt-get install virtualbox-guest-x11
Type in reboot to reboot the system again
If you go to Settings in Kali and then Display, you should now be able to select the full resolution list your monitor supports.
Can’t update or find any packages
Interestingly this didn’t happen the first time I installed Kali but did the second time. If you find that no packages are downloading, your sources.list file may be missing the repo location.
Open Terminal (yes, you better get used to the Terminal :D). Type in cat /etc/apt/sources.list and see if the output contains a repo location. Note that anything following a # symbol is a comment so it won’t get executed. I noticed my one did not have a repo directory so I added the one listed on Kali’s official page. At the time of writing, this was
deb http://http.kali.org/kali kali-rolling main contrib non-free
So edit the file (I used gedit /etc/apt/sources.list in Terminal and pasted the url above on a new line). Save the file and you should now be able to download packages.
Updating all packages
I like to keep packages up to date especially after a new OS install. In Terminal, type in apt-get update && apt-get upgrade (this can take 20 mins or so depending on how many updates there are, so do it when you have time)
Hope that helps solve common issues you might face when installing Kali on VirtualBox.
“ToView” Folders - Simple Browser Feature to Help Keep Track
There are already many ToDo lists apps and websites available but I Iike to keep things simple and not have to install/sign up if it can be avoided. So, I’ve started creating what I call “ToView” lists. In my daily web travels, I come across many interesting articles and videos that I simply don’t have time to consume at that moment. They could be bookmarked, and this trick pretty much does that, but the flow of this means that these are designed to be temporary bookmarks rather than permanent (unless, of course, the article turns out to be amazing!). Also, I don’t know about you, but my bookmarks turn out like my exercise books at school did - very tidy for the few pages then I get lazy and dump everything anywhere and everywhere. This process keeps it lean, clean, and quick! Let’s get started.
I’m using Firefox but I’m sure most browsers are capable of doing this. Steps are written below but here’s a GIF that should explain the process. I do this in the morning so the folder is ready for use during the day.
Make sure your bookmarks toolbar is visible (in Firefox, go to View...Toolbars...Bookmarks Toolbar)
Right-click on the toolbar and select New Folder...
Give the folder a name (I call it the date I expect to go through it) and click Add
From now on, during your day, when you come across an article/video/whatever page online but don’t have the time read it there and then, simply select and drag the URL into the folder
Catch up on the folder when you have time and remove the entries after you’ve finished
Rename the folder to the next day (or simply keep it as a permanent fixture if you prefer)
Improve Workflow to Maintain Discipline - Unity3D Menu Items
I haven’t written a blog post in a while, it’s mainly been Reddit or Twitter but thought I’d get back into it. For those who follow me on Twitter, you’ve probably noticed a lot of #GameDev tweets and this will be a post on improving workflow for creating GIFs quickly of your game. Naturally, the same code can be extended for pretty much anything you want to add, so let’s get started.
Why?
I recently tweeted an interesting article on creating GIFs of your game in order to help with marketing. However, I also find creating GIFs useful for the purpose of documentation as well as the ability to be able to look back in the future and be able to see the (hopefully!) improvements and progress the game has made. Additionally, writing a post-mortem of the game would be made easier since you can refer back to the GIFs quickly without having to resort to jumping to past source control commits.
The problem is remembering or bothering to create the GIFs; so creating a good workflow will mean I’m more likely to keep up this practice. Everytime I do a visually significant commit to source control, I now create a GIF of the new feature regardless of how primitive it looks.
How?
Adding menus to the Unity editor is simple and the code snippet below adds a Tools menu which contains an option. Clicking this option will open GifCam, which is the GIF recording tools I’m using, but you can modify it to open whatever you use (I’m happy to hear other suggestions for GIF tools).
Simply create a new Script in Unity, remove the default Start and Update methods and replace it with this.
public class MenuItems : MonoBehaviour { [MenuItem("Tools/GifCam")] private static void NewMenuOption() { Process.Start(@"C:\MyPathToGifCamFolder\GifCam.exe"); } }
Of course, you’d want to change the path to your tool to match your location. MenuItems is the name of my class but you can change that to whatever the you like as well.
The key aspect is the [MenuItem(”Tools/GifCam”)] attribute. Tools is the name of the menu I want to add and GifCam is the name of the menu item. You can add submenus too, for example [MenuItem("Tools/Gif Tools/GifCam")].
Compile the code and look at the menu in Unity, you should have your new menu ready to use!
Now I’m more likely to be good when it comes to keeping up to date with creating GIFs during development. Of course, this could be extended to all sorts of other tools you might want to use intermittently but without having to keep open at all times. Ultimate idea is to improve your workflow to reduce any friction when it comes to developing your game.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
In a similar vein to quickly accessing a word’s definition, I decided to use the same code to find synonyms for words. Simply highlight the word and click the bookmarklet and you’ll be taken to http://www.thesaurus.com with a list of synonyms. As with the other bookmarklets, simply copy the code below and drag it to your bookmark bar.
When I’m reading an article online and I come across a word that I don’t understand, I usually jump to Google and type in “define: <word>”. In a similar way to looping YouTube videos and Autoscrolling web pages, I decided to shorten this process to a single click of a bookmarklet. Simply highlight the word and click the bookmarklet.
Play All Songs in Steam Music Player (and create playlist)
Following on from my previous post on using hotkeys to control Steam Music Player, I now found out that you can't add all songs at once (you can only choose by artist, album, or playlist). I devised a workaround which not only allows you to play all songs in your library but also lets you create a playlist of your entire library for future use.
This works in Windows but there are likely equivalents on OSX/Linux.
Open up command prompt and navigate to your music directory (e.g. cd "C:\MyMusic\")
Type/copy paste in dir /o:n /s/b *.mp3 > queue.m3u8
Check your music directory for a file called "queue.m3u8". Open this in a text editor such as Notepad
You should see a list of all your songs. At the very beginning of the file, add #EXTM3U
Copy this queue.m3u8 file into the database directory of your Steam installation (e.g. C:\Program Files (x86)\Steam\music\_database)
There should be a file called queue.m3u8 already there. Feel free to make a backup of this (it simply contains the current playlist loaded in your music player). Paste your newly created queue.m3u8 in this directory and overwrite the one already there.
Restart Steam Music Player and you should have your entire library ready to listen to whilst playing CS:GO :) Combine it with SteamKeyJ and Steam Music Player becomes much more useful!
Bonus - If you want to create a permanent playlist in Steam so you don't need to keep doing this, simply select the first song, hold shift, and select the last song. Right-click and select 'Create Playlist'. You now have a playlist of your music library.
SteamKeyJ to Control Steam Music Player with your Keyboard
Valve has released Steam Music Player for Steam. It's still in early stages at the moment and is missing certain functionality. One thing I really would like it the ability to use my multimedia keys on my keyboard to control Steam Player from within the game (or anywhere on my PC). For those who've seen TellDJ, you'll know I like my music and my programming. As a result, I created a project this morning to do just that.
SteamKeyJ allows you to bind your keyboard keys to the main functionalities of Steam Music Player, namely:
Play/Pause
Next
Previous
Increase volume
Decrease volume
Mute
Toggle Shuffle
Toggle Repeat
This is just a quick project but I might expand on other missing features if requested. I'm sure the music player will eventually have this built in but I created this tool for me to use a stop-gap. Please let me know if you have any issues. (.NET 4.0 required)
Download here
Source code here
How to use
It's a straightforward app to use. Click on 'Configure Keys', select the box next to the action and press the key you want to assign. Once complete, click save. As long as SteamKeyJ is enabled, pressing that key will control Steam Music Player (assuming it's open).You don't need to be inside Steam to control it, it'll work across the PC. Don't forget that Steam must be running.
Enjoy :)
Update - I also figured out a way to quickly play my entire music collection as opposed to just selecting artists/albums. See here for instructions.
If you've ever tried to right-click on a Google link and copy it, you'll notice that instead of copying the link of the site, it actually copies a very long URL which redirects to Google first. For example, I searched for this blog and right-clicked on the search result and selected "Copy Link Location" (I'm using Firefox). Instead of getting "http://www.keyboardp.me", I get
http://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rj..... <some more stuff that isn't what I want>
I accidentally stumbled upon an easy way to bypass this.
This is pretty annoying when you're trying to get hold of a link. To bypass this, simple right-click and hold anywhere on the page (not on the link), move over the result link you want, and then let go. This should bring up the usual right-click menu where you can select to copy the link location. If you paste the link now, you'll see it's the link of the site itself and not the long Google redirect.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
Display Description When Summary Block is Closed in Visual Studio
When you collapse a summary block in Visual Studio, you lose the description text
Here's a quick tip on how to still be able to read the summary text even when the block is closed so it looks like this
///<summary> ///Cursor placed here for your description ///</summary>
However, anything in line with the first <summary> tag will be shown when the block is closed.
///<summary> This text will be shown when the block is closed... ///...extra text that won't be shown ///</summary>
I ran a quick test to generate help files from the XML using Sandcastle and there didn't seem to be any difference in the output (happy to hear about any anomalies).
Now you can read the summary description without opening the block :)
Two Quick Ways of Opening the Current Explorer Window in CMD
Sometimes you want to open the current Explorer window in Command Prompt (cmd). You could navigate to it in cmd but here are two quick ways to open cmd and have it jump to the folder itself.
1) Hold Shift and right click in an empty space within explorer. In the menu that pops up, there should be an option that says "open command window here". Simply click that :)
2) For a keyboard-only approach, navigate to the folder you want in Explorer, press F4 (so that the address bar is selected), press ESC (so that the address is highlighted), type cmd and press return.
Two easy ways of quickly launching Command Prompt to a folder that might otherwise be a chore to navigate to. This should work in Win 7 and 8 but I haven't tested it on Vista.
About an hour ago I found out Google has a new "Timer" feature which can essentially act as an alarm whilst you're browsing the web. Simply go to google.com and type in, for example, "timer 5 seconds" and after 5 seconds are up it'll play an alarm sound. This is pretty neat but I thought it would be better if I could play one of my own MP3s instead of the alarm sound. Turns out you can.
Host your MP3 file somewhere where it's accessible by a URL (e.g. DropBox, your own server etc..). Highlight the bookmarketlet code below and drag it to the bookmarks bar in your browser. If your browser doesn't support dragging, simply create a new bookmark and copy/paste the code below as the URL (including the javascript: at the beginning).
Now edit the relevant bookmark and replace "MyMP3URL" with your actual URL.
That's it!
From now on after you've performed the search for your timer, simply click the bookmarklet. Hopefully it should start playing your MP3 when the timer goes off.
NOTE 1 - Firefox may ask if you want to leave the page after clicking the bookmarklet. Click Stay on Page.
NOTE 2 - If your MP3 is large, or a full song, it can take a few seconds to buffer. Don't set the timer to a short period (e.g. 10 seconds) because the song might not be ready by then. For short timers it's recommended to keep the default alarm sound or use a small file.
Quickly Remove Line Numbers From Pasted Code In Visual Studio
Sometimes when you try and copy code snippets from a webpage their syntax highlighter doesn't separate the line numbers from the actual code. This means when you paste it in your IDE, you've got the line numbers and the code (which obviously wouldn't compile). Instead of manually going down each line to remove the numbers, you can simply use column select in Visual Studio.
Here's an example of code that copies the line number (don't worry, usually code on this blog won't copy the numbers :))
Copy and paste this into Visual Studio. Hold ALT and highlight the numbers. Notice how columns are selected instead of rows. Highlight the numbers, press Delete and you now have just the code :)
You can press CTRL + K, then CTRL + D to have VS automatically format the document if your code formatting is off.
In the days before generics, ArrayLists were used because you could store any object type in them and have them resize at will which was useful if you didn't know how many objects were to be used (unlike an array which required an explicit capacity at the point of initialization). However, if you're not targeting .NET 1.0,.NET 1.1, or working on legacy code, there's very little reason to use ArrayLists anymore.
System.Collections.Generic Namespace
The System.Collection.Generic namespace was introduced in .NET 2.0 and provided collections and interfaces which guaranteed type-safety. This meant that, for example, a List<string> could only hold string objects. This may seem like a step backwards since ArrayLists can hold any object type but there are performance and stability gains.
Performance
Let's say that a List<T> will replace your ArrayList (they're used in a similar manner so it's likely to be the closest replacement you're looking for). Since a List can only hold one type, there's no need for casting from object type to any other type. ArrayLists can only store object types, so there's constant casting when you retrieve an object from it.
This casting to and from object is particularly expensive when you look at value types (int, bool, enum, floats etc..). Value types need to be boxed when being stored as an object type and unboxed when being retrieved. These are relatively expensive operations which List<T> never has to do because it doesn't store elements a object types (unless, for example, you create a List<object>).
Essentially Lists<T> are faster in general use so that's a big advantage.
Stability
Since List<T> can only store one type (whatever type T is), you know exactly what type to expect when you read from it. So you can safely do this
List<int> myList = new List<int>(); myList.Add(13); myList.Add(37); foreach(int i in myList) { int myInt = i; }
You can be sure that this code is fine because you know that myList will only contain int types. There's no need to do any explicit checking of whether or not i is an int and there's no unboxing involved when reading from the list.
With an ArrayList, you run the risk of accidentally trying to cast to the wrong type which could throw an exception (and exception handling is also an relatively expensive procedure). For example, this would throw an InvalidCastException and whilst this piece of code is obviously wrong, it's not difficult to make a similar mistake in a slightly more complex case.
ArrayList myArrayList = new ArrayList(); myArrayList.Add(13); //insert int myArrayList.Add("37"); //insert string foreach (object o in myArrayList) { int t = (int)o; //exception thrown for "37" }
So, the bottom line is that you shouldn't really be using an ArrayList unless you have a really good reason to. It's pretty much an obsolete class nowadays.
Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
✓ Live Streaming✓ Interactive Chat✓ Private Shows✓ HD Quality
Anya is LIVE right now
FREE
Free to watch • No registration required • HD streaming
Generally it's good idea to handle the exception as soon as possible. However in some cases, you want to re-throw that exception and have it handled later on. I see two common mistakes when doing this whereas the preferred way to do it also requires the least typing; win-win.
Mistake 1 - Throwing a new exception
Throwing a new exception is pointless if you're hoping to get any information. It creates a new exception object and throws it, which means you lose the stacktrace and any information about the actual exception that was thrown.
Mistake 2 - Throwing the exception object
This method might look intuitive but it's slightly deceptive. In Java this would be fine but in C# this loses the original stacktrace and replaces it with a new one that starts from this point (which you likely don't want, you'd rather have the original stacktrace)
try { } catch (Exception ex) { throw ex; //bad }
Recommended approach - Use throw;
Not only does this require the least typing but it also provides the most information. The exception object that is caught is thrown, like the second mistake, but the original stacktrace is maintained so you have as much information as possible about the exception and what lead up to it.
I often spend some time on Stackoverflow and end up seeing common questions or mistakes being repeated. I'm going to start posting some of these, as well as some random code snippets, like a scrapbook with the hashtag #ScrapOverflow (I wasn't going to miss out on that pun).