public void RotateBone_SingleSelection()
        {
            float deltaAngle;

            m_BoneGizmoView.DoBoneRotation(m_SpriteSkin.boneTransforms[0], out deltaAngle).Returns(x =>
            {
                x[1] = 90f;
                return(true);
            });

            Selection.activeGameObject = m_SpriteSkin.boneTransforms[0].gameObject;
            m_BoneGizmoController.OnSelectionChanged();
            m_BoneGizmoController.OnGUI();

            Assert.That(m_SpriteSkin.boneTransforms[0].rotation, Is.EqualTo(new Quaternion(0f, 0f, 0.5560408f, 0.8311549f)).Using(quatCompare));
        }
Example #2
0
        private void DoBoneGUI()
        {
            m_BoneGizmoView.SetupLayout();

            foreach (var boneTransform in m_CachedBones)
            {
                if (boneTransform == null)
                {
                    continue;
                }

                var value  = m_BoneData[boneTransform];
                var length = value.x;

                m_BoneGizmoView.LayoutBone(boneTransform, length);

                BoneGizmoSelectionMode mode;
                if (m_BoneGizmoView.DoSelection(boneTransform, out mode))
                {
                    if (mode == BoneGizmoSelectionMode.Single)
                    {
                        if (!Selection.Contains(boneTransform.gameObject))
                        {
                            Selection.activeTransform = boneTransform;
                        }
                    }
                    else if (mode == BoneGizmoSelectionMode.Toggle)
                    {
                        var objectList = new List <Object>(Selection.objects);

                        if (objectList.Contains(boneTransform.gameObject))
                        {
                            objectList.Remove(boneTransform.gameObject);
                        }
                        else
                        {
                            objectList.Add(boneTransform.gameObject);
                        }

                        Selection.objects = objectList.ToArray();
                    }
                }
            }

            var selectedGameObjects = Selection.gameObjects;

            foreach (var selectedGameobject in selectedGameObjects)
            {
                if (!m_CachedBones.Contains(selectedGameobject.transform))
                {
                    continue;
                }

                var boneTransform = selectedGameobject.transform;

                float deltaAngle;
                if (m_BoneGizmoView.DoBoneRotation(boneTransform, out deltaAngle))
                {
                    SetBoneRotation(deltaAngle);
                }

                Vector3 deltaPosition;
                if (m_BoneGizmoView.DoBonePosition(boneTransform, out deltaPosition))
                {
                    SetBonePosition(deltaPosition);
                }
            }

            DrawBones();
        }