Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GraphicsHelper helper = new GraphicsHelper(e.Graphics);

            helper.Gradient(UColor.Blend(0x30, UColor.Black), UColor.Transparent, new Rectangle(0, 0, this.Width, this.Height / 2), 90);
            helper.Line(UColor.Blend(0x60, UColor.Black), 0, 0, this.Width, 0);
        }
Exemplo n.º 2
0
    private void DrawPalette()
    {
        Color = new byte[rows, columns];
        Image = new GameObject("Image");
        Image.transform.parent = gameObject.transform;
        Image.AddComponent <RectTransform>();
        Image.AddComponent <Image>();
        Image.GetComponent <RectTransform>().anchorMax        = new Vector2(1, 1);
        Image.GetComponent <RectTransform>().anchorMin        = new Vector2(1, 1);
        Image.GetComponent <RectTransform>().anchoredPosition = new Vector2(-128 / 2, -GetComponent <RectTransform>().rect.height / 2);
        Image.GetComponent <RectTransform>().sizeDelta        = new Vector2(GetComponent <RectTransform>().rect.width,
                                                                            GetComponent <RectTransform>().rect.height);

        Texture2D texture = new Texture2D(rows, columns);

        for (int index = 0; index < 256; index++)
        {
            int y = index % columns;
            int x = (index - y) / columns;
            texture.SetPixel(x, y, UColor.ByteToColor((byte)index));
            Color[x, columns - y - 1] = (byte)index;
        }
        texture.Apply(false);
        texture.filterMode = FilterMode.Point;

        Image.GetComponent <Image>().sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 1f);
        UColor.CurrentColor = Color[UColor.x, UColor.y];
    }
Exemplo n.º 3
0
            protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
            {
                GraphicsHelper helper = new GraphicsHelper(e.Graphics);

                Rectangle shadow = new Rectangle(
                    e.TextRectangle.X + 1,
                    e.TextRectangle.Y + 1,
                    e.TextRectangle.Width,
                    e.TextRectangle.Height);

                uint shadowColor = UColor.Blend(0x10, UColor.White);
                uint textColor   = UColor.Argb(255, 0xBB, 0xBB, 0xBB);

                if (e.Item.Selected || e.Item.Pressed)
                {
                    shadowColor = UColor.Blend(0x7a, UColor.White);
                    textColor   = UColor.White;
                }

                StringFormat format = new StringFormat();

                format.LineAlignment = StringAlignment.Center;
                format.Alignment     = StringAlignment.Near;

                if (!e.Item.Selected)
                {
                    helper.Text(e.Text, e.TextFont, shadowColor, shadow, format);
                }
                helper.Text(e.Text, e.TextFont, textColor, e.TextRectangle, format);
            }
Exemplo n.º 4
0
 public void Add(int heigth, UColor color)
 {
     ColorHeights.Add(new ColorHeight
     {
         Heigth = heigth,
         Color = color
     });
 }
Exemplo n.º 5
0
 public void ShowTrack(LogData _data)
 {
     m_Type.color = UColor.HEXtoColor(GetLogHexColor(_data.m_LogType));
     m_Info.text  = _data.m_LogInfo;
     m_Time.text  = UTime.GetDateTime(_data.m_Time).ToLongTimeString();
     m_Track.text = _data.m_LogTrace;
     transform.SetActive(true);
 }
Exemplo n.º 6
0
            protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
            {
                GraphicsHelper helper = new GraphicsHelper(e.Graphics);
                Rectangle      bounds = new Rectangle(-1, -1, e.AffectedBounds.Width + 1, e.AffectedBounds.Height + 1);

                //helper.Clear(UColor.Argb(255, 0, 0, 0));
                helper.Gradient(UColor.Rgb(0x30, 0x30, 0x30), UColor.Rgb(0x1D, 0x1D, 0x1D), bounds, 90);
            }
Exemplo n.º 7
0
    // Token: 0x06000023 RID: 35 RVA: 0x00002EC0 File Offset: 0x000010C0
    public static void DrawRadarBackground(Rect rect)
    {
        Color color;

        color = new UColor(30, 30, 30).Get();
        Rendering.texture2D_0.SetPixel(0, 0, color);
        Rendering.texture2D_0.Apply();
        GUI.color = color;
        GUI.DrawTexture(rect, Rendering.texture2D_0);
    }
Exemplo n.º 8
0
        public static IEnumerator GetVoxel(Volume volume)
        {
            yield return(null);

            Vector3Int vec = GetVectorIn();

            UColor.CurrentColor = volume.Voxel[vec.x, vec.y, vec.z];
            UColor.ByteToPosition();
            //Debug.Log(vec);
        }
Exemplo n.º 9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            GraphicsHelper helper = new GraphicsHelper(e.Graphics);

            const int r            = 7;
            const int shadowHeight = 4;

            Rectangle bounds         = new Rectangle(0, 0, this.Width - 1, this.Height - 1 - shadowHeight);
            Rectangle rectShadow     = new Rectangle(0, 0, Width - 1, Height - 1);
            Rectangle rectText       = bounds;
            Rectangle rectTextShadow = new Rectangle(1, 1, rectText.Width - 2, rectText.Height - 1);

            if (Image != null)
            {
                rectText = new Rectangle(bounds.X, bounds.Y, bounds.Width + Image.Width, bounds.Height);
            }

            helper.RoundedFill(UColor.White, bounds, r);

            if (!Hover)
            {
                if (Enabled)
                {
                    //32C437: Main color
                    //2AA92E: Shadow
                    //0A890D: Outline
                    const uint color         = 0x32c437;
                    const uint color_shadow  = 0x2aa92e;
                    const uint color_outline = 0x0a890d;
                    helper.RoundedFill(UColor.Blend(255, color_shadow), rectShadow, r);
                    helper.RoundedGradient(UColor.Blend(200, color), UColor.Blend(255, color), bounds, 90, r);
                    helper.RoundedOutline(UColor.Blend(255, color_outline), rectShadow, r);

                    helper.Text(Caption, this.Font, UColor.White, rectTextShadow);
                    helper.Text(Caption, this.Font, UColor.Blend(0xdd, UColor.White), rectText);
                }
                else
                {
                }
            }
            else
            {
                if (!Pressed)
                {
                }
                else
                {
                }
            }

            if (Image != null)
            {
                e.Graphics.DrawImage(this.Image, new Point(this.Width / 4 - this.Image.Width / 2, this.Height / 2 - this.Image.Height / 2));
            }
        }
