Get the Windows Username

Not as relevant when you are using Steam but if you wanted to use a program in a corporate environment that makes use of an SSO or Single Sign On in Windows, this is how you can retrieve that information from within Unity. The first version of BOLT does not support this so it must be done in code. Here is the code that will sent the username of the person currently signed into windows, to the console window when the program starts.

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

public class testing : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log(Environment.UserName);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

The important part is the “Environment.UserName” but it requires that you have the “using System;” declared or it won’t work.

UPDATE:

In the Bolt setup wizard if you add “Environment” to the types list you will be able to access Environments from within the Graphs.

You can add a lot of new features to Bolt in this way.
Bolt is easily expanded.

Leave a Reply