Example #1
0
        private void AddSelectedBoneInfluencetoSprite()
        {
            var character = m_Model.characterSkeleton;

            if (character == null)
            {
                return;
            }

            var characterPart  = m_Model.GetSpriteCharacterPart(m_Model.selectedSprite);
            var selectedBones  = m_Model.selectedBones;
            var characterBones = characterPart.bones.ToList();

            foreach (var bone in selectedBones)
            {
                if (!characterBones.Contains(bone))
                {
                    characterBones.Add(bone);
                }
            }

            using (m_Model.UndoScope(TextContent.addBoneInfluence))
            {
                characterPart.bones = characterBones.ToArray();
                m_Events.characterPartChanged.Invoke(characterPart);
                m_Model.view.OnSkeletonChanged();
                m_Model.view.OnBoneSelectionChanged();
            }
        }
        public void GetSelectedSpriteBoneInfluence_GetsCorrectDataFromModel()
        {
            var spriteCache   = CacheObject.Create <SpriteCache>(null);
            var characterpart = CacheObject.Create <CharacterPartCache>(null);
            var bones         = new[]
            {
                CacheObject.Create <BoneCache>(null),
                CacheObject.Create <BoneCache>(null),
            };

            characterpart.bones = bones;
            m_Model.selectedSprite.Returns(spriteCache);
            m_Model.GetSpriteCharacterPart(Arg.Is(spriteCache)).Returns(characterpart);
            var bonesResult = m_Controller.GetSelectedSpriteBoneInfluence();

            Assert.AreEqual(bones.Length, bonesResult.Length);
            for (int i = 0; i < bones.Length; ++i)
            {
                Assert.AreEqual(bones[i], bonesResult[1]);
            }
        }