Ejemplo n.º 1
0
        public int GetSubMeshCount()
        {
            Mesh mesh = MeshHelper.GetObjectMesh(this.gameObject);

            if (mesh != null)
            {
                return(MeshHelper.GetMeshSubMeshTriangleRanges(mesh).Length);
            }
            return(0);
        }
Ejemplo n.º 2
0
        internal void Project()
        {
            Initialize();

            if (_meshFilter.sharedMesh != null)
            {
                return;
            }

            this.transform.localScale = Vector3.one * _scale;
            // Randomly rotate the decal before projection
            this.transform.eulerAngles += new Vector3(180, 0, Random.Range(0f, 360f));

            RaycastHit raycastHit;
            bool       hit = Physics.Raycast(this.transform.position, this.transform.forward, out raycastHit, _scale);

            if (!hit)
            {
                Destroy(this.gameObject);
                return;
            }
            else if (raycastHit.collider.gameObject.GetComponent <Rigidbody>() != null)
            {
                Destroy(this.gameObject);
                return;
            }
            else if (raycastHit.collider.gameObject.layer != Globals.STRUCTURE_LAYER)
            {
                Destroy(this.gameObject);
                return;
            }
            UnityEngine.Mesh surfaceMesh = MeshHelper.GetObjectMesh(raycastHit.collider.gameObject);
            if (surfaceMesh == null)
            {
                Destroy(this.gameObject);
                return;
            }
            BooleanMesh(surfaceMesh, raycastHit);
        }
Ejemplo n.º 3
0
 private void Initialize()
 {
     _mesh = MeshHelper.GetObjectMesh(this.gameObject);
     _meshSubMeshTriangleRanges = MeshHelper.GetMeshSubMeshTriangleRanges(_mesh);
 }