public void RemoveCollectibleAnnotation(ARWorldObject worldObject, Collectible collectible) { ARAnnotationContainer container = null; if (m_containers.TryGetValue(worldObject, out container)) { container.RemoveCollectibleAnnotation(collectible); if (!container.HasAnnotations) { RemoveContainer(worldObject, container); } } }
internal void RemoveTapAnnotation(ARWorldObject worldObject) { ARAnnotationContainer container = null; if (m_containers.TryGetValue(worldObject, out container)) { container.RemoveTapAnnotation(); if (!container.HasAnnotations) { RemoveContainer(worldObject, container); } } }
ARAnnotationContainer GetOrCreateContainer(ARWorldObject worldObject) { ARAnnotationContainer container = null; if (!m_containers.TryGetValue(worldObject, out container)) { container = Instantiate(ContainerPrefab); container.gameObject.transform.SetParent(this.transform, false); PositionContainer(worldObject, container); m_containers[worldObject] = container; } return(container); }
private void PositionContainer(ARWorldObject worldObject, ARAnnotationContainer container) { if (worldObject.IsVisible && worldObject.GameObject) { container.gameObject.SetActive(true); var bounds = ARWorld.Instance.GetScreenBounds(worldObject); var ctlRect = (RectTransform)this.transform; var rect = (RectTransform)container.transform; //var x = Screen.width * pos.x - (Screen.width / 2); //var y = Screen.height * pos.y - (Screen.height / 2); var minx = container.MinSize.x / ctlRect.rect.width; var miny = container.MinSize.y / ctlRect.rect.height; Vector2 max = bounds.max; Vector2 min = bounds.min; var size = bounds.max - bounds.min; if (size.x < minx || size.y < miny) { bounds.size = new Vector2(Mathf.Max(size.x, minx), Mathf.Max(size.y, miny)); } rect.anchorMax = bounds.max; rect.anchorMin = bounds.min; rect.sizeDelta = Vector3.zero; //rect.anchorMin = new Vector2(pos.x, pos.y); //rect.anchoredPosition = new Vector2(0, 0); } else { container.gameObject.SetActive(false); } }
private void RemoveContainer(ARWorldObject worldObject, ARAnnotationContainer container) { m_containers.Remove(worldObject); Destroy(container.gameObject); }