public void loadObjectFromPlanet(ReverieObject obj) { //obj.assetid, obj.transform,obj._id.Split('/')[1] GameObject parent = Instantiate(parentTranform, obj.transform.position, Quaternion.identity); AssetWrapper wrapper = parent.GetComponent <AssetWrapper>(); //TODO: organize these better // 9 is objects layer parent.layer = 9; GameObject objcreative = Instantiate(prefabs[int.Parse(obj.assetid)], Vector3.zero, Quaternion.identity); objcreative.name = obj._id.Split('/')[1]; objcreative.transform.parent = parent.transform; objcreative.transform.localPosition = Vector3.zero; wrapper.content = objcreative; obj.obj = parent; onSceneObjects.Add(obj); wrapper.Init(); parent.transform.parent = this.parentScene; parent.transform.localScale = obj.transform.scale; parent.transform.rotation = Quaternion.Euler(obj.transform.rotation); ReverieTimelineRecorder recorder = parent.GetComponentInChildren <ReverieTimelineRecorder>(); recorder.objectid = obj._id.Split('/')[1]; }
public void triggerPrefab(int index, ReverieObject obj) { GameObject parent = Instantiate(parentTranform, obj.transform.position, Quaternion.identity); AssetWrapper wrapper = parent.GetComponent <AssetWrapper>(); //TODO: organize these better // 9 is objects layer parent.layer = 9; GameObject objcreative = Instantiate(prefabs[index], Vector3.zero, Quaternion.identity); objcreative.name = index.ToString(); objcreative.transform.parent = parent.transform; objcreative.transform.localPosition = Vector3.zero; wrapper.content = objcreative; obj.obj = parent; onSceneObjects.Add(obj); wrapper.Init(); parent.transform.parent = this.parentScene; ReverieTimelineRecorder recorder = parent.GetComponentInChildren <ReverieTimelineRecorder>(); recorder.objectid = obj._id; }
public void AddObject(string objectid, int index = 0, Transform obtrans = null) { Debug.Log(this.currentPlanetid); if (this.currentPlanetid == "0") { return; } NetworkHandler restapi = GetComponentInChildren <NetworkHandler>(); StartCoroutine(restapi.LoadStuff(restapi.methodforCall("POST"), NetworkHandler.ADDOBJECT + "/" + this.currentPlanetid + "/" + objectid, (data) => { //Debug.Log(data); ArangoEdge myObject = JsonUtility.FromJson <ArangoEdge>(data); Debug.Log(myObject._to + " " + myObject._from); string serverid = myObject._to.Split('/')[1]; ReverieObject newObj = new ReverieObject(); newObj._id = serverid; newObj.transform = new BasicTranform(obtrans); ObjectFactory.Instance.triggerPrefab(index, newObj); UIButtonTrigger trigger = obtrans.gameObject.GetComponentInChildren <UIButtonTrigger>(); trigger.okDone(); })); }
public void deletePrefab(ReverieObject foundobj) { for (int i = 0; i < onSceneObjects.Count; i++) { if (onSceneObjects[i] == foundobj) { onSceneObjects.RemoveAt(i); Destroy(foundobj.obj); } } }