Пример #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateMeshes()
        {
            HoverFillButton fillButton = gameObject.GetComponent <HoverFillButton>();
            HoverShapeArc   shapeArc   = gameObject.GetComponent <HoverShapeArc>();

            bool  isOuterEdge      = (EdgePosition == EdgePositionType.Outer);
            float inset            = EdgeThickness * Mathf.Sign(shapeArc.OuterRadius - shapeArc.InnerRadius);
            float insetOuterRadius = shapeArc.OuterRadius - (isOuterEdge ? inset : 0);
            float insetInnerRadius = shapeArc.InnerRadius + (isOuterEdge ? 0 : inset);
            float edgeOuterRadius  = (isOuterEdge ? shapeArc.OuterRadius : insetInnerRadius);
            float edgeInnerRadius  = (isOuterEdge ? insetOuterRadius : shapeArc.InnerRadius);

            if (fillButton.Background != null)
            {
                UpdateMeshShape(fillButton.Background, insetOuterRadius, insetInnerRadius);
            }

            if (fillButton.Highlight != null)
            {
                UpdateMeshShape(fillButton.Highlight, insetOuterRadius, insetInnerRadius);
            }

            if (fillButton.Selection != null)
            {
                UpdateMeshShape(fillButton.Selection, insetOuterRadius, insetInnerRadius);
            }

            if (fillButton.Edge != null)
            {
                UpdateMeshShape(fillButton.Edge,
                                edgeOuterRadius, edgeInnerRadius, fillButton.ShowEdge);
            }
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateShapeArcChildren()
        {
            if (!ControlChildShapes)
            {
                return;
            }

            TreeUpdater tree = GetComponent <TreeUpdater>();

            for (int i = 0; i < tree.TreeChildrenThisFrame.Count; i++)
            {
                TreeUpdater   child    = tree.TreeChildrenThisFrame[i];
                HoverShapeArc childArc = child.GetComponent <HoverShapeArc>();

                if (childArc == null)
                {
                    continue;
                }

                Quaternion offsetRot = Quaternion.Inverse(childArc.transform.localRotation);

                childArc.Controllers.Set(OuterRadiusName, this);
                childArc.Controllers.Set(InnerRadiusName, this);
                childArc.Controllers.Set(ArcDegreesName, this);
                childArc.Controllers.Set(OuterOffsetName, this);
                childArc.Controllers.Set(InnerOffsetName, this);

                childArc.OuterRadius = OuterRadius;
                childArc.InnerRadius = InnerRadius;
                childArc.ArcDegrees  = ArcDegrees;
                childArc.OuterOffset = offsetRot * OuterOffset;
                childArc.InnerOffset = offsetRot * InnerOffset;
            }
        }
Пример #3
0
        /*--------------------------------------------------------------------------------------------*/
        protected override void ActivateFillMesh(HoverMesh pSegmentMesh)
        {
            HoverShapeArc meshShapeArc = pSegmentMesh.GetComponent <HoverShapeArc>();

            pSegmentMesh.Controllers.Set(SettingsControllerMap.GameObjectActiveSelf, this);

            RendererUtil.SetActiveWithUpdate(pSegmentMesh, (meshShapeArc.ArcDegrees > 0));
        }
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateButtonRadii(HoverShapeArc pShapeArc, HoverShapeArc pButtonShapeArc)
        {
            pButtonShapeArc.Controllers.Set(HoverShapeArc.OuterRadiusName, this);
            pButtonShapeArc.Controllers.Set(HoverShapeArc.InnerRadiusName, this);

            pButtonShapeArc.OuterRadius = pShapeArc.OuterRadius;
            pButtonShapeArc.InnerRadius = pShapeArc.InnerRadius;
        }
Пример #5
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateFillMeshes()
        {
            HoverShapeArc shapeArc = gameObject.GetComponent <HoverShapeArc>();

            vMeshOuterRadius = shapeArc.OuterRadius - InsetOuter;
            vMeshInnerRadius = shapeArc.InnerRadius + InsetInner;

            base.UpdateFillMeshes();
        }
Пример #6
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateTickMeshes()
        {
            HoverShapeArc shapeArc = gameObject.GetComponent <HoverShapeArc>();
            float         inset    = (shapeArc.OuterRadius - shapeArc.InnerRadius - InsetOuter - InsetInner) *
                                     (1 - TickRelativeSizeX) / 2;

            vTickOuterRadius = shapeArc.OuterRadius - InsetOuter - inset;
            vTickInnerRadius = shapeArc.InnerRadius + InsetInner + inset;

            base.UpdateTickMeshes();
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateTrackShape(HoverShapeArc pShapeArc, HoverRendererSlider pRendSlider)
        {
            HoverShapeArc trackShapeArc = (HoverShapeArc)pRendSlider.Track.GetShape();

            trackShapeArc.Controllers.Set(HoverShapeArc.OuterRadiusName, this);
            trackShapeArc.Controllers.Set(HoverShapeArc.InnerRadiusName, this);
            trackShapeArc.Controllers.Set(HoverShapeArc.ArcDegreesName, this);

            trackShapeArc.OuterRadius = pShapeArc.OuterRadius;
            trackShapeArc.InnerRadius = pShapeArc.InnerRadius;
            trackShapeArc.ArcDegrees  = pShapeArc.ArcDegrees;
        }
Пример #8
0
        /*--------------------------------------------------------------------------------------------*/
        public void TreeUpdate()
        {
            HoverShapeArc     shape     = GetComponent <HoverShapeArc>();
            HoverRendererIdle rend      = GetComponent <HoverRendererIdle>();
            float             thickness = rend.DistanceThreshold / gameObject.transform.lossyScale.x;

            shape.Controllers.Set(HoverShapeArc.InnerRadiusName, this);
            shape.Controllers.Set(HoverShapeArc.InnerOffsetName, this);

            shape.InnerRadius = shape.OuterRadius + thickness;
            shape.InnerOffset = rend.CenterOffset;
        }
Пример #9
0
        /*--------------------------------------------------------------------------------------------*/
        protected override void ResetFillMesh(HoverMesh pSegmentMesh)
        {
            HoverShapeArc meshShapeArc = pSegmentMesh.GetComponent <HoverShapeArc>();

            meshShapeArc.Controllers.Set(HoverShapeArc.OuterRadiusName, this);
            meshShapeArc.Controllers.Set(HoverShapeArc.InnerRadiusName, this);
            meshShapeArc.Controllers.Set(HoverShapeArc.ArcDegreesName, this);

            meshShapeArc.OuterRadius = vMeshOuterRadius;
            meshShapeArc.InnerRadius = vMeshInnerRadius;
            meshShapeArc.ArcDegrees  = 0;
        }
Пример #10
0
        /*--------------------------------------------------------------------------------------------*/
        protected void UpdateAutoUv(HoverShapeArc pShapeArc, float pInnerProg, float pOuterProg)
        {
            if (!AutoUvViaRadiusType)
            {
                return;
            }

            Controllers.Set(UvInnerRadiusName, this);
            Controllers.Set(UvOuterRadiusName, this);

            UvInnerRadius = pInnerProg;
            UvOuterRadius = pOuterProg;
        }
Пример #11
0
        /*--------------------------------------------------------------------------------------------*/
        protected virtual void UpdateMeshShape(HoverMesh pMesh, float pOuterRad, float pInnerRad,
                                               bool pShowMesh = true)
        {
            HoverShapeArc meshShape = pMesh.GetComponent <HoverShapeArc>();

            pMesh.Controllers.Set(SettingsControllerMap.GameObjectActiveSelf, this);
            meshShape.Controllers.Set(HoverShapeArc.OuterRadiusName, this);
            meshShape.Controllers.Set(HoverShapeArc.InnerRadiusName, this);

            RendererUtil.SetActiveWithUpdate(pMesh, (pShowMesh && pMesh.IsMeshVisible));
            meshShape.OuterRadius = pOuterRad;
            meshShape.InnerRadius = pInnerRad;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void TreeUpdate()
        {
            HoverRendererSlider rendSlider     = gameObject.GetComponent <HoverRendererSlider>();
            HoverShapeArc       shapeArc       = gameObject.GetComponent <HoverShapeArc>();
            HoverShapeArc       handleShapeArc = (HoverShapeArc)rendSlider.HandleButton.GetShape();
            HoverShapeArc       jumpShapeArc   = (HoverShapeArc)rendSlider.JumpButton.GetShape();

            shapeArc.ArcDegrees = Mathf.Max(shapeArc.ArcDegrees, handleShapeArc.ArcDegrees);

            UpdateTrackShape(shapeArc, rendSlider);
            UpdateButtonRadii(shapeArc, handleShapeArc);
            UpdateButtonRadii(shapeArc, jumpShapeArc);
            UpdateButtonRotations(rendSlider);
        }
Пример #13
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateInfoWithShape()
        {
            HoverRendererSlider rendSlider     = gameObject.GetComponent <HoverRendererSlider>();
            HoverShapeArc       shapeArc       = gameObject.GetComponent <HoverShapeArc>();
            HoverShapeArc       handleShapeArc = (HoverShapeArc)rendSlider.HandleButton.GetShape();
            HoverShapeArc       jumpShapeArc   = (HoverShapeArc)rendSlider.JumpButton.GetShape();

            TickArcDegrees = Mathf.Max(0, TickArcDegrees);

            vInfo.TrackStartPosition = -shapeArc.ArcDegrees / 2;
            vInfo.TrackEndPosition   = shapeArc.ArcDegrees / 2;
            vInfo.HandleSize         = handleShapeArc.ArcDegrees;
            vInfo.JumpSize           = (rendSlider.AllowJump ? jumpShapeArc.ArcDegrees : 0);
            vInfo.TickSize           = TickArcDegrees;
        }
Пример #14
0
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateTickMesh(HoverMesh pTickMesh, SliderUtil.SegmentInfo pTickInfo)
        {
            HoverShapeArc meshShapeArc = pTickMesh.GetComponent <HoverShapeArc>();

            pTickMesh.Controllers.Set(SettingsControllerMap.GameObjectActiveSelf, this);
            pTickMesh.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this);
            meshShapeArc.Controllers.Set(HoverShapeArc.OuterRadiusName, this);
            meshShapeArc.Controllers.Set(HoverShapeArc.InnerRadiusName, this);
            meshShapeArc.Controllers.Set(HoverShapeArc.ArcDegreesName, this);

            meshShapeArc.OuterRadius = vTickOuterRadius;
            meshShapeArc.InnerRadius = vTickInnerRadius;
            meshShapeArc.ArcDegrees  = pTickInfo.EndPosition - pTickInfo.StartPosition;

            pTickMesh.transform.localRotation = Quaternion.AngleAxis(
                (pTickInfo.StartPosition + pTickInfo.EndPosition) / 2, Vector3.forward);

            RendererUtil.SetActiveWithUpdate(pTickMesh, !pTickInfo.IsHidden);
        }
Пример #15
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateMesh()
        {
            HoverShapeArc shape        = GetComponent <HoverShapeArc>();
            float         innerRadProg = GetRadiusProgress(InnerRadiusType);
            float         outerRadProg = GetRadiusProgress(OuterRadiusType);
            float         innerRad     = Mathf.Lerp(shape.InnerRadius, shape.OuterRadius, innerRadProg);
            float         outerRad     = Mathf.Lerp(shape.InnerRadius, shape.OuterRadius, outerRadProg);
            Vector3       innerOff     = Vector3.Lerp(shape.InnerOffset, shape.OuterOffset, innerRadProg);
            Vector3       outerOff     = Vector3.Lerp(shape.InnerOffset, shape.OuterOffset, outerRadProg);
            float         halfRadians  = shape.ArcDegrees / 180 * Mathf.PI / 2;
            int           steps        = GetArcMeshSteps();

            MeshUtil.BuildRingMesh(vMeshBuild, innerRad, outerRad, -halfRadians, halfRadians,
                                   innerOff, outerOff, steps);

            UpdateAutoUv(shape, innerRadProg, outerRadProg);
            UpdateMeshUvAndColors(steps);
            vMeshBuild.Commit();
            vMeshBuild.CommitColors();
        }
Пример #16
0
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateFillMesh(HoverMesh pSegmentMesh,
                                               SliderUtil.SegmentInfo pSegmentInfo, float pStartPos, float pEndPos)
        {
            HoverShapeArc meshShapeArc = pSegmentMesh.GetComponent <HoverShapeArc>();
            HoverMeshArc  meshArc      = (HoverMeshArc)pSegmentMesh;

            pSegmentMesh.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this);
            pSegmentMesh.Controllers.Set(HoverMesh.DisplayModeName, this);
            meshArc.Controllers.Set(HoverMeshArc.UvMinArcDegreeName, this);
            meshArc.Controllers.Set(HoverMeshArc.UvMaxArcDegreeName, this);

            meshShapeArc.ArcDegrees  = pSegmentInfo.EndPosition - pSegmentInfo.StartPosition;
            pSegmentMesh.DisplayMode = (pSegmentInfo.IsFill ?
                                        HoverMesh.DisplayModeType.SliderFill : HoverMesh.DisplayModeType.Standard);
            meshArc.UvMinArcDegree = (UseTrackUv ?
                                      Mathf.InverseLerp(pStartPos, pEndPos, pSegmentInfo.StartPosition) : 0);
            meshArc.UvMaxArcDegree = (UseTrackUv ?
                                      Mathf.InverseLerp(pStartPos, pEndPos, pSegmentInfo.EndPosition) : 1);

            pSegmentMesh.transform.localRotation = Quaternion.AngleAxis(
                (pSegmentInfo.StartPosition + pSegmentInfo.EndPosition) / 2, Vector3.forward);
        }
Пример #17
0
        /*--------------------------------------------------------------------------------------------*/
        public override float GetSliderValueViaNearestWorldPosition(Vector3 pNearestWorldPosition,
                                                                    Transform pSliderContainerTx, HoverShape pHandleButtonShape)
        {
            HoverShapeArc buttonShapeArc = (pHandleButtonShape as HoverShapeArc);

            if (buttonShapeArc == null)
            {
                Debug.LogError("Expected slider handle to have a '" + typeof(HoverShapeArc).Name +
                               "' component attached to it.", this);
                return(0);
            }

            Vector3    nearLocalPos = pSliderContainerTx.InverseTransformPoint(pNearestWorldPosition);
            float      fromDeg;
            Vector3    fromAxis;
            Quaternion fromLocalRot = Quaternion.FromToRotation(Vector3.right, nearLocalPos.normalized);

            fromLocalRot.ToAngleAxis(out fromDeg, out fromAxis);
            fromDeg *= Mathf.Sign(nearLocalPos.y);

            float halfTrackDeg = (ArcDegrees - buttonShapeArc.ArcDegrees) / 2;

            return(Mathf.InverseLerp(-halfTrackDeg, halfTrackDeg, fromDeg));
        }