Unity E-Mail Address Inputfield - c#

I'm developing a 2D jump and run game and have implemented a scoreboard via dreamlo.
On the login Page the User has to input their nickname and email address for the leaderboard.
Now I'm struggling with the code and I don't know how to make it work that the e-mail address gets shown on the leaderboard. When the player opens up the scoreboard, it says his name and "email" at the end.
This is the Line of code:
IEnumerator DatabaseUpload(string userame, string email, int score) //Called when sending new score to Website
{
WWW www = new WWW(webURL + privateCode + "/add/" + WWW.EscapeURL(userame + email) + "/" + score);
yield return www;
}
I tried to change the code to the following but this also doesnt work.
IEnumerator DatabaseUpload(string userame, string email, int score) //Called when sending new score to Website
{
WWW www = new WWW(webURL + privateCode + "/add/" + WWW.EscapeURL(userame + (email) + "/" + score);
yield return www;
}

Related

Any permanent solution this error "Download over http ,please consider updating to https" in Unity?

Trying to upload two different files into backend server.One is .json file and other is .worldmap file.When I upload I get this error in the debug "You are using download over http. Currently Unity adds NSAllowsArbitraryLoads to Info.plist to simplify transition, but it will be removed soon. Please consider updating to https.
Generic/unknown HTTP error"
I have noticed that sometimes this error shows up and sometimes not.From this Link solution the solution is to add UnityWebRequest.I have used that but still it continues to show up.Anything to do with my code ,webaddress or too many http calls from my code?
public void UploadMaps()
{
StartCoroutine(UploadFileData());
StartCoroutine(UploadWorldMap());
}
IEnumerator UploadFileData()
{
string mapnamedl = "pathtest";
Debug.Log("Mapname local = " + mapnamedl);
string locapath ="file://" +Application.persistentDataPath + "/" + mapnamedl + ".json";
Debug.Log("local path = " + locapath);
WWW localFile = new WWW(locapath);
yield return localFile;
if(localFile.error==null)
{
Debug.Log("Local file found successfully");
}
else
{
Debug.Log("Open file error: " + localFile.error);
yield break; // stop the coroutine here
}
Debug.Log("Form bytes = " + BitConverter.ToString(localFile.bytes));
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
formData.Add(new MultipartFormDataSection("Jsondata",localFile.bytes));
UnityWebRequest www = UnityWebRequest.Post("http://testsite.com/cab/test/save.php",formData);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
string JSONDATAstring = www.downloadHandler.text;
Debug.Log("Json String is = " + JSONDATAstring);
JSONNode JNode = SimpleJSON.JSON.Parse(JSONDATAstring);
string login = (JNode["upload"][0]["success"]).ToString();
Debug.Log("login is = " + login);
if (login == "1")
{
Debug.Log("Form upload complete!");
}
else if (login == "0")
{
Debug.Log("Failed ");
}
}
}
IEnumerator UploadWorldMap()
// IEnumerator UploadFileData(string mapnamedl)
{
string mapnamedl = "pathtest";
Debug.Log("Mapname local = " + mapnamedl);
string locapath = "file://" + Application.persistentDataPath + "/" + mapnamedl + ".worldmap";
Debug.Log("local path = " + locapath);
WWW localFile = new WWW(locapath);
yield return localFile;
if (localFile.error == null)
{
Debug.Log("Local file found successfully");
}
else
{
Debug.Log("Open file error: " + localFile.error);
yield break; // stop the coroutine here
}
Debug.Log("Form bytes = " + BitConverter.ToString(localFile.bytes));
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
formData.Add(new MultipartFormDataSection("Jsondata", localFile.bytes));
UnityWebRequest www = UnityWebRequest.Post("http://testsite.com/cab/test/save.php", formData);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
string JSONDATAstring = www.downloadHandler.text;
Debug.Log("Worldmap String is = " + JSONDATAstring);
JSONNode JNode = SimpleJSON.JSON.Parse(JSONDATAstring);
string login = (JNode["upload"][0]["success"]).ToString();
Debug.Log("Worldmap login is = " + login);
if (login == "1")
{
Debug.Log("Form upload complete!");
}
else if (login == "0")
{
Debug.Log("Failed ");
}
}
}
You're using the HTTP protocol (the http:// at the beginning of your URL). Apple enforces all kinds of random policies, one of which is that you must communicate over HTTPS, the secure version of HTTP. Try changing your URLs to https. If the server you're connecting to supports them, great. Otherwise, you'll need to make the server https-friendly by getting an HTTPS certificate and installing it on your server (if it's yours; otherwise, you're out of luck).

