Make username work on WebGL
hi, i got a project that requires a game , made by WebGL , with username and password but work offline. so i following up some tutorials that can make username and password work offline. but i got some problem that didnt work on WebGL. only work with exe. here's my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Text.RegularExpressions;
using UnityEngine.SceneManagement;
public class Register : MonoBehaviour {
public GameObject username;
public GameObject kantorWilayah;
public GameObject statusCabang;
public GameObject cabangKoord;
public GameObject kodeCabang;
public GameObject inisialCabang;
public GameObject alamat;
public GameObject password;
public GameObject confirmPassword;
private string Username;
private string KantorWilayah;
private string StatusCabang;
private string CabangKoord;
private string KodeCabang;
private string InisialCabang;
private string Alamat;
private string Password;
private string ConfirmPassword;
private string form;
public void Back()
{
SceneManager.LoadScene ("AdminPanel");
}
public void EditID()
{
SceneManager.LoadScene ("EditID");
}
public void RegisterButton()
{
bool UN = false;
bool KW = false;
bool SC = false;
bool CK = false;
bool KC = false;
bool IC = false;
bool ALM = false;
bool PW = false;
bool CPW = false;
//jika terisi username
if (Username != "") {
if (!System.IO.File.Exists (@"D:/UnityAdministrationFolder/" + Username + ".txt")) {
UN = true;
} else {
print ("Kepake");
}
} else {
print ("Kosong");
}
//password
if(Password != "")
{
if(Password.Length > 5)
{
PW = true;
}
else{
Debug.LogWarning("Password kudu lebih dr 6 karakter");
}
}
else{
Debug.LogWarning("Password kosong");
}
if(ConfirmPassword != "")
{
if(ConfirmPassword == Password)
{
CPW = true;
}else{
Debug.LogWarning("Konfirmasi Password ga sama");
}
}else{
Debug.LogWarning("Konfirmasi Password kosong");
}
//KantorWilayah
if (KantorWilayah != "") {
KW = true;
}
if (StatusCabang != "") {
SC = true;
}
if (CabangKoord != "") {
CK = true;
}
if (KodeCabang != "") {
KC = true;
}
if (InisialCabang != "") {
IC = true;
}
if (Alamat != "") {
ALM = true;
}
if(UN == true&&PW == true&&CPW == true&&KW == true&&SC == true&&CK == true&&KC == true&&IC == true&&ALM == true)
{
bool Clear = true;
int i = 1;
foreach(char c in Password)
{
if(Clear)
{
Password = "";
Clear = false;
}
i++;
char Encrypted = (char)(c * i);
Password += Encrypted.ToString();
}
form = (Username + Environment.NewLine + KantorWilayah + Environment.NewLine + StatusCabang + Environment.NewLine + KodeCabang + Environment.NewLine + InisialCabang + Environment.NewLine + Alamat + Environment.NewLine + Environment.NewLine + Password);
System.IO.File.WriteAllText(@"D:/UnityAdministrationFolder/" + Username + ".txt", form);
username.GetComponent<InputField> ().text = "";
kantorWilayah.GetComponent<InputField> ().text = "";
statusCabang.GetComponent<InputField> ().text = "";
cabangKoord.GetComponent<InputField> ().text = "";
kodeCabang.GetComponent<InputField> ().text = "";
inisialCabang.GetComponent<InputField> ().text = "";
alamat.GetComponent<InputField> ().text = "";
password.GetComponent<InputField> ().text = "";
confirmPassword.GetComponent<InputField> ().text = "";
SceneManager.LoadScene ("Title");
}
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.Tab)) {
if (kantorWilayah.GetComponent<InputField> ().isFocused) {
statusCabang.GetComponent<InputField> ().Select ();
}
if (statusCabang.GetComponent<InputField> ().isFocused) {
cabangKoord.GetComponent<InputField> ().Select ();
}
if (cabangKoord.GetComponent<InputField> ().isFocused) {
kodeCabang.GetComponent<InputField> ().Select ();
}
if (kodeCabang.GetComponent<InputField> ().isFocused) {
inisialCabang.GetComponent<InputField> ().Select ();
}
if (inisialCabang.GetComponent<InputField> ().isFocused) {
alamat.GetComponent<InputField> ().Select ();
}
if (alamat.GetComponent<InputField> ().isFocused) {
username.GetComponent<InputField> ().Select ();
}
if (username.GetComponent<InputField> ().isFocused) {
password.GetComponent<InputField> ().Select ();
}
if (password.GetComponent<InputField> ().isFocused) {
confirmPassword.GetComponent<InputField> ().Select ();
}
}
if (Input.GetKeyDown (KeyCode.Return)) {
if (Username != ""&&StatusCabang != ""&&Password != ""&&ConfirmPassword != ""&&KantorWilayah != ""&&CabangKoord != ""&&KodeCabang != ""&&InisialCabang != ""&&Alamat != "") {
RegisterButton ();
}
}
Username = username.GetComponent<InputField> ().text;
Password = password.GetComponent<InputField> ().text;
ConfirmPassword = confirmPassword.GetComponent<InputField> ().text;
KantorWilayah = kantorWilayah.GetComponent<InputField> ().text;
StatusCabang = statusCabang.GetComponent<InputField> ().text;
CabangKoord = cabangKoord.GetComponent<InputField> ().text;
KodeCabang = kodeCabang.GetComponent<InputField> ().text;
InisialCabang = inisialCabang.GetComponent<InputField> ().text;
Alamat = alamat.GetComponent<InputField> ().text;
}
}
hope someone can help. i looking for a solution out there , but i didnt understand how to use ExternalCall or ExternalEval. someone can help me? thanks for any help
Comment
Your answer
Follow this Question
Related Questions
LogIn Using SQL stored procedure 0 Answers
C# to WebGL 2 Answers
WebGL issue - Release Build triggers error, Development Build runs fine 0 Answers
How to Make Proper Font used in WebGL build? 2 Answers
Pass mouseevents from Iframe to unity application (WebGL) 0 Answers