public void SelectBone_SingleSelection() { BoneGizmoSelectionMode selectionMode; m_BoneGizmoView.DoSelection(m_SpriteSkin.boneTransforms[0], out selectionMode).Returns(x => { x[1] = BoneGizmoSelectionMode.Single; return(true); }); m_BoneGizmoView.DoSelection(m_SpriteSkin.boneTransforms[1], out selectionMode).Returns(x => { x[1] = BoneGizmoSelectionMode.Single; return(false); }); m_BoneGizmoController.OnSelectionChanged(); m_BoneGizmoController.OnGUI(); Assert.IsTrue(Selection.Contains(m_SpriteSkin.boneTransforms[0].gameObject)); Assert.IsFalse(Selection.Contains(m_SpriteSkin.boneTransforms[1].gameObject)); m_BoneGizmoView.DoSelection(m_SpriteSkin.boneTransforms[0], out selectionMode).Returns(x => { x[1] = BoneGizmoSelectionMode.Single; return(false); }); m_BoneGizmoView.DoSelection(m_SpriteSkin.boneTransforms[1], out selectionMode).Returns(x => { x[1] = BoneGizmoSelectionMode.Single; return(true); }); m_BoneGizmoController.OnSelectionChanged(); m_BoneGizmoController.OnGUI(); Assert.IsFalse(Selection.Contains(m_SpriteSkin.boneTransforms[0].gameObject)); Assert.IsTrue(Selection.Contains(m_SpriteSkin.boneTransforms[1].gameObject)); }
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(); }