private void initMetaphorObject() { if (layer == null) { return; } GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.name = layer.getLayerName().ToUpper(); cube.transform.localScale = 0.1f * localScaleOrg; cube.GetComponent <MeshRenderer>().enabled = true; //GameObject.Destroy(Cube.GetComponent<Collider>()); //MeshCollider mc = Cube.AddComponent<MeshCollider>(); //mc.convex = true; BoxCollider bc = cube.GetComponent <BoxCollider>(); bc.center = new Vector3(0.5f, 0f, 0f); bc.size = new Vector3(2.0f, 1f, 1f); Material newMaterial = (Material)Resources.Load("LayerMetaphorDefault", typeof(Material)); cube.GetComponent <Renderer>().material = newMaterial; goText = new GameObject("Text_" + layer.getLayerName()); TextMesh tm = goText.AddComponent <TextMesh>(); tm.text = layer.getLayerName(); tm.characterSize = 2; goText.transform.parent = cube.transform; goText.transform.localPosition = new Vector3(.6f, 0f, 0f); goText.transform.localScale = new Vector3(.1f, .8f, .1f); if (!_oldVersion) { cube.GetComponent <MeshRenderer>().enabled = false; MapARLayerDup layerDup = layer.getDuplication(); layerDup.setDupObjParent(cube.transform); layerDup.hideText(); } Rigidbody rb = cube.AddComponent <Rigidbody>(); rb.useGravity = false; rb.isKinematic = true; cube.AddComponent <LockRotation>(); //InteractionBehaviour ib = cylinder.AddComponent<InteractionBehaviour>(); //System.Action a = () => highLightDup(); //ib.OnGraspBegin = a; //a = () => cancelHighLightDup(); //ib.OnGraspEnd = a; worldObject = cube; interactionBehaviour = worldObject.AddComponent <InteractionBehaviour>();// (standard_ib); interactionBehaviour.moveObjectWhenGrasped = false; //worldObject.transform.Rotate(Vector3.up, 120); }
public void update(List <UnwrappedTileId> tileIds) { layer.updateLayer(tileIds); if (!_oldVersion) { MapARLayerDup layerDup = layer.getDuplication(); layerDup.hideText(); layerDup.setDupObjParent(this.worldObject.transform); layerDup.resetLocalScaleBy(reScaleRate); //layerDup.resetLocalPos(new Vector3(0, 0, 0)); layerDup.resetLocalPos(new UnityEngine.Pose()); } }