Exemplo n.º 10
0
            protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
            {
                GraphicsHelper  helper = new GraphicsHelper(e.Graphics);
                ToolStripButton button = e.Item as ToolStripButton;
                Rectangle       bounds = new Rectangle(0, 0, e.Item.Width - 1, e.Item.Height - 1);

                if (e.Item.Selected)
                {
                    helper.RoundedGradient(UColor.Rgb(0x06, 0x88, 0xB8), UColor.Rgb(0x06, 0x88, 0xB8), bounds, 90, 2);
                }
            }
Exemplo n.º 11
0
 public override void DrawRect(URect rect, UColor color, bool fill)
 {
     if (fill)
     {
         g.FillRectangle(new SolidBrush(ParseColor(color)), rect.X, rect.Y, rect.Width, rect.Height);
     }
     else
     {
         g.DrawRectangle(new Pen(ParseColor(color)), rect.X, rect.Y, rect.Width, rect.Height);
     }
 }
Exemplo n.º 12
0
 private void SetButton_Click(object sender, RoutedEventArgs e)
 {
     if (CurrentColor is null)
     {
         UColor color = new UColor("Color", "_", 0, 0, 0);
         if (Colormap.AddColor(color))
         {
             CurrentColor = color;
         }
     }
     SaveColor();
 }
Exemplo n.º 13
0
        public void OnPaintBarBackground(PaintEventArgs e)
        {
            GraphicsHelper graphics = new GraphicsHelper(e.Graphics);
            const int      radius   = 7;
            const int      blend    = 245;
            Rectangle      bound    = new Rectangle(DisplayRectangle.X + 1, DisplayRectangle.Y, Width - 3, Height - 2);

            graphics.RoundedFill(UColor.White, bound, radius);
            graphics.RoundedGradient(UColor.Blend(blend, UColor.Rgb(60, 60, 60)), UColor.Blend(blend, UColor.Rgb(38, 38, 38)), bound, 90, radius);
            graphics.RoundedOutline(UColor.Black, new Rectangle(bound.X + 1, bound.Y + 1, bound.Width - 1, bound.Height - 1), radius);
            graphics.Line(UColor.Blend(50, UColor.White), radius, 0, Width - radius, 0);
        }
Exemplo n.º 14
0
            protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
            {
                GraphicsHelper helper = new GraphicsHelper(e.Graphics);
                Rectangle      bounds = e.AffectedBounds;

                helper.Line(UColor.Blend(155 / 2, UColor.Rgb(0x06, 0x88, 0xD8)), 0, bounds.Width, bounds.Height - 3);
                helper.Line(UColor.Blend(155, UColor.Rgb(0x06, 0x88, 0xD8)), 0, bounds.Width, bounds.Height - 2);
                helper.Line(UColor.Rgb(0x06, 0x88, 0xD8), 0, bounds.Width, bounds.Height - 1);
//				helper.Line(UColor.Rgb(25, 25, 25), 0, bounds.Width, bounds.Height - 1);

                base.OnRenderToolStripBorder(e);
            }
Exemplo n.º 15
0
        public void OnPaintItem(PaintEventArgs e, MenuBarItem item)
        {
            GraphicsHelper helper = new GraphicsHelper(e.Graphics);
            const int      radius = 3;
            Rectangle      bound  = item.Bound;

            helper.RoundedGradient(UColor.Rgb(0x4d, 0x9f, 0xcf), UColor.Rgb(0x15, 0x69, 0x97), item.Bound, 90, radius);
            helper.Gradient(UColor.Blend(130, UColor.White), UColor.Blend(70, UColor.White), new Rectangle(item.Bound.X, item.Bound.Y + 1, 1, item.Bound.Height - radius), 90);
            helper.Gradient(UColor.Blend(130, UColor.White), UColor.Blend(70, UColor.White), new Rectangle(item.Bound.X + item.Bound.Width - radius + 2, item.Bound.Y + 1, 1, item.Bound.Height - radius), 90);
            helper.RoundedOutline(UColor.Rgb(0x18, 0x18, 0x18), item.Bound, radius);
            helper.Line(UColor.White, bound.X + radius, bound.Y + bound.Height - 1, bound.Width - radius, bound.Y + bound.Height - 1);
        }
Exemplo n.º 16
0
 public void SetData(bool _collapse, int _count = 0)
 {
     m_Type.color = UColor.HEXtoColor(GetLogHexColor(m_Data.m_LogType));
     m_Info.text  = m_Data.m_LogInfo;
     if (_collapse)
     {
         m_Info.text = string.Format("{0} {1}", _count, m_Data.m_LogInfo);
     }
     else
     {
         m_Info.text = string.Format("{0} {1}", UTime.GetDateTime(m_Data.m_Time).ToShortTimeString(), m_Data.m_LogInfo);
     }
 }
Exemplo n.º 17
0
        private void ReadColor(int oldcNum, int cNum, UColor color)
        {
            if (cNum < oldcNum) cNum = oldcNum;
            if (cNum > MAX_COLOR_INDEX) cNum = MAX_COLOR_INDEX;

            __ColorTable[cNum] = color;

            for (var i = oldcNum + 1; i < cNum; i++)
                __ColorTable[i] = UColor.Merge(
                    __ColorTable[oldcNum],
                    __ColorTable[cNum],
                    cNum - i,
                    i - oldcNum);
        }
