Monday, December 11, 2017

Unity 3D Adding MouseLook from Standard assets gives error - The script needs to derive from MonoBehaviour

You get this error trying to add MoseLook from Assets\Standard Assets\Characters\FirstPersonCharacter\Scripts
Can't add script behaviour MouseLook. The script needs to derive from MonoBehaviour!

You can use the alternative SimpleMouseRotator from Assets\Standard Assets\Utility

Sunday, December 3, 2017

Adjusting vim window size for higher resolutions (ex: 4k monitors)

vim loads with a tiny window screen by default in a 4k monitor.



To fix,

  1. Pick a font with right size using Edit --> Select Font you like so the window looks nice. 
  2. Once the window looks good, use below to find the current font settings
  3. Press Shift and :
  4. Type in set gfn? and hit Enter
  5. You should see the current font setting. For example, I got guifont=Consolas:h10:cANSI:qDRAFT
  6. Press Shift and :
  7. Type in e $MYVIMRC and hit Enter
  8. You will now be eiditing your _vimrc file. In windows you can find this file in "C:\Program Files (x86)\Vim" assuming default vim installation options
  9. Note: You may not have permission to write this file. If this is the case, please launch with Admin privileges or open the file in your favorite text editor with Admin privileges
  10. Enter Line from (5) as the first line of the file after adding set to the front. Example set guifont=Consolas:h10:cANSI:qDRAFT
  11. Note: if there are spaces, make sure to add a slash \ just before it.  
  12. Save the file and restart it
My _vimrc after update below

Friday, December 1, 2017

C# how to initiate a List via constructor

Example of a string List initialization in one line below


//Create list strCollection and assign string A, B, C & D to it!
List<string> strCollection = new List<string>() { "A", "B", "C", "D" };


Convert C# foreach loop to process in parallel

Note: this is a C# 4.0 feature

The first loop run in a serial matter, and the second one parallel. First one is guaranteed output ABCD, but the second write these characters in a random fashion

List<string> strCollection = new List<string>() { "A", "B", "C", "D" };
// Process one at a time
foreach (string str in strCollection)
{
    Console.WriteLine(str);
}
// Process in parallel
System.Threading.Tasks.Parallel.ForEach(strCollection, str =>
{
    Console.WriteLine(str);
});


Turn on Windows 11 Fast Boot

If windows starting is slow, to enable windows 11 fast startup/boot,  Press Windows + R, type powercfg.cpl, and hit Enter.  This will direct...