コード例 #1
0
        /// <summary>
        /// Intialise une nouvelle interface de calque.
        /// </summary>
        public void Initialize(GameObject layerObj_, bool isReference_, bool isPermanent_, bool isMoveable_)
        {
            LayerObj_ = layerObj_;

            IsReference_ = isReference_;
            IsPermanent_ = isPermanent_;
            IsMoveable_  = isMoveable_;

            // Objets enfants
            var bodyLandscapeObjUIBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>();

            bodyLandscapeObjUIBL_.DrawUI += Draw;
            bodyLandscapeObjUIBL_.ForceDraw();

            var layerNameObjT_ = LayerNameObj_.GetComponentInChildren <Text>();

            layerNameObjT_.text = $"Layer-{layerObj_.transform.GetSiblingIndex():D3}";

            SetupButton();

            if (isReference_)
            {
                if (ReferenceLayerObj_ != null)
                {
                    Remove(ReferenceLayerObj_);
                }

                ReferenceLayerObj_ = gameObject;
            }
        }
コード例 #2
0
        /// <summary>
        /// Intialise un nouvel objet d'interface de maillage.
        /// </summary>
        /// <param name="meshWorkerObj_">Le travailleur du maillage.</param>
        /// <param name="layerWorkerObj_">Le travailleur de calques du maillage.</param>
        /// <param name="isReference_">Indique si l'objet est une référence.</param>
        public void Initialize(GameObject meshWorkerObj_, GameObject layerWorkerObj_, bool isReference_, bool isPermanent_, bool isMoveable_)
        {
            MeshWorkerObj_  = meshWorkerObj_;
            LayerWorkerObj_ = layerWorkerObj_;
            IsReference_    = isReference_;
            IsPermanent_    = isPermanent_;
            IsMoveable_     = isMoveable_;
            IsInitialized   = true;

            name = $"UIObject-{transform.GetSiblingIndex():D3}";
            ObjectNameObj_.GetComponent <Text>().text = $"Object-{transform.GetSiblingIndex():D3}";

            SetupButton();

            BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>().ForceDraw();

            if (isReference_)
            {
                if (ReferenceObjectObj_ != null)
                {
                    Remove(ReferenceObjectObj_);
                }

                ReferenceObjectObj_ = gameObject;

                var WorkerObjAFCW_ = WorkerObj_.GetComponent <AugmentedFaceCreatorWorker>();
                WorkerObjAFCW_.SetupLights(meshWorkerObj_);
            }

            var bodyLandscapeObjUIBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>();

            bodyLandscapeObjUIBL_.DrawUI += Draw;
            bodyLandscapeObjUIBL_.ForceDraw();
        }
コード例 #3
0
        /// <summary>
        /// Ajoute une interface de calque à partir d'une image.
        /// </summary>
        /// <param name="texture_">Texture du calque.</param>
        public void AddLayer(Texture2D texture_, bool isReference_, bool isPermanent_, bool isMoveable_)
        {
            var LayerWorkerObjAFCLW_ = LayerWorkerObj_.GetComponent <AugmentedFaceCreatorLayerWorker>();

            if (!LayerWorkerObjAFCLW_.CanAddLayer_)
            {
                return;
            }

            var layerCameraAFCC_ = AugmentedFaceCreatorWorker.LayerCameraPivotObj_.GetComponent <AugmentedFaceCreatorCamera>();

            var bodyLandscapeObjAFCBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>();

            bodyLandscapeObjAFCBL_.Focus(MeshWorkerObj_, LayerWorkerObj_);

            var layerObj_ = LayerWorkerObjAFCLW_.AddLayer(layerSupportPrefab_, texture_);

            layerObj_.transform.localPosition = layerCameraAFCC_.Forward_ * ((layerObj_.transform.GetSiblingIndex() + 1) * LayerWorkerObjAFCLW_.LayerOffset_ + layerCameraAFCC_.ClippingPlane_.near_);

            if (isReference_)
            {
                layerObj_.layer = 8;
            }

            var uiLayerObj_ = Instantiate(uiLayerPrefab_, Vector3.zero, Quaternion.identity, UILayersContentObj_.transform);

            uiLayerObj_.name = $"UILayer-{uiLayerObj_.transform.GetSiblingIndex() - 1}";

            var uiLayerObjUIAFCL_ = uiLayerObj_.GetComponent <UIAugmentedFaceCreatorLayer>();

            uiLayerObjUIAFCL_.Initialize(layerObj_, isReference_, isPermanent_, isMoveable_);
        }
コード例 #4
0
        /// <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();
            });
        }
コード例 #5
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_ => { });
            });
        }
コード例 #6
0
        /// <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_);
        }
コード例 #7
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_);
        }