/// <summary>
        /// Loops through all currently detected planes and randomly chooses objects
        /// to place out of the pool of objects that have met the criteria of fitting
        /// on said plane.
        /// </summary>
        private void PlaceContent()
        {
            CleanContent();

            #if PLATFORM_LUMIN
            foreach (MLPlanes.Plane plane in _planes.PlanesResult)
            {
                ContentObject[] candidates = GetCandidateObjects(plane);

                if (candidates.Length == 0)
                {
                    continue;
                }

                // Now select a random object from the candidate list.
                int           candidateIndex  = Random.Range(0, candidates.Length);
                ContentObject prefabReference = candidates[candidateIndex];

                // Save a reference to the local bounds of our new obj
                Bounds bounds = prefabReference.LocalBounds;

                // Instantiate candidate as a game object
                GameObject newObject = GameObject.Instantiate(prefabReference.gameObject);

                // Add the new object to the placedContent list
                _placedContent.Add(newObject);

                // Center the new object on the plane.
                newObject.transform.position = plane.Center;

                // If the object is on the wall, rotate it
                // to the correct wall orientation.
                if (MLPlanesStarterKit.DoesPlaneHaveFlag(plane, (MLPlanes.QueryFlags)SurfaceType.Wall))
                {
                    newObject.transform.rotation = Quaternion.LookRotation(plane.Rotation * Vector3.back);
                }
                // If the object is on the floor, rotate it to face
                // the main camera. This isn't required but it's a nice touch.
                if (MLPlanesStarterKit.DoesPlaneHaveFlag(plane, (MLPlanes.QueryFlags)SurfaceType.Floor))
                {
                    Vector3 lookPos = _mainCamera.transform.position - plane.Center;
                    lookPos.y = 0;
                    Quaternion rotation = Quaternion.LookRotation(lookPos.normalized);
                    newObject.transform.rotation = rotation;
                }
            }
            #endif
        }
        /// <summary>
        /// Based on the passed in SurfaceType, returns a list of ContentObjects
        /// that meet the same flag requirements.
        /// </summary>
        /// <param name="flag">The SurfaceType to be checked</param>
        private ContentObject[] GetCandidateObjects(MLPlanes.Plane plane)
        {
            var candidates = new List <ContentObject>();
            var flags      = System.Enum.GetValues(typeof(SurfaceType)) as SurfaceType[];

            // Get all of the ContentObject refs that match these flags
            for (int i = 0; i < flags.Length; ++i)
            {
                if (MLPlanesStarterKit.DoesPlaneHaveFlag(plane, (MLPlanes.QueryFlags)flags[i]))
                {
                    candidates.AddRange(_sortedContentObjects[(uint)flags[i]]);
                }
            }

            return(candidates.ToArray());
        }