ASP.net Web API authorization denied with same credentials on Android in Unity3d [duplicate]

The Code below is used to get Temperature Value from Thingworx server that is hosted in one of our own systems. This works perfectly well in unity. But not in andoird, once apk is generated, it won't fetch any data from the server and there will be connection established. But, it just wont fetch the data and put that into the text mesh.
I'm using unity 5.4.1 32bit . Check in both Android - 5.0.2 and 6.
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
using System.Text.RegularExpressions;
using System;
using UnityEngine.UI;
public class GETTempValue : MonoBehaviour {
public GameObject TempText;
static string TempValue;
void Start()
{
StartCoroutine(GetText());
}
IEnumerator GetText()
{
Debug.Log("Inside Coroutine");
while (true)
{
yield return new WaitForSeconds(5f);
string url = "http://Administrator:ZZh7y6dn#*IP Address*:8080/Thingworx/Things/SimulationData/Properties/OvenTemperature/";
Debug.Log("Before UnityWebRequest");
UnityWebRequest www = UnityWebRequest.Get (url);
yield return www.Send();
Debug.Log("After UnityWebRequest");
if (www.isError) {
Debug.Log ("Error while Receiving: "+www.error);
} else {
Debug.Log("Success. Received: "+www.downloadHandler.text);
string result = www.downloadHandler.text;
Char delimiter = '>';
String[] substrings = result.Split(delimiter);
foreach (var substring in substrings)
{
if (substring.Contains ("</TD"))
{
String[] Substrings1 = substring.Split ('<');
Debug.Log (Substrings1[0].ToString()+"Temp Value");
TempValue = Substrings1 [0].ToString ();
TempText.GetComponent<TextMesh> ().text = TempValue+"'C";
}
}
}
}
}
}
this is the android manifest permission
uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.CAMERA"
uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
Embedding username and password(http://username:password#example.com) in a url is no longer supported in some Applications and OS for security reasons.That's because this is not the standard way to perform HTTP Authentication. It very likely that Unity or Android did not implement this on the their side.
I tested this on the built-in Android Browser with http://Administrator:ZZh7y6dn#*IP Address*:8080/Thingworx/Things/SimulationData/Properties/OvenTemperature/ and it failed to function. So, I guess this problem is from Android.
I tested again without username and password http://*IP Address**:8080/Thingworx/Things/SimulationData/Properties/OvenTemperature/ then the login window appeared. When I entered the username and password, it worked.
You can still use UnityWebRequest to solve this problem by providing the AUTHORIZATION header to the UnityWebRequest with the SetRequestHeader function. This will only work if the authorization type is Basic instead of Digest. In your case, it is HTTP Basic.
For general solution:
string authenticate(string username, string password)
{
string auth = username + ":" + password;
auth = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(auth));
auth = "Basic " + auth;
return auth;
}
IEnumerator makeRequest()
{
string authorization = authenticate("YourUserName", "YourPassWord");
string url = "yourUrlWithoutUsernameAndPassword";
UnityWebRequest www = UnityWebRequest.Get(url);
www.SetRequestHeader("AUTHORIZATION", authorization);
yield return www.Send();
.......
}
For solution in your question:
public GameObject TempText;
static string TempValue;
void Start()
{
StartCoroutine(GetText());
}
string authenticate(string username, string password)
{
string auth = username + ":" + password;
auth = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(auth));
auth = "Basic " + auth;
return auth;
}
IEnumerator GetText()
{
WaitForSeconds waitTime = new WaitForSeconds(2f); //Do the memory allocation once
string authorization = authenticate("Administrator", "ZZh7y6dn");
while (true)
{
yield return waitTime;
string url = "http://*IP Address*:8080/Thingworx/Things/SimulationData/Properties/OvenTemperature/";
UnityWebRequest www = UnityWebRequest.Get(url);
www.SetRequestHeader("AUTHORIZATION", authorization);
yield return www.Send();
if (www.isError)
{
Debug.Log("Error while Receiving: " + www.error);
}
else
{
string result = www.downloadHandler.text;
Char delimiter = '>';
String[] substrings = result.Split(delimiter);
foreach (var substring in substrings)
{
if (substring.Contains("</TD"))
{
String[] Substrings1 = substring.Split('<');
Debug.Log(Substrings1[0].ToString() + "Temp Value");
TempValue = Substrings1[0].ToString();
TempText.GetComponent<TextMesh>().text = TempValue + "'C";
}
}
}
}
}

