コード例 #1
0
        /// <summary>
        /// Configure la gestion des boutons.
        /// </summary>
        private void SetupButton()
        {
            var bodyLandscapeUIAFCBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>();
            var bodyLandscapeSR_      = bodyLandscapeUIAFCBL_.ScrollViewObjectsObj_.GetComponent <ScrollRect>();
            var uit_ = GetComponent <UITouch>();
            var i_   = GetComponent <Image>();
            var buttonRemoveObjectObjB_ = ButtonRemoveObjectObj_.GetComponent <Button>();
            var buttonHideObjectObjB_   = ButtonHideObjectObj_.GetComponent <Button>();
            var buttonAddLayerObjB_     = ButtonAddLayerObj_.GetComponent <Button>();

            uit_.BeginDrag += e_ =>
            {
                UISelection.NoSelect_ = true;
                bodyLandscapeSR_.OnBeginDrag(e_);
            };

            uit_.Drag += e_ =>
            {
                bodyLandscapeSR_.OnDrag(e_);
            };

            uit_.EndDrag += e_ =>
            {
                UISelection.NoSelect_ = false;
                bodyLandscapeSR_.OnEndDrag(e_);
            };

            uit_.Click += (obj_, clickCount, touchCount) =>
            {
                UISelection.Select(obj_);
            };

            buttonRemoveObjectObjB_.onClick.AddListener((UnityEngine.Events.UnityAction)(() =>
            {
                if (!IsPermanent_)
                {
                    Remove();
                }
            }));

            buttonHideObjectObjB_.onClick.AddListener(() =>
            {
                ShowHide();
            });

            buttonAddLayerObjB_.onClick.AddListener(() =>
            {
                AddLayer(texture_ => { });
            });
        }
