petrepa / TFE4580

Specialization project for my master thesis at NTNU
2 stars 0 forks source link

Add random participant number to main screen 🔢🔀🔡 #23

Closed petrepa closed 4 years ago

petrepa commented 4 years ago

To log participant without revealing identification.

petrepa commented 4 years ago

Fix 🥳

Made ParticipantNumber.cs and added to some text objects on the main scene.

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

public class ParticipantNumber : MonoBehaviour
{
    const string glyphs= "ABCDEFGHIJKLMNOP0123456789"; //add the characters you want
    private Text text;

    void Start(){
        text = GetComponent<Text>();
        var partNum = "";

        for(int i=0; i<4; i++)
        {
            partNum += (glyphs[Random.Range(0, glyphs.Length)]).ToString();
        }

        text.text = "#" + partNum;
    }
}

Commit: https://github.com/petrepa/TFE4580/commit/2218c7649328e909d11e97cc71c0006201828371