예제 #1
0
        public static void UpdateMesh(this SpriteCache sprite, BoneCache[] bones)
        {
            var mesh        = sprite.GetMesh();
            var previewMesh = sprite.GetMeshPreview();

            Debug.Assert(mesh != null);
            Debug.Assert(previewMesh != null);

            mesh.bones = bones;

            previewMesh.SetWeightsDirty();
        }
예제 #2
0
        private Mesh GetMesh(SpriteCache sprite)
        {
            var meshPreview = sprite.GetMeshPreview();
            var skeleton    = sprite.skinningCache.GetEffectiveSkeleton(sprite);

            Debug.Assert(meshPreview != null);
            Debug.Assert(skeleton != null);

            if (meshPreview.canSkin && skeleton.isPosePreview)
            {
                return(meshPreview.mesh);
            }

            return(meshPreview.defaultMesh);
        }
예제 #3
0
        private void DrawWireframe(SpriteCache sprite)
        {
            Debug.Assert(Event.current.type == EventType.Repaint);
            Debug.Assert(sprite != null);

            var meshPreview = sprite.GetMeshPreview();

            Debug.Assert(meshPreview != null);

            m_Material.mainTexture = null;
            m_Material.SetFloat("_Opacity", 0.35f);
            m_Material.SetFloat("_VertexColorBlend", 0f);
            m_Material.color = Color.white;

            GL.wireframe = true;
            DrawingUtility.DrawMesh(meshPreview.mesh, m_Material, sprite.GetLocalToWorldMatrixFromMode());
            GL.wireframe = false;
        }
예제 #4
0
        private void DrawDefaultSpriteMesh(SpriteCache sprite)
        {
            Debug.Assert(m_Material != null);

            var meshPreview = sprite.GetMeshPreview();
            var meshCache   = sprite.GetMesh();
            var skeleton    = skinningCache.GetEffectiveSkeleton(sprite);

            Debug.Assert(meshPreview != null);

            if (meshPreview.canSkin == false || skeleton.isPosePreview == false)
            {
                m_Material.mainTexture = meshCache.textureDataProvider.texture;
                m_Material.SetFloat("_Opacity", 1f);
                m_Material.SetFloat("_VertexColorBlend", 0f);
                m_Material.color = new Color(1f, 1f, 1f, 1f);

                DrawingUtility.DrawMesh(meshPreview.defaultMesh, m_Material, sprite.GetLocalToWorldMatrixFromMode());
            }
        }
예제 #5
0
        private void DrawSpriteMesh(SpriteCache sprite, float weightMapOpacity)
        {
            Debug.Assert(m_Material != null);

            var meshPreview = sprite.GetMeshPreview();
            var meshCache   = sprite.GetMesh();

            Debug.Assert(meshPreview != null);

            if (meshPreview.mesh == null || meshPreview.mesh.vertexCount == 0)
            {
                DrawDefaultSpriteMesh(sprite);
            }
            else
            {
                m_Material.mainTexture = meshCache.textureDataProvider.texture;
                m_Material.SetFloat("_Opacity", 1f);
                m_Material.SetFloat("_VertexColorBlend", weightMapOpacity);

                m_Material.color = Color.white;

                DrawingUtility.DrawMesh(meshPreview.mesh, m_Material, sprite.GetLocalToWorldMatrixFromMode());
            }
        }