/// <summary> /// Configure la gestion des boutons. /// </summary> private void SetupButton() { var bodyLandscapeObjAFCBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>(); var uiObjectObjUIAFCO_ = ObjectObj_.GetComponent <UIAugmentedFaceCreatorObject>(); var uiObjectObjSR_ = uiObjectObjUIAFCO_.UILayersObj_.GetComponent <ScrollRect>();; var uit_ = GetComponent <UITouch>(); var buttonRemoveLayerObjB_ = ButtonRemoveLayerObj_.GetComponent <Button>(); var buttonHideLayerObjB_ = ButtonHideLayerObj_.GetComponent <Button>(); var buttonMoveForwardObjB_ = ButtonMoveForwardObj_.GetComponent <Button>(); var buttonMoveBackwardObjB_ = ButtonMoveBackwardObj_.GetComponent <Button>(); uit_.BeginDrag += e_ => { UISelection.NoSelect_ = true; uiObjectObjSR_.OnBeginDrag(e_); }; uit_.Drag += e_ => { uiObjectObjSR_.OnDrag(e_); }; uit_.EndDrag += e_ => { UISelection.NoSelect_ = false; uiObjectObjSR_.OnEndDrag(e_); }; uit_.Click += (obj_, clickCount, touchCount) => { UISelection.Select(obj_); }; buttonRemoveLayerObjB_.onClick.AddListener(() => { Remove(); }); buttonHideLayerObjB_.onClick.AddListener(() => { ShowHide(); }); buttonMoveForwardObjB_.onClick.AddListener(() => { MoveForwardLayer(); }); buttonMoveBackwardObjB_.onClick.AddListener(() => { MoveBackwardLayer(); }); }
/// <summary> /// Dessine l'interface utilisateur. /// </summary> private void Draw(float scale_) { // Composants var bodyLandscapeObjUIBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>(); var rt_ = GetComponent <RectTransform>(); var nameObjRT_ = LayerNameObj_.GetComponent <RectTransform>(); var nameObjT_ = LayerNameObj_.GetComponentInChildren <Text>(); var buttonRemoveObjRT_ = ButtonRemoveLayerObj_.GetComponent <RectTransform>(); var buttonHideObjRT_ = ButtonHideLayerObj_.GetComponent <RectTransform>(); var buttonMoveForwardObjRT_ = ButtonMoveForwardObj_.GetComponent <RectTransform>(); var buttonMoveBackwardObjRT_ = ButtonMoveBackwardObj_.GetComponent <RectTransform>(); // Constantes if (scale_ > 0) { scaledTouchSurfaceSize_ = touchSurfaceSize_ * scale_; scaledMarginSize_ = marginSize_ * scale_; scaledBodyFontSize_ = Mathf.RoundToInt(bodyfontSize_ * scale_); } // Logiques var height_ = 0f; //// Nom du calque. var layerNameWidth_ = bodyLandscapeObjUIBL_.ScaledRightPanelWidth_ - scaledTouchSurfaceSize_.x * 2f - scaledMarginSize_ * 4f - bodyLandscapeObjUIBL_.ScaledMarginSize_ * 2f; nameObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, layerNameWidth_); nameObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y); nameObjRT_.anchoredPosition = new Vector2(scaledMarginSize_, 0f); nameObjT_.fontSize = scaledBodyFontSize_; //// Bouton de suppresion buttonRemoveObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x); buttonRemoveObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y); buttonRemoveObjRT_.anchoredPosition = new Vector2(0f, 0f); //// Bouton de masquage buttonHideObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x); buttonHideObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y); buttonHideObjRT_.anchoredPosition = new Vector2(scaledTouchSurfaceSize_.x * -1f, 0f); //// Première ligne height_ += scaledTouchSurfaceSize_.y; //// Bouton de déplacement en avant buttonMoveForwardObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x); buttonMoveForwardObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y); buttonMoveForwardObjRT_.anchoredPosition = new Vector2(0f, (scaledTouchSurfaceSize_.y + scaledMarginSize_) * -1f); //// Bouton de déplacement en arrière buttonMoveBackwardObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x); buttonMoveBackwardObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y); buttonMoveBackwardObjRT_.anchoredPosition = new Vector2(scaledTouchSurfaceSize_.x + scaledMarginSize_, (scaledTouchSurfaceSize_.y + scaledMarginSize_) * -1f); //// Deuxième ligne height_ += scaledMarginSize_ + scaledTouchSurfaceSize_.y; //// Ce panneau rt_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bodyLandscapeObjUIBL_.ScaledRightPanelWidth_ - bodyLandscapeObjUIBL_.ScaledMarginSize_ * 2f - scaledMarginSize_ * 2f); rt_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height_); }