/** * Place the info board to the other side of the artwork. */ public void SwitchSides() { if (this.recognizedArtwork != null) { // Determine the new placement this.currentPlacement = (this.currentPlacement == InfoBoardPlacement.Left) ? InfoBoardPlacement.Right : InfoBoardPlacement.Left; // Switch info board position this.recognizedArtwork.SwitchSides(this.currentPlacement); // Set position and rotation Vector2 oldPivot = this.canvasRect.pivot; if (this.currentPlacement == InfoBoardPlacement.Right) { this.canvasRect.pivot = new Vector2(0.0f, 1.0f); this.canvasRect.localPosition = new Vector3(0.0f, 0.0f, 0.0f); this.canvasRect.localEulerAngles = new Vector3(this.canvasRect.localEulerAngles.x, 190.0f, this.canvasRect.localEulerAngles.z); } else { this.canvasRect.pivot = new Vector2(1.0f, 1.0f); this.canvasRect.localPosition = new Vector3(0.0f, 0.0f, 0.0f); this.canvasRect.localEulerAngles = new Vector3(this.canvasRect.localEulerAngles.x, 170.0f, this.canvasRect.localEulerAngles.z); } // Switch sides inside the canvas RectTransform rectInfo = (RectTransform)this.infoButton.transform; RectTransform rectCancle = (RectTransform)this.cancleButton.transform; RectTransform rectSwitch = (RectTransform)this.switchButton.transform; RectTransform rect3D = (RectTransform)this._3DButton.transform; List <RectTransform> buttonRects = new List <RectTransform> { rectInfo, rectCancle, rectSwitch, rect3D }; // Adjust the button positions foreach (RectTransform rect in buttonRects) { // Flip the horizontal anchor values float anchorsX = (rect.anchorMin.x + 1) % 2; rect.anchorMin = new Vector2(anchorsX, 1.0f); rect.anchorMax = new Vector2(anchorsX, 1.0f); // Flip the horizontal position float positionX = rect.localPosition.x * (-1); rect.localPosition = new Vector3(positionX, -25.0f, 0.0f); } // Adjust the panels pivot to switch the scaling direction RectTransform rectPanel = (RectTransform)this.panel.transform; float pivotX = (oldPivot.x + 1) % 2; rectPanel.pivot = new Vector2(pivotX, 1.0f); } }
/** * Set the data for this info board. * * @param recognizedArtwork the recognized artwork information * @param placement initial info board placement * @param artwork data artwork for this info board * @param middlePoint middle point of the recognized artwork */ public void SetData(RecognizedArtwork recognizedArtwork, InfoBoardPlacement placement, Artwork artwork, Vector3 middlePoint) { this.anchorManager = WorldAnchorManager.Instance; this.logger = DebugLogger.Instance; this.infoCanvas = InfoCanvas.Instance; this.arrows = UIArrows.Instance; this.recognizedArtwork = recognizedArtwork; this.currentPlacement = placement; this.artwork = artwork; this.middlePoint = middlePoint; StartCoroutine(Initialize()); }