First, excuse me for my bad English. I'm trying to call some images that I have stored in a database with a text. I can show the text, but I do not know how to show the image. The images are saved in a folder called "upload" located in the Web Services files. The text called him through his ID, and I want the related image to be displayed as well.
This is how I called:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using SimpleJSON;
public class DataLoader : MonoBehaviour
{
string JsonDataString;
string JsonDataString2;
static public string OriginalJsonSite;
public Text Titulo;
public Text Texto;
IEnumerator Start ()
{
WWW readingsite = new WWW (OriginalJsonSite);
Debug.Log(OriginalJsonSite);
yield return readingsite;
if (string.IsNullOrEmpty (readingsite.error)) {
JsonDataString = readingsite.text;
JsonDataString2 = JsonDataString.Substring(3, JsonDataString.Length - 4);
}
JSONNode jsonNode = SimpleJSON.JSON.Parse (JsonDataString2);
Debug.Log(JsonDataString2);
Titulo.text = jsonNode["titulo"].ToString().ToUpper();
Debug.Log(jsonNode["titulo"]);
Texto.text = jsonNode["texto"].ToString().ToUpper();
Debug.Log(jsonNode["texto"]);
}}
And this is how I show:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PlaceInfo : MonoBehaviour
{
public string escenaInfo;
public string id;
void OnMouseOver()
{
DataLoader.OriginalJsonSite = "http://(Website name)/API/test.php?id=" + id;
SceneManager.LoadScene(escenaInfo);
}
void OnMouseDown()
{
DataLoader.OriginalJsonSite = "http://(Website name)/API/test.php?id=" + id;
// this object was clicked - do something
SceneManager.LoadScene(escenaInfo);
}}
This is one of the data I have saved.
[{"_id":{"$oid":"5d30f06ba6e0712cf41c93d3"},"titulo":"Museo Hist\u00f3rico y Arqueol\u00f3gico de Conc\u00f3n","texto":"Es el lugar que resguarda y cobija los elementos ancestrales, hist\u00f3ricos y tradicionales de la localidad y est\u00e1 interesado en recuperar la memoria, como elemento fundamental para la construcci\u00f3n de identidad que nos permita romper el aislamiento.","fileName":"museo.jpg"}]
and this is the url of the image:
http://(web service name)/upload/museo.jpg