Exemplo n.º 18
0
    }//spawnSprite

    //*******************************************************
    //*******************************************************
    public static void CircleOnTex(Texture2D tex, int cx, int cy, int rad, Color color, float outlineThickness = 0.2f, float outlineBrightness = 0.75f)
    {
        int x, y, px, nx, py, ny, d;

        Color altColor;

        if (color != Color.clear)
        {
            altColor = UColor.ChangeRelativeBrightness(color, outlineBrightness);
        }
        else
        {
            altColor = Color.black;
        }//else

        Color[] fillColorArray = tex.GetPixels();

        for (var i = 0; i < fillColorArray.Length; ++i)
        {
            fillColorArray[i] = Color.clear;
        }

        tex.SetPixels(fillColorArray);

        for (x = 0; x <= rad; x++)
        {
            d = (int)Mathf.Ceil(Mathf.Sqrt(rad * rad - x * x));
            for (y = 0; y <= d; y++)
            {
                Vector2 mag      = new Vector2(x, y);
                Color   theColor = color;
                if (mag.magnitude > rad * (1 - outlineThickness))
                {
                    theColor = altColor;
                }//if

                px = cx + x;
                nx = cx - x;
                py = cy + y;
                ny = cy - y;

                tex.SetPixel(px, py, theColor);
                tex.SetPixel(nx, py, theColor);

                tex.SetPixel(px, ny, theColor);
                tex.SetPixel(nx, ny, theColor);
            } //for
        }     //for
    }         //circleOnTex
Exemplo n.º 19
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            UColor color = new UColor(NameTextBox.Text, SuffixTextBox.Text, ColorCanvas.R, ColorCanvas.G, ColorCanvas.B);

            if (Colormap.AddColor(color))
            {
                CurrentColor = color;
                Refresh();
            }
            else
            {
                MessageBox.Show("Suffix must be unique.", "Error on adding a Color", MessageBoxButton.OK, MessageBoxImage.Error);
                CurrentColor = null;
            }
        }
Exemplo n.º 20
0
        private void ColorMapView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SaveColor();
            ListView listView = (ListView)sender;
            UColor   color    = (UColor)listView.SelectedItem;

            if (color == null)
            {
                return;
            }
            NameTextBox.Text   = color.Name;
            SuffixTextBox.Text = color.Suffix;
            ColorCanvas.R      = color.Color.R;
            ColorCanvas.G      = color.Color.G;
            ColorCanvas.B      = color.Color.B;
            CurrentColor       = color;
        }
Exemplo n.º 21
0
        //
        // Constructor
        //
        public ZoomView(int priority, string name, float x, float y)
            : base(priority, name, x, y, 0, 0)
        {
            font1       = UFontManager.getFont(UDrawUtility.FontName, fontSize);
            brush1      = Brushes.DarkBlue;
            brush2      = Brushes.DarkRed;
            brush3      = Brushes.LightGray;
            hoverBrush1 = new SolidBrush(Color.FromArgb(UColor.setBrightness(Color.DarkBlue.ToArgb(), 128)));
            hoverBrush2 = new SolidBrush(Color.FromArgb(UColor.setBrightness(Color.DarkRed.ToArgb(), 128)));
            hoverBrush3 = new SolidBrush(Color.FromArgb(UColor.setBrightness(Color.Gray.ToArgb(), 128)));
            zoom        = new ZoomRate();
            int _x = (int)pos.X;

            rect1 = new Rectangle(_x, (int)pos.Y, smallButtonW, smallButtonW);
            _x   += smallButtonW + marginX;
            rect2 = new Rectangle(_x, (int)pos.Y, centerButtonW, centerButtonH);
            _x   += centerButtonW + marginX;
            rect3 = new Rectangle(_x, (int)pos.Y, smallButtonW, smallButtonW);
        }
Exemplo n.º 22
0
        public void PropertyCanReadStructColorValueTest()
        {
            string name           = "SpriteEmitter544";
            Export Exp            = ExportTable.FindAll(n => n.NameTableRef == NameTable.IndexOf(name))?.First();
            int    PropertyOffset = 0x0B + Exp.SerialOffset + 28;
            //Act
            Property Prop = new Property(pf.Bytes, PropertyOffset);

            Prop.SetStructType(StructType.Color);
            UColor Col = Prop.Value as UColor;

            //Assert
            Assert.IsTrue(Prop.Value is UColor);
            Assert.AreEqual(Prop.Size, 7);
            Assert.AreEqual(Prop.NameTableRef.Value, NameTable.IndexOf("Color"));
            Assert.AreEqual((byte)255, Col.a);
            Assert.AreEqual((byte)255, Col.b);
            Assert.AreEqual((byte)255, Col.g);
            Assert.AreEqual((byte)255, Col.r);
        }
Exemplo n.º 23
0
        private Color32 GetGroundColor()
        {
            Color32    color = new Color32();
            RaycastHit hit;

            if (Physics.SphereCast(transform.position, characterController.radius,
                                   transform.TransformDirection(Vector3.down), out hit, characterController.height / 3))
            {
                Vector3 position = hit.point;
                position += hit.normal * 0.5f;

                int x = Mathf.RoundToInt(position.x);
                int y = Mathf.RoundToInt(position.y);
                int z = Mathf.RoundToInt(position.z);

                color = UColor.ByteToColor(volume.GetComponent <MVolume>().volume.Voxel[x, y, z]);

                return(color);
            }
            return(color);
        }
Exemplo n.º 24
0
 public override void Clear(UColor backColor)
 {
     g.Clear(ParseColor(backColor));
 }
Exemplo n.º 25
0
 private UColor MergeColors(UColor l, UColor r, double percent)
 {
     return new UColor(
         (byte)(l.A * percent + r.A * (1 - percent)),
         (byte)(l.R * percent + r.R * (1 - percent)),
         (byte)(l.G * percent + r.G * (1 - percent)),
         (byte)(l.B * percent + r.B * (1 - percent)));
 }
