Exemple #1
0
        /// <summary>   Initialises the oclussion manager. </summary>
        private void InitOclussionManager()
        {
            // create a list to hold the game objects
            meshObjects = new List <GameObject>();

            // create a list to hold the meshes
            List <Mesh> meshes = new List <Mesh>();

            MeshSplitter.CreateMeshes(width, height, (int)quadWidth, (int)quadHeight, (int)quadXGap, (int)quadYGap, ref meshes);

            for (int i = 0; i < meshes.Count; ++i)
            {
                GameObject newObject = new GameObject("OcclusionMesh" + i);
                newObject.AddComponent <MeshFilter>();
                newObject.AddComponent <MeshRenderer>();
                newObject.GetComponent <MeshFilter>().mesh = meshes[i];

                newObject.GetComponent <MeshFilter>().mesh.bounds = new Bounds(Vector3.zero, Vector3.one);

                newObject.transform.SetParent(_depthOcclusionGO.transform, false);
                newObject.transform.localPosition = Vector3.zero;
                newObject.transform.localScale    = Vector3.one;

                meshObjects.Add(newObject);
            }

            ApplyTexture(currentNativeTexture);
        }
        /// <summary>
        ///     Create game objects and attach meshes to them.
        /// </summary>
        /// <param name="numMeshes">The number of meshes there are.</param>
        /// <param name="meshes">The list containing the meshes.</param>
        private void CreateGameObjects()
        {
            // create a list to hold the meshes
            List <Mesh> meshes = new List <Mesh>();

            MeshSplitter.CreateMeshes(width, height, (int)quadWidth, (int)quadHeight, (int)quadXGap, (int)quadYGap, ref meshes);

            for (int i = 0; i < meshes.Count; ++i)
            {
                GameObject newObject = new GameObject("OcclusionMesh" + i);
                newObject.AddComponent <MeshFilter>();
                newObject.AddComponent <MeshRenderer>();
                newObject.GetComponent <MeshFilter>().mesh = meshes[i];

                newObject.transform.SetParent(gameObject.transform, true);
                newObject.transform.localPosition = Vector3.zero;
                newObject.transform.localScale    = Vector3.one;

                meshObjects.Add(newObject);
            }
        }