public void MoveBone_SingleSelection() { Vector3 deltaPosition; m_BoneGizmoView.DoBonePosition(m_SpriteSkin.boneTransforms[0], out deltaPosition).Returns(x => { x[1] = Vector3.up * 3f; return(true); }); Selection.activeGameObject = m_SpriteSkin.boneTransforms[0].gameObject; m_BoneGizmoController.OnSelectionChanged(); m_BoneGizmoController.OnGUI(); Assert.That(m_SpriteSkin.boneTransforms[0].position, Is.EqualTo(new Vector3(-1.219143f, 3.253849f, 0f)).Using(vec3Compare)); }
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(); }