0% found this document useful (0 votes)
93 views

Scripts

This document contains code for managing scenes and loading scenes in response to image targets and user input in an augmented reality application. It includes classes for calling scenes, changing scenes, checking keys, and handling a database. Methods detect when targets are found/lost and load corresponding scenes. A database handler class handles user creation, validation of activation keys, and loading appropriate starting scenes.

Uploaded by

Gris Depandi
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

Scripts

This document contains code for managing scenes and loading scenes in response to image targets and user input in an augmented reality application. It includes classes for calling scenes, changing scenes, checking keys, and handling a database. Methods detect when targets are found/lost and load corresponding scenes. A database handler class handles user creation, validation of activation keys, and loading appropriate starting scenes.

Uploaded by

Gris Depandi
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

CallScenes.

CS

using System.Collections;
using System.Collections.Generic;
using System.IO;

using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
using EasyAR;

namespace Sample
{
public class CallScenes : ImageTargetBehaviour
{
public string SceneCall;
private bool toggle = false;
public string Ddf;
public string SceneJsonNames;
public string SeriesCheck;
protected override void Awake()
{

base.Awake();
//Ddf = "Back";
//System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"Camera.txt", null);
//System.IO.File.WriteAllText(Application.persistentDataPath + "/" +
"Camera.txt", Ddf);
TargetFound += OnTargetFound;
TargetLost += OnTargetLost;
TargetLoad += OnTargetLoad;
TargetUnload += OnTargetUnload;
QualitySettings.vSyncCount=0;
Application.targetFrameRate=24;
}

void OnTargetFound(TargetAbstractBehaviour behaviour)


{
SceneManager.LoadScene(SceneCall);
Debug.Log("Found: " + Target.Id);

}
public void changeMonsterOn()
{
Debug.Log("Sivasankari");
if (toggle == false)
{
toggle = true;
SceneManager.LoadScene("Frontgame");
}
else
{
SceneManager.LoadScene("Game");
}

}
public void ChangeFlashFront(string Scenee)
{

MYSCEN callsces = new MYSCEN();


callsces.name = Scenee;
string output1 = JsonUtility.ToJson(callsces);

File.WriteAllText(Application.persistentDataPath + "/" +
SceneJsonNames + ".json", output1);

SceneManager.LoadScene(Scenee);
}
void OnTargetLost(TargetAbstractBehaviour behaviour)
{
Debug.Log("Lost: " + Target.Id);
}

void OnTargetLoad(ImageTargetBaseBehaviour behaviour,


ImageTrackerBaseBehaviour tracker, bool status)
{
Debug.Log("Load target (" + status + "): " + Target.Id + " (" +
Target.Name + ") " + " -> " + tracker);
}

void OnTargetUnload(ImageTargetBaseBehaviour behaviour,


ImageTrackerBaseBehaviour tracker, bool status)
{
Debug.Log("Unload target (" + status + "): " + Target.Id + " (" +
Target.Name + ") " + " -> " + tracker);
}
public class MYSCEN
{
public string name;

}
}
}

SceneChanger.cs

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

public class SceneChanger : MonoBehaviour