Exemplo n.º 26
0
        private const float Scale = 1f; // Scale of the mesh

        public static Mesh Get(int chunkX, int chunkZ, Volume volume)
        {
            _cx = chunkX * 16;
            _cz = chunkZ * 16;

            var vertices  = new List <Vector3>();
            var colors32  = new List <Color32>();
            var triangles = new List <int>();
            var uv        = new List <Vector2>();

            var dimensions = new [] { ChunkSize.X, ChunkSize.Y, ChunkSize.Z }; // Size of each axis

            for (var d = 0; d < 3; d++)                                        // Iterate for x, y, z axis: 0 = x; 1 = y; 2 = z;
            {
                var u         = (d + 1) % 3;
                var v         = (d + 2) % 3;
                var x         = new int[3];
                var q         = new int[3]; q[d] = 1;
                var mask      = new int[dimensions[u] * dimensions[v]];
                var colorMask = new byte[dimensions[u] * dimensions[v]];

                for (x[d] = -1; x[d] < dimensions[d];) // Do something 16 times
                {
                    var n = 0;
                    for (x[v] = 0; x[v] < dimensions[v]; ++x[v])          // x
                    {
                        for (x[u] = 0; x[u] < dimensions[u]; ++x[u], ++n) // y
                        {
                            var current = (x[d] >= 0 ? Data(x[0], x[1], x[2], volume) : 0);
                            var next    = (x[d] < dimensions[d] - 1 ? Data(x[0] + q[0], x[1] + q[1], x[2] + q[2], volume) : 0);
                            if (current != next)
                            {
                                if (current > 0 && next > 0)
                                {
                                    mask[n]      = 0;
                                    colorMask[n] = 0;
                                }
                                else if (current == 0)
                                {
                                    mask[n]      = -1;
                                    colorMask[n] = (byte)next;
                                }
                                else if (next == 0)
                                {
                                    mask[n]      = 1;
                                    colorMask[n] = (byte)current;
                                }
                                else
                                {
                                    mask[n]      = 0;
                                    colorMask[n] = 0;
                                }
                            }
                            else
                            {
                                mask[n]      = 0;
                                colorMask[n] = 0;
                            }
                        }
                    } // End.

                    x[d]++;
                    n = 0;
                    for (var j = 0; j < dimensions[v]; ++j)
                    {
                        for (var i = 0; i < dimensions[u];)
                        {
                            var maskValue  = mask[n];
                            var colorValue = colorMask[n];
                            if (maskValue != 0)
                            {
                                int l, k;

                                var w = 1;
                                for (;
                                     n + w < mask.Length && mask[n + w] == maskValue && colorValue == colorMask[n + w] &&
                                     i + w < dimensions[u];
                                     ++w)
                                {
                                }

                                var h    = 1;
                                var done = false;
                                for (; j + h < dimensions[v]; ++h)
                                {
                                    for (k = 0; k < w; ++k)
                                    {
                                        if (mask[n + k + h * dimensions[u]] != maskValue ||
                                            colorMask[n + k + h * dimensions[u]] != colorValue)
                                        {
                                            done = true;
                                            break;
                                        }
                                    }

                                    if (done)
                                    {
                                        break;
                                    }
                                }

                                var xp = new Vector3();
                                xp[u] = i;
                                xp[v] = j;
                                xp[d] = x[d];
                                xp   *= Scale;
                                var du = new Vector3();
                                du[u] = w * Scale;
                                var dv = new Vector3();
                                dv[v] = h * Scale;
                                AddFace(
                                    new Vector3(xp[0], xp[1], xp[2]),
                                    new Vector3(xp[0] + du[0], xp[1] + du[1], xp[2] + du[2]),
                                    new Vector3(xp[0] + du[0] + dv[0], xp[1] + du[1] + dv[1], xp[2] + du[2] + dv[2]),
                                    new Vector3(xp[0] + dv[0], xp[1] + dv[1], xp[2] + dv[2]),
                                    UColor.ByteToColor(colorValue), d, maskValue < 0,
                                    vertices, colors32, triangles, uv);
                                for (l = 0; l < h; ++l)
                                {
                                    for (k = 0; k < w; ++k)
                                    {
                                        mask[(n + k) + l * dimensions[u]]      = 0;
                                        colorMask[(n + k) + l * dimensions[u]] = 0;
                                    }
                                }

                                i += w;
                                n += w;
                            }
                            else
                            {
                                ++i;
                                ++n;
                            }
                        }
                    }
                }
            }

            return(new Mesh
            {
                vertices = vertices.ToArray(),
                triangles = triangles.ToArray(),
                colors32 = colors32.ToArray()
            });
        }
