private void PrepareBones(SpriteSkin spriteSkin) { Debug.Assert(spriteSkin != null); Debug.Assert(m_BoneGizmoView.CanLayout()); if (!spriteSkin.isActiveAndEnabled || !spriteSkin.isValid || !spriteSkin.spriteRenderer.enabled) { return; } var sprite = spriteSkin.spriteRenderer.sprite; var boneTransforms = spriteSkin.boneTransforms; var spriteBones = spriteSkin.spriteBones; var alpha = AlphaFromSpriteSkin(spriteSkin); for (int i = 0; i < boneTransforms.Length; ++i) { var boneTransform = boneTransforms[i]; if (boneTransform == null || m_BoneData.ContainsKey(boneTransform)) { continue; } var bone = spriteBones[i]; if (m_BoneGizmoView.IsActionHot(BoneGizmoAction.None) && m_BoneGizmoView.IsBoneVisible(boneTransform, bone.length, alpha)) { m_CachedBones.Add(boneTransform); } m_BoneData.Add(boneTransform, new Vector2(bone.length, alpha)); } }
public void Setup() { var go = new GameObject("TestObject"); m_SkinnedSprite = AssetDatabase.LoadAssetAtPath <Sprite>("Assets/Temp/bird.png"); m_SpriteSkin = go.AddComponent <SpriteSkin>(); m_SpriteSkin.spriteRenderer.sprite = m_SkinnedSprite; m_SpriteSkin.CreateBoneHierarchy(); m_BoneGizmoView = Substitute.For <IBoneGizmoView>(); m_BoneGizmoView.IsBoneVisible(Arg.Any <Transform>(), Arg.Any <float>(), Arg.Any <float>()).Returns(x => { return(true); }); m_BoneGizmoView.IsActionHot(BoneGizmoAction.None).Returns(x => { return(true); }); m_BoneGizmoView.CanLayout().Returns(x => { return(true); }); m_UndoObject = Substitute.For <IUndoObject>(); m_BoneGizmoToggle = Substitute.For <IBoneGizmoToggle>(); m_BoneGizmoToggle.enableGizmos.Returns(x => { return(true); }); m_BoneGizmoController = new BoneGizmoController(m_BoneGizmoView, m_UndoObject, m_BoneGizmoToggle); }