{
public string Scene_Name;
public string SceneJsonNames;
public string JsonNames;
public Text CallText;
// Use this for initialization
void Start()
{
Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
QualitySettings.vSyncCount=0;
Application.targetFrameRate=24;

}
public void ScensChanging()
{
StartCoroutine(CheckS());
}
// Update is called once per frame
void Update()
{

}
IEnumerator CheckS()
{
yield return new WaitForSeconds(2.0f);

FileInfo theSourceFile = new FileInfo(Application.persistentDataPath + "/"


+ JsonNames + ".json");
if ((!theSourceFile.Exists) || (theSourceFile.Length == 0))
{
CallText.text=JsonNames;
SceneManager.LoadScene("MyLOgin", LoadSceneMode.Single);

}
else
{
FileInfo theSourceFile1 = new FileInfo(Application.persistentDataPath +
"/" + SceneJsonNames + ".json");
if ((theSourceFile1.Exists) || (theSourceFile1.Length != 0))
{
string output1 = File.ReadAllText(Application.persistentDataPath +
"/" + SceneJsonNames + ".json"); //read Values from json file and print values
MYSCEN jsprint = JsonUtility.FromJson<MYSCEN>(output1);
Debug.Log("Name: " + jsprint.name);
SceneManager.LoadScene(jsprint.name, LoadSceneMode.Single);
}

}
}
public class MYSCEN
{
public string name;

}
Check_Key_here.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.IO;

public class Check_Key_here : MonoBehaviour


{
public string Scene_Name;
// Use this for initialization
void Start()
{
Screen.autorotateToLandscapeLeft = false;
Screen.autorotateToLandscapeRight = false;
Application.targetFrameRate=24;
QualitySettings.vSyncCount=0;
StartCoroutine(CheckS());
}

// Update is called once per frame


void Update()
{

}
IEnumerator CheckS()
{
yield return new WaitForSeconds(2.0f);
SceneManager.LoadScene("Index", LoadSceneMode.Single);
/*
FileInfo theSourceFile = new FileInfo(Application.persistentDataPath + "/"
+ "Activation.json");
if ((!theSourceFile.Exists) || (theSourceFile.Length == 0))
{
SceneManager.LoadScene(Scene_Name, LoadSceneMode.Single);
}
else
{
FileInfo theSourceFile1 = new FileInfo(Application.persistentDataPath +
"/" + "myscen.json");
if ((theSourceFile1.Exists) || (theSourceFile1.Length != 0))
{
string output1 = File.ReadAllText(Application.persistentDataPath +
"/myscen.json"); //read Values from json file and print values
MYSCEN jsprint = JsonUtility.FromJson<MYSCEN>(output1);
Debug.Log("Name: " + jsprint.name);
SceneManager.LoadScene(jsprint.name, LoadSceneMode.Single);
}

}*/
}
public class MYSCEN
{
public string name;

}
}

DatabaseHandler.cs

using UnityEngine;
using UnityEngine.UI;
using System;
using System.Threading;
using System.Text;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using System.Security.Cryptography;

using System.Text.RegularExpressions;
using DeadMosquito.AndroidGoodies;
public class DatabaseHandler : MonoBehaviour
{
public InputField SecretKEYTEXT; public GameObject success; public GameObject
failure;
public string deviceID;
public string JsonNames;
public string SceneJsonNames;
private string SecretKEY; private string charname1; private string charname2;
public string HashKEY;
private string SecretsKEY;
public string CreateUserURL;
public string Myscene;
public Text MessageText;
public Text KeySecretText;

public GameObject SuccessMSG;


public GameObject FailureMSG;
public string ADSDE="ADS";
void Start()
{

Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
Application.targetFrameRate=24;
QualitySettings.vSyncCount=0;
}
public void OnSubmit()
{
CreateUser();

}
public void CreateUser()
{
charname1 = "85"; charname2 = "arhimaya";
KeySecretText = GameObject.Find("Siva").GetComponent<Text>();
SecretKEY = KeySecretText.text+SecretKEYTEXT.text;

deviceID = AGDeviceInfo.GetAndroidId();
//deviceID = "Sankari63";
string dates = System.DateTime.Now.ToString("dd/MM/yyyy");
int months = System.DateTime.Now.Month;//et_Month();

WWWForm form = new WWWForm();


form.AddField("secretkey", HashKEY);
form.AddField("deviceid", deviceID);
if(SecretKEY.Contains("WS1"))
{
Myscene="WS1Back";
JsonNames="WS1";
SceneJsonNames="SWS1";

}
else if(SecretKEY.Contains("WS2"))
{
Myscene="WS2Back";
JsonNames="WS2";
SceneJsonNames="SWS2";
}
else if(SecretKEY.Contains("WS3"))
{
Myscene="WS3Back";
JsonNames="WS3";
SceneJsonNames="SWS3";
}
else if(SecretKEY.Contains("WS4"))
{
Myscene="WS4Back";
JsonNames="WS4";
SceneJsonNames="SWS4";
}
else if(SecretKEY.Contains("WS5"))
{
Myscene="WS5Back";
JsonNames="WS5";
SceneJsonNames="SWS5";
}
form.AddField("activationkey", SecretKEY);

// Debug.Log(deviceID + charname + dates + months);


CreateUserURL =
"https://shristeear.com/shristeearvideo/arhimaya_products/animalsar/login.php";
//CreateUserURL = "http://34.231.33.25/arhimaya/Appreg/newsar.php";
Debug.Log(CreateUserURL);
WWW www = new WWW(CreateUserURL, form);
StartCoroutine(WaitForRequest(www));

}
public IEnumerator WaitForRequest(WWW www)
{//Thread.Sleep (100);
yield return www;

if (www.text == "unauthorized")
{
Debug.Log(www.text);
FailureMSG.SetActive(true);
SuccessMSG.SetActive(false);
MessageText.text = www.text;
}
else if (www.text == "Invalid Key")
{
Debug.Log(www.text);
FailureMSG.SetActive(true);
SuccessMSG.SetActive(false);
MessageText.text = www.text;
}
else if (www.text == "Already activated")
{
Debug.Log(www.text);
MessageText.text = www.text;
FailureMSG.SetActive(true);
SuccessMSG.SetActive(false);
}
else if (www.text == "Success")
{
Debug.Log(www.text);
MYSCEN callsces=new MYSCEN();
FailureMSG.SetActive(false);
SuccessMSG.SetActive(true);
MessageText.text = www.text;
jsonvalues myjson = new jsonvalues(); //class object create
callsces.name=Myscene;
string output1 = JsonUtility.ToJson(callsces);
myjson.MACID = deviceID; //values set using object
myjson.ACTKEY = SecretKEY; //values set using
object
string output = JsonUtility.ToJson(myjson); //values print output
Debug.Log(output);

File.WriteAllText(Application.persistentDataPath +
"/"+JsonNames+".json", output);
File.WriteAllText(Application.persistentDataPath +
"/"+SceneJsonNames+".json", output1); //Create json file and store values
NOADS myjson2 = new NOADS(); //class object create
myjson2.ADSCHECK = ADSDE; //values set using object
string output3 = JsonUtility.ToJson(myjson2); //values print output

File.WriteAllText(Application.persistentDataPath +
"/AdsActivation.json", output3);
Debug.Log(Application.persistentDataPath + "/Activation.json");
SceneManager.LoadScene(Myscene, LoadSceneMode.Single);

}
}
public class jsonvalues
{
public string MACID;
public string ACTKEY;

}
public class Series2
{
public string MACID;
public string ACTKEY;

}
public class Series3
{
public string MACID;
public string ACTKEY;

}
public class Series4
{
public string MACID;
public string ACTKEY;

}
public class Series5
{
public string MACID;
public string ACTKEY;

}
public class NOADS
{
public string ADSCHECK;

}
public class MYSCEN
{
public string name;

}
public void shareText1()
{
string CreateUserURL1 =
"http://34.231.33.25/arhimayapackage/ayyanshare.php";
WWWForm form1 = new WWWForm();
form1.AddField("nulli", "oo");
WWW www1 = new WWW(CreateUserURL1, form1);
StartCoroutine(WaitForRequest1(www1));
}
public IEnumerator WaitForRequest1(WWW www1)
{//Thread.Sleep (100);
yield return www1;
string lin = (www1.text).ToString();
Debug.Log(lin);
//execute the below lines if being run on a Android device
#if UNITY_ANDROID
//Refernece of AndroidJavaClass class for intent
AndroidJavaClass intentClass = new
AndroidJavaClass("android.content.Intent");
//Refernece of AndroidJavaObject class for intent
AndroidJavaObject intentObject = new
AndroidJavaObject("android.content.Intent");
//call setAction method of the Intent object created
intentObject.Call<AndroidJavaObject>("setAction",
intentClass.GetStatic<string>("ACTION_SEND"));
//set the type of sharing that is happening
intentObject.Call<AndroidJavaObject>("setType", "text/plain");
//add data to be passed to the other activity i.e., the data to be sent
intentObject.Call<AndroidJavaObject>("putExtra",
intentClass.GetStatic<string>("EXTRA_SUBJECT"), "App");
intentObject.Call<AndroidJavaObject>("putExtra",
intentClass.GetStatic<string>("EXTRA_TEXT"), lin);
//get the current activity
AndroidJavaClass unity = new
AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity =
unity.GetStatic<AndroidJavaObject>("currentActivity");
//start the activity by sending the intent data
currentActivity.Call("startActivity", intentObject);
#endif

using UnityEngine;
using UnityEngine.UI;
using System;
using System.Threading;
using System.Text;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using System.Security.Cryptography;

using System.Text.RegularExpressions;
using DeadMosquito.AndroidGoodies;
public class DatabaseHandler : MonoBehaviour
{
public InputField SecretKEYTEXT; public GameObject success; public GameObject
failure;
public string deviceID;
private string SecretKEY; private string charname1; private string charname2;
public string HashKEY;
public string CreateUserURL;
public string Myscene;
public Text MessageText;

public GameObject SuccessMSG;


public GameObject FailureMSG;
public string ADSDE="ADS";
void Start()
{

Screen.autorotateToLandscapeLeft = true;
Screen.autorotateToLandscapeRight = true;
}
public void OnSubmit()
{
CreateUser();

}
public void CreateUser()
{
SecretKEY = SecretKEYTEXT.text; charname1 = "85"; charname2 = "arhimaya";
deviceID = AGDeviceInfo.GetAndroidId();
//deviceID = "Sankari63";
string dates = System.DateTime.Now.ToString("dd/MM/yyyy");
int months = System.DateTime.Now.Month;//et_Month();

WWWForm form = new WWWForm();


form.AddField("secretkey", HashKEY);
form.AddField("deviceid", deviceID);
if(SecretKEY.Contains("WS1"))
{
Myscene="WS1Back";
}
else
{
Myscene="WS2Back";
}
form.AddField("activationkey", SecretKEY);

// Debug.Log(deviceID + charname + dates + months);


CreateUserURL =
"https://shristeear.com/shristeearvideo/arhimaya_products/animalsar/login.php";
//CreateUserURL = "http://34.231.33.25/arhimaya/Appreg/newsar.php";
Debug.Log(CreateUserURL);
WWW www = new WWW(CreateUserURL, form);
StartCoroutine(WaitForRequest(www));

}
public IEnumerator WaitForRequest(WWW www)
{//Thread.Sleep (100);
yield return www;

if (www.text == "unauthorized")
{
Debug.Log(www.text);
FailureMSG.SetActive(true);
SuccessMSG.SetActive(false);
MessageText.text = www.text;
}
else if (www.text == "Invalid Key")
{
Debug.Log(www.text);
FailureMSG.SetActive(true);
SuccessMSG.SetActive(false);
MessageText.text = www.text;
}
else if (www.text == "Already activated")
{
Debug.Log(www.text);
MessageText.text = www.text;
FailureMSG.SetActive(true);
SuccessMSG.SetActive(false);
}
else if (www.text == "Success")
{
Debug.Log(www.text);
MYSCEN callsces=new MYSCEN();
FailureMSG.SetActive(false);
SuccessMSG.SetActive(true);
MessageText.text = www.text;
jsonvalues myjson = new jsonvalues(); //class object create
callsces.name=Myscene;
string output1 = JsonUtility.ToJson(callsces);
myjson.MACID = deviceID; //values set using object
myjson.ACTKEY = SecretKEY; //values set using
object
string output = JsonUtility.ToJson(myjson); //values print output
Debug.Log(output);

File.WriteAllText(Application.persistentDataPath + "/Activation.json",
output);
File.WriteAllText(Application.persistentDataPath + "/myscen.json",
output1); //Create json file and store values
NOADS myjson2 = new NOADS(); //class object create
myjson2.ADSCHECK = ADSDE; //values set using object
string output3 = JsonUtility.ToJson(myjson2); //values print output

File.WriteAllText(Application.persistentDataPath +
"/AdsActivation.json", output3);
Debug.Log(Application.persistentDataPath + "/Activation.json");
SceneManager.LoadScene(Myscene, LoadSceneMode.Single);

}
}
public class jsonvalues
{
public string MACID;
public string ACTKEY;

}
public class NOADS
{
public string ADSCHECK;

}
public class MYSCEN
{
public string name;

}
public void shareText1()
{
string CreateUserURL1 =
"http://34.231.33.25/arhimayapackage/ayyanshare.php";
WWWForm form1 = new WWWForm();
form1.AddField("nulli", "oo");
WWW www1 = new WWW(CreateUserURL1, form1);
StartCoroutine(WaitForRequest1(www1));
}
public IEnumerator WaitForRequest1(WWW www1)
{//Thread.Sleep (100);
yield return www1;
string lin = (www1.text).ToString();
Debug.Log(lin);
//execute the below lines if being run on a Android device
#if UNITY_ANDROID
//Refernece of AndroidJavaClass class for intent
AndroidJavaClass intentClass = new
AndroidJavaClass("android.content.Intent");
//Refernece of AndroidJavaObject class for intent
AndroidJavaObject intentObject = new
AndroidJavaObject("android.content.Intent");
//call setAction method of the Intent object created
intentObject.Call<AndroidJavaObject>("setAction",
intentClass.GetStatic<string>("ACTION_SEND"));
//set the type of sharing that is happening
intentObject.Call<AndroidJavaObject>("setType", "text/plain");
//add data to be passed to the other activity i.e., the data to be sent
intentObject.Call<AndroidJavaObject>("putExtra",
intentClass.GetStatic<string>("EXTRA_SUBJECT"), "App");
intentObject.Call<AndroidJavaObject>("putExtra",
intentClass.GetStatic<string>("EXTRA_TEXT"), lin);
//get the current activity
AndroidJavaClass unity = new
AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity =
unity.GetStatic<AndroidJavaObject>("currentActivity");
//start the activity by sending the intent data
currentActivity.Call("startActivity", intentObject);
#endif

You might also like