internal static void BuildDecal(Decal decal)
        {
            MeshFilter filter = decal.GetComponent<MeshFilter>();
            if (filter == null) filter = decal.gameObject.AddComponent<MeshFilter>();
            if (decal.GetComponent<Renderer>() == null) decal.gameObject.AddComponent<MeshRenderer>();
            decal.GetComponent<Renderer>().material = decal.material;

            if (decal.material == null || decal.sprite == null)
            {
                filter.mesh = null;
                return;
            }

            affectedObjects = GetAffectedObjects(decal.GetBounds(), decal.affectedLayers);
            foreach (GameObject go in affectedObjects)
            {
                DecalBuilder.BuildDecalForObject(decal, go);
            }
            DecalBuilder.Push(decal.pushDistance);

            Mesh mesh = DecalBuilder.CreateMesh();
            if (mesh != null)
            {
                filter.mesh = mesh;
            }
        }
Beispiel #2
0
 public void BuildAndSetDirty()
 {
     if (Sprite)
     {
         DecalUtils.FixRatio(this, ref oldScale);
     }
     DecalBuilder.Build(this);
     DecalUtils.SetDirty(this);
 }
Beispiel #3
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;
     }
 }
Beispiel #4
0
        public void createMesh()
        {
            for (int i = 0; i < this.info.BufNormals.Count; i++)
            {
                DecalBuilder.bufVertices.Add(this.info.BufVertices[i]);
                DecalBuilder.bufNormals.Add(this.info.BufNormals[i]);
            }

            for (int i = 0; i < this.info.BufIndices.Count; i++)
            {
                DecalBuilder.bufIndices.Add(this.info.BufIndices[i]);
            }

            DecalBuilder.GenerateTexCoords(0, this.sprite);

            MeshFilter filter = gameObject.GetComponent<MeshFilter>();
            gameObject.GetComponent<Renderer>().material = this.material;

            filter.mesh = DecalBuilder.CreateMesh();

            transform.position = this.info.Position;
            transform.rotation = this.info.Rotation;
        }