示例#1
0
        public void ModifyMesh(Neumorphism neu, VertexHelper vh)
        {
            var output = vertCache;

            vh.GetUIVertexStream(output);

            Color   color;
            Vector2 offset;

            if (mode == Mode.Light)
            {
                color  = neu.lightColor;
                offset = new Vector2(-1, 1).normalized *neu.shadowOffset;
            }
            else
            {
                color  = neu.shadowColor;
                offset = new Vector2(1, -1).normalized *neu.shadowOffset;
            }
            ApplyShadowZeroAlloc(output, color, 0, output.Count, offset.x, offset.y);
            vh.Clear();
            vh.AddUIVertexTriangleStream(output);

            output.Clear();
        }
        public void ModifyMesh(Neumorphism neu, VertexHelper vh)
        {
            if (rectTransform == null)
            {
                rectTransform = neu.GetComponent <RectTransform>();
            }
            var rect = rectTransform.rect;

            if (rect.width > rect.height)
            {
                rect.y     -= (rect.width - rect.height) * 0.5f;
                rect.height = rect.width;
            }
            else
            {
                rect.x    -= (rect.height - rect.width) * 0.5f;
                rect.width = rect.height;
            }

            var vert = default(UIVertex);

            for (int i = 0; i < vh.currentVertCount; i++)
            {
                vh.PopulateUIVertex(ref vert, i);
                vert.uv1 = Rect.PointToNormalized(rect, vert.position);
                vh.SetUIVertex(vert, i);
            }
        }