コード例 #2
0
        /// <summary>
        /// Dessine l'interface utilisateur.
        /// </summary>
        private void Draw(float scale_)
        {
            // Composants
            var bodyLandscapeObjUIBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>();
            var rt_ = GetComponent <RectTransform>();
            var objectNameObjRT_                 = ObjectNameObj_.GetComponent <RectTransform>();
            var objectNameObjT_                  = ObjectNameObj_.GetComponentInChildren <Text>();
            var removeObjectObjRT_               = ButtonRemoveObjectObj_.GetComponent <RectTransform>();
            var hideObjectObjRT_                 = ButtonHideObjectObj_.GetComponent <RectTransform>();
            var addLayerObjRT_                   = ButtonAddLayerObj_.GetComponent <RectTransform>();
            var dropdownAnchorObjRT_             = DropdownAnchorObj_.GetComponent <RectTransform>();
            var dropdownAnchorObjD_              = DropdownAnchorObj_.GetComponent <Dropdown>();
            var dropdownAnchorLabelObjT_         = DropdownAnchorObj_.transform.Find("Label").GetComponent <Text>();
            var dropdownAnchorArrowObjRT_        = DropdownAnchorObj_.transform.Find("Arrow").GetComponent <RectTransform>();
            var dropdownAnchorTemplateItemObjRT_ = DropdownAnchorObj_.transform.Find("Template").Find("Viewport").Find("Content").Find("Item").GetComponent <RectTransform>();
            var dropdownAnchorTemplateLabelObjT_ = DropdownAnchorObj_.transform.Find("Template").Find("Viewport").Find("Content").Find("Item").Find("Item Label").GetComponent <Text>();
            var layersObjRT_         = UILayersObj_.GetComponent <RectTransform>();
            var layersContentObjVLG_ = UILayersContentObj_.GetComponent <VerticalLayoutGroup>();

            // Constantes
            if (scale_ > 0)
            {
                scaledTouchSurfaceSize_ = touchSurfaceSize_ * scale_;
                scaledMarginSize_       = marginSize_ * scale_;
                scaledBodyFontSize_     = Mathf.RoundToInt(bodyfontSize_ * scale_);
            }

            // Logiques
            var height_ = 0f;

            //// Nom de l'objet
            var objectNameObjWidth_ = bodyLandscapeObjUIBL_.ScaledRightPanelWidth_ - scaledTouchSurfaceSize_.x * 2f - scaledMarginSize_ * 3f - bodyLandscapeObjUIBL_.ScaledMarginSize_ * 2f;

            objectNameObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, objectNameObjWidth_);
            objectNameObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y);
            objectNameObjRT_.anchoredPosition = new Vector2(scaledMarginSize_, scaledMarginSize_ * -1f);

            objectNameObjT_.fontSize = scaledBodyFontSize_;

            //// Bouton de suppresion
            removeObjectObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x);
            removeObjectObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y);
            removeObjectObjRT_.anchoredPosition = new Vector2(scaledMarginSize_ * -1, scaledMarginSize_ * -1f);

            //// Bouton de masquage
            hideObjectObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x);
            hideObjectObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y);
            hideObjectObjRT_.anchoredPosition = new Vector2((scaledTouchSurfaceSize_.x + scaledMarginSize_) * -1, scaledMarginSize_ * -1f);

            //// Première ligne
            height_ += Mathf.Abs(scaledMarginSize_ + scaledTouchSurfaceSize_.y);

            //// Bouton d'ajout de calques
            var secondLineOffset_ = (scaledTouchSurfaceSize_.y + scaledMarginSize_ * 2f) * -1f;

            addLayerObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x);
            addLayerObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y);
            addLayerObjRT_.anchoredPosition = new Vector2(scaledMarginSize_, secondLineOffset_);

            //// Dropdown des ancres

            if (!IsReference_ && ReferenceObjectObj_ != null)
            {
                dropdownAnchorObjRT_.offsetMin = new Vector2(scaledTouchSurfaceSize_.x + scaledMarginSize_ * 2f, 0f);
                dropdownAnchorObjRT_.offsetMax = new Vector2(scaledMarginSize_ * -1f, secondLineOffset_);
                dropdownAnchorObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y);

                dropdownAnchorLabelObjT_.fontSize = scaledBodyFontSize_;

                dropdownAnchorArrowObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, scaledTouchSurfaceSize_.x);
                dropdownAnchorArrowObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y);
                dropdownAnchorArrowObjRT_.anchoredPosition = Vector2.zero;

                dropdownAnchorTemplateItemObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y);

                dropdownAnchorTemplateLabelObjT_.fontSize = scaledBodyFontSize_;

                var anchorsNames_ = ReferenceObjectObj_?.GetComponent <UIAugmentedFaceCreatorObject>()?.MeshWorkerObj_?.GetComponent <AugmentedFaceCreatorMeshWorker>()?.GetAnchorNames_();

                if (anchorsNames_ != null)
                {
                    dropdownAnchorObjD_.ClearOptions();
                    dropdownAnchorObjD_.AddOptions(anchorsNames_);
                }

                dropdownAnchorObjD_.onValueChanged.AddListener(value_ =>
                {
                    AnchorIndex_ = value_;
                });
            }

            DropdownAnchorObj_.SetActive(!IsReference_);

            //// Deuxième ligne
            height_ += Mathf.Abs(scaledMarginSize_ + scaledTouchSurfaceSize_.y);

            //// Liste des calques
            var layersObjOffset_ = (scaledTouchSurfaceSize_.y * 2f + scaledMarginSize_ * 3f) * -1f;

            layersObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bodyLandscapeObjUIBL_.ScaledRightPanelWidth_ - bodyLandscapeObjUIBL_.ScaledMarginSize_ * 2f - scaledMarginSize_ * 2f);
            layersObjRT_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, scaledTouchSurfaceSize_.y * 2f + scaledMarginSize_ * 1f);
            layersObjRT_.anchoredPosition = new Vector2(scaledMarginSize_, layersObjOffset_);
            layersContentObjVLG_.spacing  = scaledMarginSize_;

            //// Troisième ligne
            height_ += Mathf.Abs(scaledMarginSize_ + scaledTouchSurfaceSize_.y * 2f + scaledMarginSize_ * 1f);

            //// Quatrième ligne (marge)
            height_ += Mathf.Abs(scaledMarginSize_);

            //// Ce panneau
            rt_.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bodyLandscapeObjUIBL_.ScaledRightPanelWidth_ - bodyLandscapeObjUIBL_.ScaledMarginSize_ * 2f);
            rt_.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height_);
        }