public void SplitABone_WeightBoneIndexUpdate_NoWeightForNewBone()
        {
            ChangeBoneIndex(new int[5] {
                1, 2, 3, 4, 5
            }, new int[5] {
                2, 3, 4, 5, 6
            }, m_ExpectedVertices);

            var root    = m_Model.bones.ElementAt(0);
            var child_1 = m_Model.bones.ElementAt(1);

            var newChild = m_Model.CreateNewChildBone(root, Vector2.one);

            m_Model.Parent(child_1, newChild);

            m_CacheManager.SetSpriteBoneRawData(m_SpriteId, m_Model.GetRawData());
            m_CacheManager.Apply();

            m_MeshDPMock.Received(1).SetVertices(m_SpriteId, Arg.Is <Vertex2DMetaData[]>(x => CompareVertices(m_ExpectedVertices, x)));
        }
        // Global mouse click to create bone, then tip, then another bone, then tip, until user cancel.
        private void HandleCreation()
        {
            // Change cursor looks.
            m_View.ShowCreationCursor();

            var position = Vector3.zero;

            // This function return true if user clicked, and fill in the position (rect space).
            if (m_View.HandleFullViewCursor(ref position))
            {
                // Normal creating is a smooth creation series of bones, each is a child of the previous bone.
                // And looks continuous, meaning the tip of parent always point to the child.
                if (state.normalCreating)
                {
                    RecordUndo(null, "bone create children");

                    if (state.normalCreatingRoot)
                    {
                        if (selectingBone)
                        {
                            var selectedBone = state.selectedBones[0];

                            // Normal creation state > creating root state > selected a bone (root) > define the root's tip.
                            m_Model.MoveTip(selectedBone, position);

                            // Exiting the normal creating root state.
                            state.normalCreatingRoot = false;
                        }
                        else
                        {
                            // Normal creation state > creating root state > nothing selected yet > create the root's bone.
                            var newBone = m_Model.CreateNewRoot(position);
                            SelectSingleBone(newBone);
                        }
                    }
                    else if (selectingBone)
                    {
                        var selectedBone = state.selectedBones[0];

                        // Create a new bone at the tip of current selected bone.
                        var newBone = m_Model.CreateNewChildBone(selectedBone, selectedBone.tip);

                        // Define the tip of the newly created bone at the position user clicked.
                        m_Model.MoveTip(newBone, position);

                        // Continue creating bones.
                        SelectSingleBone(newBone);
                    }
                    else
                    {
                        throw new InvalidOperationException("While not creating a root, there should always be a selected bone.");
                    }
                }
                // Free creating is an alternative way to create direct children of selected bone.
                // Each newly created bone is a sibling to each other.
                // The creation is disjointed, meaning the tip of the parent will not follow the newly created child.
                else if (state.freeCreating)
                {
                    if (state.freeCreatingBone)
                    {
                        RecordUndo(null, "bone free create");

                        if (selectingBone)
                        {
                            var selectedBone = state.selectedBones[0];

                            // Free creation state > creating bone state > selected > create the child bone.
                            var newBone = m_Model.CreateNewChildBone(selectedBone, position);
                            SelectSingleBone(newBone);
                        }
                        else
                        {
                            // Free creation state > creating bone state > nothing selected yet > create the root's bone.
                            var newBone = m_Model.CreateNewRoot(position);
                            SelectSingleBone(newBone);
                        }

                        // Exit the creating bone state, next should be defining the tip for this newly created bone.
                        state.freeCreatingBone = false;
                    }
                    else if (selectingBone)
                    {
                        var selectedBone = state.selectedBones[0];

                        // Define the tip of the newly created bone at the position user clicked.
                        m_Model.MoveTip(selectedBone, position);

                        // Reselect the parent (unless the newly created is a root bone).
                        // We are creating direct child remember?
                        if (state.freeCreating && !selectedBone.isRoot)
                        {
                            SelectSingleBone(selectedBone.parent);
                        }

                        // Goes back to creating bone state, tip is done.
                        state.freeCreatingBone = true;
                    }
                    else
                    {
                        throw new InvalidOperationException("While not creating a root, there should always be a selected bone.");
                    }
                }

                // There's a click and potentially new stuff on screen, repaint.
                m_View.Refresh();
            }
        }
        public void CreateANewHierarchy_BoneNameIncrementAutomatically()
        {
            var root    = m_Model.CreateNewRoot(Vector3.zero);
            var bone1   = m_Model.CreateNewChildBone(root, Vector3.one);
            var bone2   = m_Model.CreateNewChildBone(bone1, Vector3.right);
            var bone3   = m_Model.CreateNewChildBone(bone2, Vector3.left);
            var bone1_1 = m_Model.CreateNewChildBone(bone1, Vector3.up);

            Assert.AreEqual("root", root.name);
            Assert.AreEqual("bone_1", bone1.name);
            Assert.AreEqual("bone_2", bone2.name);
            Assert.AreEqual("bone_3", bone3.name);
            Assert.AreEqual("bone_4", bone1_1.name);
        }