Monday, January 7, 2019

Windows - check to see if a remote server port is open

We can use portqry tool for this. Windows server editions should already come with this tool.

if not already in windows, you can download a command line or UI version from below
https://support.microsoft.com/en-us/help/310099/description-of-the-portqry-exe-command-line-utility

Usage is as below.
For example, to check if servername has port 80 open, do below

portqry -n servername -e 80

Friday, January 4, 2019

Unity - How to take a screenshot in game with script (at a specific resolution)

Attach below script to any object in your game. Click Play in editor and at the desired point, press "z" in keyboard to take your screenshot as a png file (if game is built, use Ctrl-Z). The screenshot will be stored (ie; the save location) in your Unity project's root folder


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TakeScreenShot : MonoBehaviour {

 // Update is called once per frame
 void Update () {
#if UNITY_EDITOR
        if (Input.GetKey(KeyCode.Z))
#else
     if((Input.GetKey(KeyCode.RightControl) 
      || Input.GetKey(KeyCode.LeftControl)) 
        && Input.GetKeyDown(KeyCode.Z))
#endif
        {
            Debug.Log("Taking screenshot");
            ScreenCapture.CaptureScreenshot("ScreenShot-" + 
             UnityEngine.SceneManagement.SceneManager.GetActiveScene().name + 
             ".png");
            Debug.Log("Done");
        }           
    }
}


Tip: If you want a specific resolution of screenshot, make sure to set this in the player (ie; in Game tab)
In the below example, we are setting resolution to 2400 x 1200. When you use above script, the saved screenshot will have the same resolution.

See example below. Use + symbol to add custom resolutions

Saturday, October 20, 2018

Unity Shadows are too Dark or Light


In Unity Inspector, select your Light, and under Shadow Settings, use the Strength slider to change shadow to make it darker or lighter as you like


Friday, October 19, 2018

Oculus Developer: Android APK is signed with Signature Scheme V2, which is not yet supported.

If you are here getting an error uploading an APK to Oculus Store with a build with Unity, see down below

Go to the APK Folder and resign with V1 as below

"C:\Program Files\Java\jdk1.8.0_191\bin\jarsigner" -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore MyApp.keystore "My App Name.apk" "key alias name" -storepass mypassword -keypass mypassword2

If in Unity and you are getting error "Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates", try the change outlined below

Unity: Change build from Gradle to Internal. The apk will be generated using V1 signing, and no need to do the workaround above

Oculus Developer - Gear VR / Oculus Go app is not visible in Oculus app or any screens in the mobile device

You have built and installed the app in your device, but its not visible in the home screens or Device (except the Setting --> Apps screen, which do not have any option to launch it)

This is by design. Gear VR apps will not have a shortcut that you can use to launch it. It have to be launched from the Oculus app only.

To make your app visible inside the app, Upload a binary/apk to one of the Build channels (I have used Alpha) in the Build Dashboard. In the Build Dashboard, you will see an option to add test users as well. Make sure you add yourself. After adding, wait for the email with information on signing up. This may take some time to show up in your inbox (took about 30+ mins for me)

Once you click on the the email invitation link, the app will appear in the My Preview Apps section of Oculus Home

Thursday, October 11, 2018

How to add Basic authentication to a web request


Below is sample C# code where we can inject an Basic Authorization header into a HTTP request


request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password)));

How to close the small square magnifier that pops up on screen on iPhoneX at odd times


To get rid of the magnifying box:

Tap two times (double tap) on screen with three fingers, and on the popup that appears, select Zoom Out

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...