Skip to content

Bash Script Setup

This guide continues with two options for development setup from the previous step.

  • Github Developer Setup
  • Local File Developer Setup
  • Skip to the next section Setting up Beamable

Enable Github within Unity Package Manager

We'll need to set up a bash script to launch Unity with your configured SSH keys for git.

If you're going to be modifying the core functionality of IdleKit, see the Local Developer Setup.

1. Configure your github account

Make sure configure your github account to connect with SSH.

2. Create a bash script

The bash script below will load your ssh keys and launch Unity. This is required to access private Github repositories.

Create a file with the following contents and save it as launch-showcase.sh on your local drive.

Be sure to update the 3 project setting lines with your own file system locations.

    # Project Settings
    # - Change the 3 lines below to match your setup

    ssh_key_loc='C:\\Users\\Username\\.ssh\\id_ed25519'
    unity_loc='C:\\Program Files\\Unity\\Hub\\Editor\\2019.4.24f1\\Editor\\Unity.exe'
    project_loc='C:\\Projects\\IdleKitExternalDocs\\idlekit-showcase'

    # Please do not edit below this line
    env=~/.ssh/agent.env

    agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

    agent_start () {
    (umask 077; ssh-agent >| "$env")
    . "$env" >| /dev/null ; }

    agent_load_env

    # agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
    agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

    if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
    agent_start
    ssh-add "$ssh_key_loc"
    elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
    ssh-add "$ssh_key_loc"
    fi

    # Expose env variables to native windows
    setx SSH_AGENT_PID "$SSH_AGENT_PID"
    setx SSH_AUTH_SOCK "$SSH_AUTH_SOCK"

    unset env

    "$unity_loc" -projectPath "$project_loc"

3. Launch Unity through Gitbash - Windows Users

For Windows users we recommend using Gitbash to run bash scripts.

For Mac users you may skip this step.

Open GitBash. Running the script above should open Unity correctly. gitbash

Troubleshooting

If Unity attempts to open, but instead Unity hub opens, check the following: - The URLs for your repositories are correct. - You have configured github the connect with ssh and keys. - You can access the repositories through command line with ssh access. - You are running the above bash script with gitbash which configures ssh keys for the terminal session.


Next >> Setting up Beamable