Ejemplo n.º 1
0
 public void BuildAndSetDirty()
 {
     if (Sprite)
     {
         DecalUtils.FixRatio(this, ref oldScale);
     }
     DecalBuilder.Build(this);
     DecalUtils.SetDirty(this);
 }
Ejemplo n.º 2
0
 public void BuildAndSetDirty()
 {
     //if (Sprite) DecalUtils.FixRatio( this, ref oldScale );
     DecalBuilder.Build(this);
     DecalUtils.SetDirty(this);
     if (TryGetComponent <MeshCollider>(out MeshCollider col))
     {
         col.sharedMesh = GetComponent <MeshFilter>().sharedMesh;
     }
 }
Ejemplo n.º 3
0
        private static void Build_(MeshBuilder builder, Decal decal)
        {
            var objects            = DecalUtils.GetAffectedObjects(decal);
            var terrains           = DecalUtils.GetAffectedTerrains(decal);
            var bounds             = DecalUtils.GetBounds(decal);
            var worldToDecalMatrix = decal.transform.worldToLocalMatrix;

            var triangles1 = MeshUtils.GetTriangles(objects, worldToDecalMatrix).Where(i => Filter(i, decal));
            var triangles2 = TerrainUtils.GetTriangles(terrains, bounds, worldToDecalMatrix).Where(i => Filter(i, decal));

            AddTriangles(builder, triangles1);
            AddTriangles(builder, triangles2);
        }
Ejemplo n.º 4
0
        void OnDrawGizmosSelected()
        {
            Gizmos.matrix = transform.localToWorldMatrix;
            Gizmos.color  = Color.green;
            Gizmos.DrawWireCube(Vector3.zero, Vector3.one);

            var bounds = DecalUtils.GetBounds(this);

            Gizmos.matrix = Matrix4x4.identity;
            Gizmos.color  = Color.white;
            Gizmos.DrawWireCube(bounds.center, bounds.size + Vector3.one * 0.01f);

            //Gizmos.matrix = transform.localToWorldMatrix;
            //Gizmos.color = Color.yellow;
            //var mesh = MeshFilter.sharedMesh;
            //if (mesh) {
            //    var vertices = mesh.vertices;
            //    var normals = mesh.normals;
            //    for (var i = 0; i < vertices.Length; i++) {
            //        Gizmos.DrawRay( vertices[ i ], normals[ i ] * 0.15f );
            //    }
            //}
        }