public void SelectBones_InvokeEventOnBoneSelection() { var bone1 = Substitute.For <BoneCache>(); var bone2 = Substitute.For <BoneCache>(); bone1.name = "test_name"; var treeViewList = new List <TreeViewItem>() { new TreeViewItemBase <BoneCache>(bone1.GetInstanceID(), 0, "test", bone1), new TreeViewItemBase <BoneCache>(bone2.GetInstanceID(), 0, "test", bone2) }; treeViewList[0].AddChild(treeViewList[1]); bool eventCalled = false; UnityAction callback = () => { eventCalled = true; }; m_EventSystem.boneSelectionChanged.AddListener(callback); BoneCache[] bones = null; m_Model.SelectBones(Arg.Do <BoneCache[]>(x => bones = x)); m_Controller.SelectBones(new[] { bone1.GetInstanceID() }, treeViewList); m_EventSystem.boneSelectionChanged.RemoveListener(callback); Assert.IsTrue(eventCalled); Assert.AreEqual(1, bones.Length); }
public void SelectBones(IList <int> selectedIds, IList <TreeViewItem> items) { var selectedBones = items.Where(x => selectedIds.Contains(x.id)).Select(y => ((TreeViewItemBase <BoneCache>)y).customData).ToArray(); using (m_Model.UndoScope(TextContent.boneSelection)) { m_Model.SelectBones(selectedBones); m_SkinningEvents.boneSelectionChanged.Invoke(); } }