Exemplo n.º 27
0
        private static void AddFace(int x, int y, int z, int index, byte inputColor, byte faceId,
                                    uint block01, uint block02, uint block03,
                                    uint block04, uint block05, uint block06,
                                    uint block07, uint block08, uint block09,
                                    uint block11, uint block12, uint block13,
                                    uint block14, uint block16,
                                    uint block17, uint block18, uint block19,
                                    uint block21, uint block22, uint block23,
                                    uint block24, uint block25, uint block26,
                                    uint block27, uint block28, uint block29,
                                    Vector3[] vertices, int[] triangles, Color32[] colors32)
        {
            float ao1F    = 3.5f;  //3.5  // 4
            float ao2F    = 1.5f;  //1.5  //1.2
            float lightX  = 0.20f; //0.20f   /0.15f
            float lightPy = 0;
            float lightNy = 0.5f;  //0.5f  //0.35f
            float lightZ  = 0.25f; //0.25f  //0.2


            bool    flipped = false;
            uint    empty   = 0x00000000;
            Color32 color   = UColor.ByteToColor(inputColor);

            index = index * 4;

            float xScale = x / Scale;
            float yScale = y / Scale;
            float zScale = z / Scale;
            float i      = 1 / Scale;


            if (faceId == 1)
            {
                color = new Color32((byte)(color.r - color.r * lightX), (byte)(color.g - color.g * lightX),
                                    (byte)(color.b - color.b * lightX), 255);
                Color32 ao1 = CalculateAo(color.r, color.g, color.b, ao1F);
                Color32 ao2 = CalculateAo(color.r, color.g, color.b, ao2F);

                if (block19 != empty && block06 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale); //1
                    colors32[index] = ao2;
                    flipped         = true;
                }
                else if (block19 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale); //1
                    colors32[index] = ao1;
                }
                else if (block06 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale); //1
                    colors32[index] = ao1;
                }
                else if (block09 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale); //1
                    colors32[index] = ao1;
                    flipped         = true;
                }
                else
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale); //1
                    colors32[index] = color;
                }

                if (block19 != empty && block26 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale); //2
                    colors32[index + 1] = ao2;
                }
                else if (block19 != empty)
                {
                    vertices[index + 1] = new Vector3(xScale + i, yScale, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else if (block26 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else if (block29 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else
                {
                    vertices[index + 1] = new Vector3(xScale + i, yScale, zScale); //2
                    colors32[index + 1] = color;
                }

                if (block13 != empty && block26 != empty)
                {
                    vertices[index + 2] =
                        new Vector3(xScale + i, yScale, zScale + i); //3
                    colors32[index + 2] = ao2;
                    flipped             = true;
                }
                else if (block13 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale + i); //3
                    colors32[index + 2] = ao1;
                }
                else if (block26 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale + i); //3
                    colors32[index + 2] = ao1;
                }
                else if (block23 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale + i); //3
                    colors32[index + 2] = ao1;
                    flipped             = true;
                }
                else
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale + i); //3
                    colors32[index + 2] = color;
                }

                if (block13 != empty && block06 != empty)
                {
                    vertices[index + 3] =
                        new Vector3(xScale + i, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao2;
                }
                else if (block13 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao1;
                }
                else if (block06 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao1;
                }
                else if (block03 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao1;
                }
                else
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale + i); //4
                    colors32[index + 3] = color;
                }
            }

            if (faceId == 2)
            {
                color = new Color32((byte)(color.r - color.r * lightX), (byte)(color.g - color.g * lightX),
                                    (byte)(color.b - color.b * lightX), 255);
                Color32 ao1 = CalculateAo(color.r, color.g, color.b, ao1F);
                Color32 ao2 = CalculateAo(color.r, color.g, color.b, ao2F);

                if (block11 != empty && block04 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale + i); //1
                    colors32[index] = ao2;
                    flipped         = true;
                }
                else if (block11 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale + i); //1
                    colors32[index] = ao1;
                }
                else if (block04 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale + i); //1
                    colors32[index] = ao1;
                }
                else if (block01 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale + i); //1
                    colors32[index] = ao1;
                    flipped         = true;
                }
                else
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale + i); //1
                    colors32[index] = color;
                }

                if (block11 != empty && block24 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale, yScale, zScale + i); //2
                    colors32[index + 1] = ao2;
                }
                else if (block11 != empty)
                {
                    vertices[index + 1] = new Vector3(xScale, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else if (block24 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else if (block21 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else
                {
                    vertices[index + 1] = new Vector3(xScale, yScale, zScale + i); //2
                    colors32[index + 1] = color;
                }

                if (block17 != empty && block24 != empty)
                {
                    vertices[index + 2] =
                        new Vector3(xScale, yScale, zScale); //3
                    colors32[index + 2] = ao2;
                    flipped             = true;
                }
                else if (block17 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                }
                else if (block24 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                }
                else if (block27 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                    flipped             = true;
                }
                else
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale); //3
                    colors32[index + 2] = color;
                }

                if (block17 != empty && block04 != empty)
                {
                    vertices[index + 3] =
                        new Vector3(xScale, yScale - i, zScale); //4
                    colors32[index + 3] = ao2;
                }
                else if (block17 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else if (block04 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else if (block07 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale); //4
                    colors32[index + 3] = color;
                }
            }

            if (faceId == 3)
            {
                color = new Color32((byte)(color.r - color.r * lightPy), (byte)(color.g - color.g * lightPy),
                                    (byte)(color.b - color.b * lightPy), 255);
                Color32 ao1 = CalculateAo(color.r, color.g, color.b, ao1F);
                Color32 ao2 = CalculateAo(color.r, color.g, color.b, ao2F);

                if (block22 != empty && block24 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale, zScale + i); //1
                    colors32[index] = ao2;
                    flipped         = true;
                }
                else if (block22 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale, zScale + i); //1
                    colors32[index] = ao1;
                }
                else if (block24 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale, zScale + i); //1
                    colors32[index] = ao1;
                }
                else if (block21 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale, zScale + i); //1
                    colors32[index] = ao1;
                    flipped         = true;
                }
                else
                {
                    vertices[index] = new Vector3(xScale, yScale, zScale + i); //1
                    colors32[index] = color;
                }

                if (block22 != empty && block26 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao2;
                }
                else if (block22 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else if (block26 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else if (block23 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else
                {
                    vertices[index + 1] = new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = color;
                }

                if (block28 != empty && block26 != empty)
                {
                    vertices[index + 2] =
                        new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao2;
                    flipped             = true;
                }
                else if (block28 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                }
                else if (block26 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                }
                else if (block29 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                    flipped             = true;
                }
                else
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = color;
                }

                if (block28 != empty && block24 != empty)
                {
                    vertices[index + 3] =
                        new Vector3(xScale, yScale, zScale); //4
                    colors32[index + 3] = ao2;
                }
                else if (block28 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else if (block24 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else if (block27 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else
                {
                    vertices[index + 3] = new Vector3(xScale, yScale, zScale); //4
                    colors32[index + 3] = color;
                }
            }

            if (faceId == 4)
            {
                color = new Color32((byte)(color.r - color.r * lightNy), (byte)(color.g - color.g * lightNy),
                                    (byte)(color.b - color.b * lightNy), 255);
                Color32 ao1 = CalculateAo(color.r, color.g, color.b, ao1F);
                Color32 ao2 = CalculateAo(color.r, color.g, color.b, ao2F);

                if (block08 != empty && block04 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao2;
                    flipped         = true;
                }
                else if (block08 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao1;
                }
                else if (block04 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao1;
                }
                else if (block07 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao1;
                    flipped         = true;
                }
                else
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = color;
                }

                if (block08 != empty && block06 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale - i, zScale); //2
                    colors32[index + 1] = ao2;
                }
                else if (block08 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale - i, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else if (block06 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale - i, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else if (block09 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale - i, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else
                {
                    vertices[index + 1] = new Vector3(xScale + i, yScale - i, zScale); //2
                    colors32[index + 1] = color;
                }

                if (block02 != empty && block06 != empty)
                {
                    vertices[index + 2] =
                        new Vector3(xScale + i, yScale - i, zScale + i); //3
                    colors32[index + 2] = ao2;
                    flipped             = true;
                }
                else if (block02 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale - i, zScale + i); //3
                    colors32[index + 2] = ao1;
                }
                else if (block06 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale - i, zScale + i); //3
                    colors32[index + 2] = ao1;
                }
                else if (block03 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale - i, zScale + i); //3
                    colors32[index + 2] = ao1;
                    flipped             = true;
                }
                else
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale - i, zScale + i); //3
                    colors32[index + 2] = color;
                }

                if (block02 != empty && block04 != empty)
                {
                    vertices[index + 3] =
                        new Vector3(xScale, yScale - i, zScale + i); // 4
                    colors32[index + 3] = ao2;
                }
                else if (block02 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); // 4
                    colors32[index + 3] = ao1;
                }
                else if (block04 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); // 4
                    colors32[index + 3] = ao1;
                }
                else if (block01 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); // 4
                    colors32[index + 3] = ao1;
                }
                else
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); // 4
                    colors32[index + 3] = color;
                }
            }

            if (faceId == 5)
            {
                color = new Color32((byte)(color.r - color.r * lightZ), (byte)(color.g - color.g * lightZ),
                                    (byte)(color.b - color.b * lightZ), 255);
                Color32 ao1 = CalculateAo(color.r, color.g, color.b, ao1F);
                Color32 ao2 = CalculateAo(color.r, color.g, color.b, ao2F);

                if (block13 != empty && block02 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale + i); //1
                    colors32[index] = ao2;
                    flipped         = true;
                }
                else if (block13 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale + i); //1
                    colors32[index] = ao1;
                }
                else if (block02 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale + i); //1
                    colors32[index] = ao1;
                }
                else if (block03 != empty)
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale + i); //1
                    colors32[index] = ao1;
                    flipped         = true;
                }
                else
                {
                    vertices[index] = new Vector3(xScale + i, yScale - i, zScale + i); //1
                    colors32[index] = color;
                }

                if (block13 != empty && block22 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao2;
                }
                else if (block13 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else if (block22 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else if (block23 != empty)
                {
                    vertices[index + 1] =
                        new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = ao1;
                }
                else
                {
                    vertices[index + 1] = new Vector3(xScale + i, yScale, zScale + i); //2
                    colors32[index + 1] = color;
                }

                if (block11 != empty && block22 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale + i); //3
                    colors32[index + 2] = ao2;
                    flipped             = true;
                }
                else if (block11 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale + i); //3
                    colors32[index + 2] = ao1;
                }
                else if (block22 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale + i); //3
                    colors32[index + 2] = ao1;
                }
                else if (block21 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale + i); //3
                    colors32[index + 2] = ao1;
                    flipped             = true;
                }
                else
                {
                    vertices[index + 2] = new Vector3(xScale, yScale, zScale + i); //3
                    colors32[index + 2] = color;
                }

                if (block11 != empty && block02 != empty)
                {
                    vertices[index + 3] =
                        new Vector3(xScale, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao2;
                }
                else if (block11 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao1;
                }
                else if (block02 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao1;
                }
                else if (block01 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); //4
                    colors32[index + 3] = ao1;
                }
                else
                {
                    vertices[index + 3] = new Vector3(xScale, yScale - i, zScale + i); //4
                    colors32[index + 3] = color;
                }
            }

            if (faceId == 6)
            {
                color = new Color32((byte)(color.r - color.r * lightZ), (byte)(color.g - color.g * lightZ),
                                    (byte)(color.b - color.b * lightZ), 255);
                Color32 ao1 = CalculateAo(color.r, color.g, color.b, ao1F);
                Color32 ao2 = CalculateAo(color.r, color.g, color.b, ao2F);

                if (block17 != empty && block08 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao2;
                    flipped         = true;
                }
                else if (block17 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao1;
                }
                else if (block08 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao1;
                }
                else if (block07 != empty)
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = ao1;
                    flipped         = true;
                }
                else
                {
                    vertices[index] = new Vector3(xScale, yScale - i, zScale); //1
                    colors32[index] = color;
                }

                if (block17 != empty && block28 != empty)
                {
                    vertices[index + 1] = new Vector3(xScale, yScale, zScale); //2
                    colors32[index + 1] = ao2;
                }
                else if (block17 != empty)
                {
                    vertices[index + 1] = new Vector3(xScale, yScale, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else if (block28 != empty)
                {
                    vertices[index + 1] = new Vector3(xScale, yScale, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else if (block27 != empty)
                {
                    vertices[index + 1] = new Vector3(xScale, yScale, zScale); //2
                    colors32[index + 1] = ao1;
                }
                else
                {
                    vertices[index + 1] = new Vector3(xScale, yScale, zScale); //2
                    colors32[index + 1] = color;
                }

                if (block19 != empty && block28 != empty)
                {
                    vertices[index + 2] =
                        new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao2;
                    flipped             = true;
                }
                else if (block19 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                }
                else if (block28 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                }
                else if (block29 != empty)
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = ao1;
                    flipped             = true;
                }
                else
                {
                    vertices[index + 2] = new Vector3(xScale + i, yScale, zScale); //3
                    colors32[index + 2] = color;
                }

                if (block19 != empty && block08 != empty)
                {
                    vertices[index + 3] =
                        new Vector3(xScale + i, yScale - i, zScale); //4
                    colors32[index + 3] = ao2;
                }
                else if (block19 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else if (block08 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else if (block09 != empty)
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale); //4
                    colors32[index + 3] = ao1;
                }
                else
                {
                    vertices[index + 3] = new Vector3(xScale + i, yScale - i, zScale); //4
                    colors32[index + 3] = color;
                }
            }

            int face = index / 4;

            index = index / 4 * 6;
            if (!flipped)
            {
                triangles[index]     = face * 4;
                triangles[index + 1] = face * 4 + 1;
                triangles[index + 2] = face * 4 + 2;
                triangles[index + 3] = face * 4;
                triangles[index + 4] = face * 4 + 2;
                triangles[index + 5] = face * 4 + 3;
            }
            else
            {
                triangles[index]     = face * 4 + 3;
                triangles[index + 1] = face * 4;
                triangles[index + 2] = face * 4 + 1;
                triangles[index + 3] = face * 4 + 3;
                triangles[index + 4] = face * 4 + 1;
                triangles[index + 5] = face * 4 + 2;
            }

            flipped = false;
        }
Exemplo n.º 28
0
        private bool IsColorDivEnabled(UColor[] colors, float indent)
        {
            for (int i = 0; i < colors.Length; i++)
                for (int j = i + 1; j < colors.Length; j++)
                    if (!IsColorsEquels(colors[i], colors[j], indent))
                        return false;

            return true;
        }
Exemplo n.º 29
0
 public override void DrawText(float x, float y, string text, UColor color)
 {
     g.DrawString(text, font, new SolidBrush(ParseColor(color)), x, y);
 }
Exemplo n.º 30
0
 private Color ParseColor(UColor color)
 {
     return(Color.FromArgb(color.A, color.R, color.G, color.B));
 }
Exemplo n.º 31
0
 private bool IsColorsEquels(UColor c1, UColor c2, float indent)
 {
     if (Math.Abs((c1.R - c2.R) / 256f) >= indent)
         return false;
     if (Math.Abs((c1.G - c2.G) / 256f) >= indent)
         return false;
     if (Math.Abs((c1.B - c2.B) / 256f) >= indent)
         return false;
     return true;
 }
Exemplo n.º 32
0
        public override void DrawDash(UPoint startPos, UPoint endPos, UColor color)
        {
            dashPen.Color = ParseColor(color);

            g.DrawLine(dashPen, new PointF(startPos.X, startPos.Y), new PointF(endPos.X, endPos.Y));
        }
Exemplo n.º 33
0
 public override void DrawLine(UPoint startPos, UPoint endPos, UColor color)
 {
     g.DrawLine(new Pen(ParseColor(color)), startPos.X, startPos.Y, endPos.X, endPos.Y);
 }
        void GenerateVertexTexture(GameObject _targetFBX, AnimationClip[] _clips)
        {
            if (!UEAsset.SelectDirectory(_targetFBX, out string savePath, out string meshName))
            {
                Debug.LogWarning("Invalid Folder Selected");
                return;
            }
            GameObject          instantiatedObj     = GameObject.Instantiate(m_TargetPrefab);
            SkinnedMeshRenderer skinnedMeshRenderer = instantiatedObj.GetComponentInChildren <SkinnedMeshRenderer>();

            #region Bake Animation Atlas
            int vertexCount       = skinnedMeshRenderer.sharedMesh.vertexCount;
            int totalVertexRecord = vertexCount * 2;
            int totalFrame        = GetInstanceParams(_clips, out AnimationInstanceParam[] instanceParams);

            Texture2D atlasTexture = new Texture2D(Mathf.NextPowerOfTwo(totalVertexRecord), Mathf.NextPowerOfTwo(totalFrame), TextureFormat.RGBAHalf, false);
            atlasTexture.filterMode = FilterMode.Point;
            atlasTexture.wrapModeU  = TextureWrapMode.Clamp;
            atlasTexture.wrapModeV  = TextureWrapMode.Repeat;
            UBoundsChecker.Begin();
            for (int i = 0; i < _clips.Length; i++)
            {
                AnimationClip clip           = _clips[i];
                Mesh          vertexBakeMesh = new Mesh();
                float         length         = clip.length;
                float         frameRate      = clip.frameRate;
                int           frameCount     = (int)(length * frameRate);
                int           startFrame     = instanceParams[i].m_FrameBegin;
                for (int j = 0; j < frameCount; j++)
                {
                    clip.SampleAnimation(instantiatedObj, length * j / frameCount);
                    skinnedMeshRenderer.BakeMesh(vertexBakeMesh);
                    Vector3[] vertices = vertexBakeMesh.vertices;
                    Vector3[] normals  = vertexBakeMesh.normals;
                    for (int k = 0; k < vertexCount; k++)
                    {
                        UBoundsChecker.CheckBounds(vertices[k]);
                        atlasTexture.SetPixel(k * 2, startFrame + j, UColor.VectorToColor(vertices[k]));
                        atlasTexture.SetPixel(k * 2 + 1, startFrame + j, UColor.VectorToColor(normals[k]));
                    }
                }
                vertexBakeMesh.Clear();
            }
            atlasTexture.Apply();
            #endregion

            #region Bake Mesh
            Mesh instanceMesh = skinnedMeshRenderer.sharedMesh.Copy();
            instanceMesh.normals     = null;
            instanceMesh.tangents    = null;
            instanceMesh.boneWeights = null;
            instanceMesh.bindposes   = null;
            instanceMesh.bounds      = UBoundsChecker.CalculateBounds();
            #endregion
            DestroyImmediate(instantiatedObj);

            GPUAnimationData data = ScriptableObject.CreateInstance <GPUAnimationData>();
            data.m_Animations = instanceParams;
            data = UEAsset.CreateAssetCombination(savePath + meshName + "_GPU_Vertex.asset", data, new KeyValuePair <string, Object>(meshName + "_AnimationAtlas", atlasTexture), new KeyValuePair <string, Object>(meshName + "_InstanceMesh", instanceMesh));
            Object[] assets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(data));
            foreach (var asset in assets)
            {
                Texture2D atlas = asset as Texture2D;
                Mesh      mesh  = asset as Mesh;
                if (atlas)
                {
                    data.m_AnimationAtlas = atlas;
                }
                if (mesh)
                {
                    data.m_InstancedMesh = mesh;
                }
            }
            AssetDatabase.SaveAssets();
        }
        void GenerateBoneInstanceMeshAndTexture(GameObject _targetFBX, AnimationClip[] _clips, string exposeBones)
        {
            if (!UEAsset.SelectDirectory(_targetFBX, out string savePath, out string meshName))
            {
                Debug.LogWarning("Invalid Folder Selected");
                return;
            }
            GameObject          _instantiatedObj     = GameObject.Instantiate(m_TargetPrefab);
            SkinnedMeshRenderer _skinnedMeshRenderer = _instantiatedObj.GetComponentInChildren <SkinnedMeshRenderer>();

            try
            {
                Matrix4x4[] bindPoses = _skinnedMeshRenderer.sharedMesh.bindposes;
                Transform[] bones     = _skinnedMeshRenderer.bones;
                #region Record Expose Bone
                List <AnimationInstanceExposeBone> exposeBoneParam = new List <AnimationInstanceExposeBone>();
                if (exposeBones != "")
                {
                    Transform[] activeTransforms = _instantiatedObj.GetComponentsInChildren <Transform>();
                    for (int i = 0; i < activeTransforms.Length; i++)
                    {
                        if (!System.Text.RegularExpressions.Regex.Match(activeTransforms[i].name, exposeBones).Success)
                        {
                            continue;
                        }
                        int       relativeBoneIndex = -1;
                        Transform relativeBone      = activeTransforms[i];
                        while (relativeBone != null)
                        {
                            relativeBoneIndex = System.Array.FindIndex(bones, p => p == relativeBone);
                            if (relativeBoneIndex != -1)
                            {
                                break;
                            }
                            relativeBone = relativeBone.parent;
                        }
                        if (relativeBoneIndex == -1)
                        {
                            continue;
                        }

                        Matrix4x4 rootWorldToLocal = _skinnedMeshRenderer.transform.worldToLocalMatrix;

                        exposeBoneParam.Add(new AnimationInstanceExposeBone()
                        {
                            m_BoneIndex = relativeBoneIndex,
                            m_BoneName  = activeTransforms[i].name,
                            m_Position  = rootWorldToLocal.MultiplyPoint(activeTransforms[i].transform.position),
                            m_Direction = rootWorldToLocal.MultiplyVector(activeTransforms[i].transform.forward)
                        });
                    }
                }
                #endregion
                #region Bake Animation Atlas
                int boneCount  = _skinnedMeshRenderer.sharedMesh.bindposes.Length;
                int totalWdith = boneCount * 3;
                int totalFrame = GetInstanceParams(_clips, out AnimationInstanceParam[] instanceParams);
                List <AnimationInstanceEvent> instanceEvents = new List <AnimationInstanceEvent>();

                Texture2D atlasTexture = new Texture2D(Mathf.NextPowerOfTwo(totalWdith), Mathf.NextPowerOfTwo(totalFrame), TextureFormat.RGBAHalf, false);
                atlasTexture.filterMode = FilterMode.Point;
                atlasTexture.wrapModeU  = TextureWrapMode.Clamp;
                atlasTexture.wrapModeV  = TextureWrapMode.Repeat;
                UBoundsChecker.Begin();
                for (int i = 0; i < _clips.Length; i++)
                {
                    AnimationClip clip       = _clips[i];
                    float         length     = clip.length;
                    float         frameRate  = clip.frameRate;
                    int           frameCount = (int)(length * frameRate);
                    int           startFrame = instanceParams[i].m_FrameBegin;
                    for (int j = 0; j < frameCount; j++)
                    {
                        clip.SampleAnimation(_instantiatedObj, length * j / frameCount);
                        for (int k = 0; k < boneCount; k++)
                        {
                            Matrix4x4 curFrameBoneMatrix = _skinnedMeshRenderer.transform.worldToLocalMatrix * bones[k].localToWorldMatrix * bindPoses[k];
                            atlasTexture.SetPixel(k * 3, startFrame + j, UColor.VectorToColor(curFrameBoneMatrix.GetRow(0)));
                            atlasTexture.SetPixel(k * 3 + 1, startFrame + j, UColor.VectorToColor(curFrameBoneMatrix.GetRow(1)));
                            atlasTexture.SetPixel(k * 3 + 2, startFrame + j, UColor.VectorToColor(curFrameBoneMatrix.GetRow(2)));
                        }

                        Mesh boundsCheckMesh = new Mesh();
                        _skinnedMeshRenderer.BakeMesh(boundsCheckMesh);
                        Vector3[] verticies = boundsCheckMesh.vertices;
                        for (int k = 0; k < verticies.Length; k++)
                        {
                            UBoundsChecker.CheckBounds(verticies[k].Divide(_skinnedMeshRenderer.transform.localScale));
                        }

                        boundsCheckMesh.Clear();
                    }
                }
                atlasTexture.Apply();
                #endregion
                #region Bake Mesh
                Mesh         instanceMesh = _skinnedMeshRenderer.sharedMesh.Copy();
                BoneWeight[] boneWeights  = instanceMesh.boneWeights;
                Vector4[]    uv1          = new Vector4[boneWeights.Length];
                Vector4[]    uv2          = new Vector4[boneWeights.Length];
                for (int i = 0; i < boneWeights.Length; i++)
                {
                    uv1[i] = new Vector4(boneWeights[i].boneIndex0, boneWeights[i].boneIndex1, boneWeights[i].boneIndex2, boneWeights[i].boneIndex3);
                    uv2[i] = new Vector4(boneWeights[i].weight0, boneWeights[i].weight1, boneWeights[i].weight2, boneWeights[i].weight3);
                }
                instanceMesh.SetUVs(1, uv1);
                instanceMesh.SetUVs(2, uv2);
                instanceMesh.boneWeights = null;
                instanceMesh.bindposes   = null;
                instanceMesh.bounds      = UBoundsChecker.CalculateBounds();
                #endregion
                DestroyImmediate(_instantiatedObj);

                GPUAnimationData data = ScriptableObject.CreateInstance <GPUAnimationData>();
                data.m_Animations  = instanceParams;
                data.m_ExposeBones = exposeBoneParam.ToArray();

                data = UEAsset.CreateAssetCombination(savePath + meshName + "_GPU_Bone.asset", data, new KeyValuePair <string, Object>(meshName + "_AnimationAtlas", atlasTexture), new KeyValuePair <string, Object>(meshName + "_InstanceMesh", instanceMesh));
                Object[] assets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(data));
                foreach (var asset in assets)
                {
                    Texture2D atlas = asset as Texture2D;
                    Mesh      mesh  = asset as Mesh;
                    if (atlas)
                    {
                        data.m_AnimationAtlas = atlas;
                    }
                    if (mesh)
                    {
                        data.m_InstancedMesh = mesh;
                    }
                }
                AssetDatabase.SaveAssets();
            }
            catch (System.Exception e)
            {
                Debug.LogError("Generate Failed:" + e.Message);
                DestroyImmediate(_instantiatedObj);
            }
        }