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); }
protected void AddLayer(MapARLayer layer) { MapARLayerDup mapARLayerDup = layer.getDuplication(); mapARLayerDup.show(); mapARLayersActived.Insert(0, layer); mapARLayersDisActived.Remove(layer); StartCoroutine(DuplicationMovement(mapARLayerDup, Vector3.up, dupGap * 5, dupMovementTime, 1)); mapARLayersActivedDup.Insert(currentSelectedIndex, mapARLayerDup); foreach (MapARLayerDup layerDup in mapARLayersActivedDup) { if (mapARLayersActivedDup.IndexOf(layerDup) > currentSelectedIndex) { StartCoroutine(DuplicationMovement(layerDup, Vector3.up, dupGap, dupMovementTime, 1)); } } MapHightLightUpdate(); }
protected void DeleteLayer(MapARLayer layer) { MapARLayerDup mapARLayerDup = layer.getDuplication(); mapARLayersActived.Remove(layer); mapARLayersDisActived.Insert(0, layer); StartCoroutine(DuplicationMovement(mapARLayerDup, Vector3.down, dupGap * 5, dupMovementTime, 1)); mapARLayersActivedDup.Remove(mapARLayerDup); //mapARLayerDup.destory(); foreach (MapARLayerDup layerDup in mapARLayersActivedDup) { if (mapARLayersActivedDup.IndexOf(layerDup) >= currentSelectedIndex) { StartCoroutine(DuplicationMovement(layerDup, Vector3.down, dupGap, dupMovementTime, 1)); } } mapARLayerDup.hide(); MapHightLightUpdate(); }