Receive image from web server C# Unity

I have had web server that stores the images. In Unity, I can receive one and create gameobject to change it's material. However, I want to receive max no. four images. After 1 mins, I want to receive max no. four images again. Besides, if there is two images in server, I just want to create two new gameobject and change them material. If there is three, just create three. How can I do that, Any one can help me? Here is my code in Unity:
void Start () {
StartCoroutine (LoadImage ());
}
IEnumerator LoadImage(){
filename = "image" + k.ToString () + ".png";
url = "https://wwwfoodparadisehk.000webhostapp.com/" + filename;
WWW www = new WWW (url);
yield return www;
if (www.error != null) {
Debug.Log (www.error);
} else {
Debug.Log (k);
path = "Assets/MyMaterial" + k.ToString () + ".mat";
k = k + 1;
material = new Material (Shader.Find ("Sprites/Default"));
AssetDatabase.CreateAsset (material, path);
Debug.Log (AssetDatabase.GetAssetPath (material));
material.mainTexture = www.texture;
GameObject newPaperInstance = Instantiate (newpaper) as GameObject;
newPaperInstance.transform.Find ("Plane001").gameObject.GetComponent<Renderer> ().material = material;
}
}
I'd first ask my server for a list of the items I can get. For this, you can simply make a text file or make your own PHP file to create a list that you separate by a character like the pipe (|):
MyMaterial1|MyMaterial2|MyMaterial3
Then you can ask the file from your server the same way you'd get the images and create a string[] array object from the result. You can use Split('|') in order to create this array from your result string.
When you're done, you can foreach over the items within the array.
IEnumerator LoadImages()
{
string filename = "imagelist.txt";
string url = "https://wwwfoodparadisehk.000webhostapp.com/" + filename;
WWW www = new WWW (url);
yield return www;
if (www.error != null)
{
Debug.Log (www.error);
}
else
{
string[] images = www.text.Split ('|');
foreach (var image in images)
{
LoadImage (image);
}
}
}
Last but not least, you'll have to create a second function that loads the texture from the string you supply:
IEnumerator LoadImage(string image)
{
string url = "https://wwwfoodparadisehk.000webhostapp.com/" + image;
WWW www = new WWW (url);
yield return www;
if (www.error != null)
{
Debug.Log (www.error);
}
else
{
// turn your image into a texture with www.texture and apply it to your objects.
}

unity how to load image from streamingassets on ios

I put some png files into /Assets/StreamingAssets, what i want to do is load a image's texture from that floder.
here is my c# code below:
string path = "file://" + Application.streamingAssetsPath + "/sunny.png";
private IEnumerator GetMatByWWW(string url)
{
WWW www = new WWW(url);
yield return www;
RawImage rawImage = gameObject.GetComponent<RawImage>();
rawImage.texture = www.texture;
}
On OSX, the code working perfect. But i need to make it working on IOS. So i remove the prefix of "file://" and the path is :
string path = Application.streamingAssetsPath + "/sunny.png";
It just showed a red question-mark after build and run at my iPhone. And i also tried
string path = "file:/" + Application.streamingAssetsPath + "/sunny.png";
Who can tell me how to do it correctly?
string ab_path = Application.streamingAssetsPath + "/" + "bundlename";
AssetBundle ab = AssetBundle.LoadFromFile(ab_path);
if(ab == null)
{
Debug.Log("ab is null");
}
Gameobject prefab = ab.LoadAsset<GameObject>("prefab_name");
Gameobject go = GameObject.Instantiate(prefab);
please check this link.
https://docs.unity3d.com/ScriptReference/AssetBundle.LoadFromFile.html

Embedded In Person Signing process?

I've been trying like mad to get this to work, and I'm sure it's something simple, but I'm at a loss right now.
I'm using the SDK for DocuSign example. I've modified it lightly to try to get an InPersonSigner embedded:
private Recipient[] ConstructRecipients()
{
// Construct the recipients
var runningList = new List<Recipient>();
for (int i = 1; i <= Request.Form.Count; i++)
{
if (null !=Request.Form[Keys.RecipientName + i])
{
var r = new Recipient
{
UserName = Request.Form[Keys.RecipientName + i],
Email = Request.Form[Keys.RecipientEmail + i] // <-- Using my DocuSign account email for simplicity
};
// Get and set the security settings
string security = Request.Form[Keys.RecipientSecurity + i];
if (null != security)
{
//...Code still here, just making this post shorter
}
}
// Try InPerson Signing
r.RequireIDLookup = false;
r.UserName = "AccountUserName"; //<-- Again, My Account user name for simplicity
r.SignerName = Request.Form[Keys.RecipientName + i]; // "BB King"
r.Type = RecipientTypeCode.InPersonSigner;
r.ID = i.ToString();
//r.Type = RecipientTypeCode.Signer;
if (null == Request.Form[Keys.RecipientInviteToggle + i])
{
// we want an embedded signer
r.CaptiveInfo = new RecipientCaptiveInfo {ClientUserId = i.ToString()};
}
runningList.Add(r);
}
else
{
break;
}
}
return runningList.ToArray();
}
When sending via email, it works, the Host (me) receives the Email, and is able to go through the "In Person Singing Process".
When sending for embedded results (remember I'm using the SDK out of the box for the embedded part - which includes ClientID), it errors with this message: "The recipient you have identified is not a valid recipient of the specified envelope."
What do I need to add to make the Embedded SDK sample work with a In Person Signing Session?
---- EDIT ----
I found the issue, but don't know the best solution. Apparently, the GetStatusAndDocs.aspx.cs file has this line:
DocuSignAPI.FilteredEnvelopeStatuses statuses = client.RequestStatusesEx(filter);
Statuses contains an EnvelopeStatus object, and that contains a RecipientStatus object. The RecipientStatus objects returns the UserName field as the SignerName that I entered, not the UserName that I entered.
This RecipientStatus object doesn't even have a SignerName property/field??? Why?
What property/field should I use to pass to the RequestRecipientToken username parameter? If it's one of my field agents, I need to know how to fully identify the person and their account to determine they went to the field, fired up the app, and then did an in person signing.
Still at a lost although I have figured this out so far?
I found the answer:
For an embedded RecipientTypeCode.InPersonSigner, the email address can be bogus, fake, junk, etc., (as long as it's in email format "somethingdotsomething#someplacedotsomething.whatever").
When it's RecipientTypeCode.InPersonSigner, the username you pass to the RequestRecipientToken() is the Actual Account Holder userName. Not the account that you may have given access to your main account as an Agent or someone part of a group, and not the signer/recipient name, but the account holder name that is on the account credentials being used for embedded signature.
The code on page GetStatusAndDocs.aspx.cs can be modified as follows to accomplish this:
protected System.Web.UI.HtmlControls.HtmlGenericControl CreateEnvelopeTable(DocuSignAPI.EnvelopeStatus status)
{
var envelopeDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
int recipIndex = 0;
foreach (DocuSignAPI.RecipientStatus recipient in status.RecipientStatuses)
{
var info = new System.Web.UI.HtmlControls.HtmlGenericControl("p");
String recipId = "Recipient_Detail_" + status.EnvelopeID + "_" + recipient.RoutingOrder + "_" + recipient.UserName + "_" + recipient.Email + "_" + recipIndex++;
info.InnerHtml = "<img src=\"images/plus.png\"> Recipient - " +
recipient.UserName + ": " + recipient.Status.ToString();
if (recipient.Status != DocuSignAPI.RecipientStatusCode.Completed && null != recipient.ClientUserId)
{
// For InPersonSigner, this will not work because the recipient.UserName needs to be the credentialed account actual user name, not the recipieint userName.
//info.InnerHtml += " <input type=\"submit\" id=\"" + status.EnvelopeID + "\" value=\"Start Signing\" name=\"DocEnvelope+" + status.EnvelopeID + "&Email+" + recipient.Email + "&UserName+" +
// recipient.UserName + "&CID+" + recipient.ClientUserId + "\">";
// In order to make this work for InPersonSigner, we need the envelope account (the credentialed account) userName instead of recipient.UserName
// Get correct user name depending on recipient type
string userName = (recipient.Type == RecipientTypeCode.InPersonSigner) ? status.ACHolder : recipient.UserName;
info.InnerHtml += " <input type=\"submit\" id=\"" + status.EnvelopeID + "\" value=\"Start Signing\" name=\"DocEnvelope+" + status.EnvelopeID + "&Email+" + recipient.Email + "&UserName+" +
userName + "&CID+" + recipient.ClientUserId + "\">";
}
if (null != recipient.TabStatuses)
{
// Code here is the same, just making it shorter for this response
}
envelopeDiv.Controls.Add(info);
}
// Code between here and return is the same, just making it shorter for this response
return envelopeDiv;
}

Categories

Resources