public static void LoadOneDevice(string device_file) { GameObject device; device = GameObject.Find("Device"); //Debug.Log("user_app_path" + user_app_path + " file [" + computer_file+"]"); string cdir = System.IO.Path.Combine(user_app_path, DEVICES); string cfile = System.IO.Path.Combine(cdir, device_file); //Debug.Log("computer " + cdir); GameObject new_d = Instantiate(device, new Vector3(1.0F, 0, 0), Quaternion.identity); DeviceBehavior script = (DeviceBehavior)new_d.GetComponent(typeof(DeviceBehavior)); script.SetFilePath(cfile); new_d.SetActive(true); script.LoadComponent(); int pos = script.position; //Debug.Log("LoadComputers " + script.computer_name + " pos is " + pos); if (pos < 0) { Debug.Log("LoadOneDevice got invalid pos for " + script.component_name); return; } WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos); int slot = ws.AddDevice(script.component_name); float xf, zf; ccUtils.GridTo3dPos(ws.x, ws.y, out xf, out zf); //Debug.Log(ws.x + " " + ws.y + " " + xf + " " + zf); Vector3 v = new Vector3(xf, 0.5f, zf); new_d.transform.position = v; }
public static void LoadOneDevice(string device_file) { GameObject device; device = GameObject.Find("Device"); //Debug.Log("user_app_path" + user_app_path + " file [" + computer_file+"]"); string cdir = System.IO.Path.Combine(user_app_path, DEVICES); string cfile = System.IO.Path.Combine(cdir, device_file); //Debug.Log("computer " + cdir); GameObject new_d = Instantiate(device, new Vector3(1.0F, 0, 0), Quaternion.identity); DeviceBehavior script = (DeviceBehavior)new_d.GetComponent(typeof(DeviceBehavior)); script.SetFilePath(cfile); new_d.SetActive(true); script.LoadComponent(); script.LoadDevice(); script.hw = hw_name; SkinnedMeshRenderer this_render = new_d.GetComponent <SkinnedMeshRenderer>(); try { this_render.sharedMesh = CatalogBehavior.object_mesh_dict[script.hw]; } catch (KeyNotFoundException) { Debug.Log("Key exception in object_mesh_dict caused by " + script.hw); } try { this_render.material = CatalogBehavior.object_mat_dict[script.hw]; } catch (KeyNotFoundException) { Debug.Log("Key exception in object_mat_dict caused by " + script.hw); } int pos = script.position; //Debug.Log("LoadComputers " + script.computer_name + " pos is " + pos); if (pos < 0) { Debug.Log("LoadOneDevice got invalid pos for " + script.component_name); return; } WorkSpaceScript.WorkSpace ws = WorkSpaceScript.GetWorkSpace(pos); int slot = ws.AddDevice(script.component_name); float xf, zf; ccUtils.GridTo3dPos(ws.x, ws.y, out xf, out zf); //Debug.Log(ws.x + " " + ws.y + " " + xf + " " + zf); Vector3 v = new Vector3(xf, 0.5f, zf); new_d.transform.position = v; }