Beispiel #1
0
        public static IEnumerator BuildOccluderProxyGeometry(Transform parent, MeshRenderer[] staticRenderers, Action <OccluderData[]> result, Component component, string tag = "Occluder")
        {
            SimpleCulling culling = component as SimpleCulling;

            Transform           container         = NewObject(occluderContainerName, parent).transform;
            List <MeshRenderer> occluderRenderers = staticRenderers.Where(s => s.gameObject.tag == tag).ToList();

            OccluderData[] occluders = new OccluderData[occluderRenderers.Count];
            for (int i = 0; i < occluders.Length; i++)
            {
                MeshFilter meshFilter = occluderRenderers[i].GetComponent <MeshFilter>();
                if (meshFilter == null)
                {
                    continue;
                }

                GameObject   occluderObj       = occluderRenderers[i].gameObject;
                Transform    occluderTransform = occluderObj.transform;
                GameObject   proxyObj          = NewObject(occluderObj.name, container, occluderTransform.position, occluderTransform.rotation, occluderTransform.lossyScale);
                MeshCollider proxyCollider     = proxyObj.AddComponent <MeshCollider>();
                proxyCollider.sharedMesh = meshFilter.sharedMesh;
                occluders[i]             = new OccluderData(proxyCollider, occluderRenderers[i]);

#if UNITY_EDITOR
                if (culling != null)
                {
                    culling.completion = (float)(i + 1) / (float)occluders.Length;
                }
                UnityEditor.SceneView.RepaintAll();
#endif
                yield return(null);
            }
            result(occluders);
        }
Beispiel #2
0
 public OccluderHit(Vector3 point, OccluderData data)
 {
     this.point = point;
     this.data  = data;
 }