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

Thursday, August 2, 2018

Unity Pause Un-Pause game while using Oculus Rift


Make sure you install Oculus Utilities & Oculus Platform packages
https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5/
https://developer.oculus.com/downloads/package/oculus-platform-sdk/

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

public class GamePause : MonoBehaviour
{
    [SerializeField] private GameObject pauseObject;
    private AudioSource audioSource; // assuming music is attached to this GO
    private void OnEnable()
    {
        OVRManager.HMDUnmounted += PauseGame;
        OVRManager.HMDMounted += UnPauseGame;
        OVRManager.VrFocusLost += PauseGame;
        OVRManager.VrFocusAcquired += UnPauseGame;
        audioSource = GetComponent();
    }

    private void OnDisable()
    {
        OVRManager.HMDUnmounted -= PauseGame;
        OVRManager.HMDMounted -= UnPauseGame;
        OVRManager.VrFocusLost -= PauseGame;
        OVRManager.VrFocusAcquired -= UnPauseGame;
    }

    private void PauseGame()
    {
        if (pauseObject != null)
            pauseObject.SetActive(true);
        Time.timeScale = 0.0f;
        if (audioSource != null)
            audioSource.Pause();
    }

    private void UnPauseGame()
    {
        if (OVRManager.hasVrFocus)
        {
            if (pauseObject != null)
                pauseObject.SetActive(false);
            Time.timeScale = 1.0f;
            if (audioSource != null)
                audioSource.UnPause();
        }
    }
}

Wednesday, August 1, 2018

type or namespace Oculus could not be found while trying to include "using Oculus.Platform" in Unity


Make sure you install Oculus Utilities & Oculus Platform packages both

https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5/
https://developer.oculus.com/downloads/package/oculus-platform-sdk/

If TestEntitlementCheck failed while running OculusVRCValidator

Sample Entitlement check file

Make sure you install Oculus Utilities & Oculus Platform packages
https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5/
https://developer.oculus.com/downloads/package/oculus-platform-sdk/


using UnityEngine;
using System.Collections;
using Oculus.Platform;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

public class EntitlementManager : MonoBehaviour
{
 
    public string appId;
    public static bool entSucceded = false;

    void Start()
    {
        // Core.Initialize(appId);
        if (!entSucceded)
        {
            Core.AsyncInitialize(appId);
            Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementChecked);
        }
    }

    /*
    void Update()
    {
        Request.RunCallbacks();
    } */

    void EntitlementChecked(Message msg)
    {

        // Ok
        if (!msg.IsError)
        {
            // Do what you want, load main menu
            // SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
            Debug.Log("Ent success!");
        }
        // Not Ok
        else
        {
            //UnityEngine.Application.Quit();
            SceneManager.LoadScene("EntFailed", LoadSceneMode.Single);
            Debug.Log(msg.GetError());
            entSucceded = true;
        }
    }
}

ERROR: Failed to receive a call for ovr_RecenterTrackingOrigin or ovr_ClearShouldRecenterFlag within 1 second of recentering request

Starting TestResponseToRecenterRequest
Waiting for the application to run for 5 seconds before testing begins...
Starting test...
Sending a request to recenter...
ERROR: Failed to receive a call for ovr_RecenterTrackingOrigin or ovr_ClearShouldRecenterFlag within 1 second of recentering request
Please refer to VRC Guidelines: https://developer.oculus.com/distribute/latest/concepts/vrc-pc-input-3/
Cleaning up...
Test FAILED


Solution: Attach OVRManager Script to an object in game

Friday, July 20, 2018

c# asp.net - simple aspx file to upload a file to server

Save below as an .aspx file in IIS.

<%@ Page Language="C#" AutoEventWireup="true" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test Upload file</title>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
 <input type="file" id="myFile" name="myFile" />
 <asp:Button runat="server"
   ID="btnUpload" OnClick="btnUploadClick" Text="Upload" />
</form>
<script runat=server>
protected void btnUploadClick(object sender, EventArgs e)
{
    HttpPostedFile file = Request.Files["myFile"];

    //check file was submitted
    if (file != null && file.ContentLength > 0)
    {
        string fname = System.IO.Path.GetFileName(file.FileName);
        file.SaveAs((System.IO.Path.Combine("C:/Temp/", fname)));
    }
}
</script>
</body>
</html>

Thursday, July 19, 2018

Unity VR (XR) camera not located at the position you add it in the scene


The camera is directly controlled by the engine and you may not be able to specify its position. What you have to do is to center the camera in the scene (0,0,0) and then put this inside a empty object. You can then position this camera containing object to where you want the player camera to be located


It may be a good practice to call below just to be sure camera is initialized and centered just before your scene starts
UnityEngine.XR.InputTracking.Recenter();

Wednesday, July 11, 2018

Batch convert using ffmpeg

Say you have some folder and sub-folders full of .wav files and want to convert them all to .mp3 at a single shot, try the below



  1. Get ffmpeg
  2. Copy the below command from down below and save it in a .bat file
  3. Make sure the ffmpeg path is correct in the command
  4. Make sure the file is saved in the root folder where you want the files to be converted.
  5. Run the bat file you have created

for /R %%g in (*.wav) do start /b /wait "" "C:\ffmpeg-4.0.1-win64-static\bin\ffmpeg" -threads 16 -i "%%g" -acodec libmp3lame "%%~dpng.mp3" && del "%%g"



Monday, June 25, 2018

Removing outlook profile

Outlook giving error "Before deleting the e-mail account containing your personal mail, contacts, and calendar data, you must create a new location for your data", when trying to remove email account

I have tried this with Outlook 2016 in Windows 10


  1. Close Outlook if its running
  2. Start -> Run (or Win Key + R) -> outlook.exe /manageprofiles -> OK
  3. Click "Show Profiles" button and delete it
  4. Close window and start outlook
  5. Outlook should ask to create a new profile now
  6. Now you can enter your email address and configure outlook as normal


Wednesday, May 9, 2018

Setting a proxy for a standalone Microsoft .Net application

  1. Find the applications install location (or .exe location). If you are using a shortcut, you can right click, and check the properties to find this place.
  2. Locate your applications .config file. Typically this will be in the same folder as your .exe; For example, for myappname.exe, you should be able to see myappname.exe.config in the same directory
  3. Create one if there there is only not already present. Make sure to name it myappname.exe.config
  4. If creating a new file, Open the newly created file in notepad, and paste the below into it. Make sure to change proxyservernameproxyserverport in your environment
  5. if file already exists, add the defaultProxy section as shown below and save file
  6. Restart the application
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
      <proxy proxyaddress="http://proxyservername:proxyserverport/" bypassonlocal="false" usesystemdefault="false" autoDetect="false" />
    </defaultProxy>
  </system.net>
</configuration>


Adding a new resource to Microsoft High Availability Cluster

The following was tried on Windows Server 2012 R2

Here I am giving an example of a Service; you can start an application or a script or a multitude of options that comes with the cluster software

1.  Bring up the Failover Cluster Manager

1.Right click on computer, click manage
2.Select Tools à Failover Cluster Manager

2.  Adding Role

1.Expand down to Roles
2.From Right side, click Create Empty Role
3.“New Role” is created
4.Click on “New Role”
5.Select properties, and set Name as “My Service” or any name you prefer

3.  Adding your service

1.Right Click on newly created “My Service” Role
2.Pick Option “Add Resource”à Generic Service
3.Pick “Your Servie To Use” from list and click Next, Next and Finish

4.To Start the service, Right click again on “My Service” and select “Start Role”

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