Пример #1
0
        /*--------------------------------------------------------------------------------------------*/
        public void Resize(float pAngle0, float pAngle1)
        {
            if (Math.Abs(pAngle0 - vAngle0) < 0.0001f && Math.Abs(pAngle1 - vAngle1) < 0.0001f)
            {
                return;
            }

            vAngle0 = pAngle0;
            vAngle1 = pAngle1;

            if (vAngle1 > vAngle0)
            {
                vMeshSteps = (int)Math.Round(Math.Max(2, (vAngle1 - vAngle0) / Math.PI * 60));
            }
            else
            {
                vMeshSteps = 0;
            }

            BuildMesh(vBackground.GetComponent <MeshFilter>().mesh, 1);

            if (vHighlight != null)
            {
                BuildMesh(vHighlight.GetComponent <MeshFilter>().mesh, vPrevHighAmount);
                BuildMesh(vSelect.GetComponent <MeshFilter>().mesh, vPrevSelAmount);

                MeshUtil.BuildRingMesh(vEdge.GetComponent <MeshFilter>().mesh,
                                       vRadiusInner - 0.01f, vRadiusInner, vAngle0, vAngle1, vMeshSteps);
            }

            vSelectionPoints = null;
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void BuildMesh(float pThickness)
        {
            if (pThickness == vCurrThickness)
            {
                return;
            }

            vCurrThickness = pThickness;
            MeshUtil.BuildRingMesh(vRingMesh, (1 - pThickness) / 2f, 0.5f, 0, (float)Math.PI * 2, 24);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected virtual void BuildMesh(float pThickness)
        {
            if (Math.Abs(pThickness - vCurrThickness) < 0.001f)
            {
                return;
            }

            vCurrThickness = pThickness;

            MeshUtil.BuildRingMesh(vRingMeshBuilder, (1 - pThickness) / 2f, 0.5f, 0, (float)Math.PI * 2, 24);
            vRingMeshBuilder.Commit();
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateMesh(MeshType pType, Mesh pMesh, float pAmount = 1)
        {
            if (pType == MeshType.Edge)
            {
                float edgeInner = (DrawOuterEdge ? vRadOuter : vRadInner - EdgeThick);
                float edgeOuter = (DrawOuterEdge ? vRadOuter + EdgeThick : vRadInner);
                MeshUtil.BuildRingMesh(EdgeMesh, edgeInner, edgeOuter, vAngle0, vAngle1, vMeshSteps);
                return;
            }

            float radOuter = vRadInner + (vRadOuter - vRadInner) * pAmount;

            MeshUtil.BuildRingMesh(pMesh, vRadInner, radOuter, vAngle0, vAngle1, vMeshSteps);
        }
Пример #5
0
        /*--------------------------------------------------------------------------------------------*/
        private void BuildMesh(Mesh pMesh, float pAmount0, float pAmount1, bool pIsFill)
        {
            float sliderAngle = (vSliderAngleHalf + UiSelectRenderer.AngleInset) * 2;
            float angleRange  = vAngle1 - vAngle0 - sliderAngle;
            int   fillSteps   = (int)Math.Round((vMeshSteps - 2) * (pAmount1 - pAmount0)) + 2;
            float a0          = vAngle0 + angleRange * pAmount0;
            float a1          = vAngle0 + angleRange * pAmount1;

            if (!pIsFill)
            {
                a0 += sliderAngle;
                a1 += sliderAngle;
            }

            MeshUtil.BuildRingMesh(pMesh, 1.04f, 1.46f, a0, a1, fillSteps);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void UpdateMesh(MeshType pType, Mesh pMesh, float pAmount = 1)
        {
            if (vBackgroundOnly && pType != MeshType.Background)
            {
                return;
            }

            if (pType == MeshType.Edge)
            {
                MeshUtil.BuildRingMesh(EdgeMesh, vRadInner - 0.01f, vRadInner,
                                       vAngle0, vAngle1, vMeshSteps);
                return;
            }

            float radOuter = vRadInner + (vRadOuter - vRadInner) * pAmount;

            MeshUtil.BuildRingMesh(pMesh, vRadInner, radOuter, vAngle0, vAngle1, vMeshSteps);
        }
Пример #7
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();
        }
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 protected virtual void BuildMesh(Mesh pMesh)
 {
     MeshUtil.BuildRingMesh(pMesh, InnerRadius, OuterRadius, vAngle0, vAngle1, vMeshSteps);
 }
Пример #9
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 private void BuildMesh(Mesh pMesh)
 {
     MeshUtil.BuildRingMesh(pMesh, vInnerRadius, vInnerRadius + 0.5f, vAngle0, vAngle1, vMeshSteps);
 }
Пример #10
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public virtual void Build(ArcState pArcState, ArcSegmentState pSegState,
                                  float pArcAngle, ArcSegmentSettings pSettings)
        {
            vArcState  = pArcState;
            vSegState  = pSegState;
            vAngle0    = -pArcAngle / 2f + AngleInset;
            vAngle1    = pArcAngle / 2f - AngleInset;
            vSettings  = pSettings;
            vMeshSteps = (int)Math.Round(Math.Max(2, (vAngle1 - vAngle0) / Math.PI * 60));

            ////

            vBackground = new GameObject("Background");
            vBackground.transform.SetParent(gameObject.transform, false);
            vBackground.AddComponent <MeshFilter>();
            vBackground.AddComponent <MeshRenderer>();
            vBackground.renderer.sharedMaterial              = new Material(Shader.Find("Unlit/AlphaSelfIllum"));
            vBackground.renderer.sharedMaterial.renderQueue -= 300;
            vBackground.renderer.sharedMaterial.color        = Color.clear;

            vEdge = new GameObject("Edge");
            vEdge.transform.SetParent(gameObject.transform, false);
            vEdge.AddComponent <MeshFilter>();
            vEdge.AddComponent <MeshRenderer>();
            vEdge.renderer.sharedMaterial              = new Material(Shader.Find("Unlit/AlphaSelfIllum"));
            vEdge.renderer.sharedMaterial.renderQueue -= 300;
            vEdge.renderer.sharedMaterial.color        = Color.clear;

            vHighlight = new GameObject("Highlight");
            vHighlight.transform.SetParent(gameObject.transform, false);
            vHighlight.AddComponent <MeshFilter>();
            vHighlight.AddComponent <MeshRenderer>();
            vHighlight.renderer.sharedMaterial              = new Material(Shader.Find("Unlit/AlphaSelfIllum"));
            vHighlight.renderer.sharedMaterial.renderQueue -= 200;
            vHighlight.renderer.sharedMaterial.color        = Color.clear;

            vSelect = new GameObject("Select");
            vSelect.transform.SetParent(gameObject.transform, false);
            vSelect.AddComponent <MeshFilter>();
            vSelect.AddComponent <MeshRenderer>();
            vSelect.renderer.sharedMaterial              = new Material(Shader.Find("Unlit/AlphaSelfIllum"));
            vSelect.renderer.sharedMaterial.renderQueue -= 10;
            vSelect.renderer.sharedMaterial.color        = Color.clear;

            ////

            Mesh bgMesh = vBackground.GetComponent <MeshFilter>().mesh;

            BuildMesh(bgMesh, 1);

            vSelectionPoints = new List <Vector3>();

            for (int i = 1; i < bgMesh.vertices.Length; i += 2)
            {
                vSelectionPoints.Add(bgMesh.vertices[i]);
            }

            MeshUtil.BuildRingMesh(vEdge.GetComponent <MeshFilter>().mesh,
                                   0.99f, 1.0f, vAngle0, vAngle1, vMeshSteps);

            ////

            var labelObj = new GameObject("Label");

            labelObj.transform.SetParent(gameObject.transform, false);
            labelObj.transform.localPosition = new Vector3(0, 0, 1);
            labelObj.transform.localScale    = new Vector3(1, 1, (vArcState.IsLeft ? 1 : -1));

            vLabel        = labelObj.AddComponent <UiLabel>();
            vLabel.IsLeft = vArcState.IsLeft;
        }
Пример #11
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 private void BuildMesh(Mesh pMesh, float pThickness)
 {
     MeshUtil.BuildRingMesh(pMesh, 1, 1 + 0.5f * pThickness, vAngle0, vAngle1, vMeshSteps);
 }
Пример #12
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void BuildMesh(Mesh pMesh, float pThickness)
        {
            float radOuter = vRadiusInner + (vRadiusOuter - vRadiusInner) * pThickness;

            MeshUtil.BuildRingMesh(pMesh, vRadiusInner, radOuter, vAngle0, vAngle1, vMeshSteps);
        }