- Home /
Question by
tanmayR · Jan 28, 2013 at 11:10 AM ·
webservice
Loading 3d objects at runtime
Hello, hrere is my code , i just want to know can i load 3d object in .fbx at runtime from webservice by hitting url ???
using UnityEngine;
using System.Collections;
using System.Xml;
public class parsing2 : MonoBehaviour
{
public GUIStyle Button;
public bool p;
string tex;
public string[] name;
public GameObject[] G;
public GameObject Model;
// Use this for initialization
void Start ()
{
p=false;
}
// Update is called once per frame
void Update ()
{
if(p==true)
{
parse();
}
}
void parse()
{
var xmlDoc = new XmlDocument();
xmlDoc.Load("http://youngmoneyapps.info/RoyalBaby/request.php?action=topTen");
XmlNodeList transformList = xmlDoc.GetElementsByTagName("response");
foreach (XmlNode transformInfo in transformList)
{
XmlNodeList transformcontent = transformInfo.ChildNodes;
foreach (XmlNode transformItens in transformcontent)
{
if(transformItens.Name == "suggestName")
{
// Wait for download to complete
Start1();
// renderer.material.mainTexture = www.texture;
name=new string[]{tex};
}
if(transformItens.Name == "counter")
{
Debug.Log (transformItens.InnerText);
}
}
//Do the same with all the other tags that are nested inside the <playerdata>
}
}
void OnGUI()
{
if (GUI.Button(new Rect(10, 70, 50, 30), "Click",Button))
{
p=true;
}
}
IEnumerator Start1()
{
Debug.Log("fdef");
WWW www = new WWW("http://youngmoneyapps.info/RoyalBaby/request.php?action=topTen");
yield return www;
renderer.material.mainTexture = www.texture;
}
}
Thankz
Comment
Answer by Great Alexander · Jan 28, 2013 at 04:15 PM
You can use Instatiate() function to load 3d models in the run time :
public GameObject 3dmodel;
GameObject instance;
instance = Instantiate(3dmodel, transform.position, transform.rotation);
Answer by Graham-Dunnett · Jan 28, 2013 at 04:01 PM
Unity has no run-time support for loading FBX files.
thankz Graham.......
but i m getting a data in the form of text only...so i can only retrieve text at runtime???@Graham
Your answer