Beispiel #1
0
        private void Awake()
        {
            // Ensure an NSTSettings exists in case the developer completely missed this step somehow.
            NSTSettings.EnsureSettingsExistsInScene();

            //fallBackBounds = new Bounds(new Vector3(0, 0, 0), new Vector3(1000, 1000, 1000f));

            // Add the root meshrendered and its bounds, if one exists.
            MeshRenderer rootmeshrend = GetComponent <MeshRenderer>();

            // Try to find the starting bounds to which we will add. Need to avoid letting the defulat values of nyBounds get used.
            if (rootmeshrend != null)
            {
                myBounds = rootmeshrend.bounds;
            }

            // Find all of the MeshRenderers in this map - TODO: Make colliders an option as this will likely be more accurate.
            MeshRenderer[] allrenderers = GetComponentsInChildren <MeshRenderer>();

            // if we don't have a starting bounds from the root, get the first found child as the start.
            if (rootmeshrend == null && allrenderers.Length > 0)
            {
                myBounds = allrenderers[0].bounds;
            }

            for (int i = 0; i < allrenderers.Length; i++)
            {
                myBounds.Encapsulate(allrenderers[i].bounds);
            }

            // Add to this bounds set to combinedBounds.
            if (factorBoundsOn == FactorBoundsOn.AwakeDestroy)
            {
                FactorInBounds(true);
            }
        }
Beispiel #2
0
 public void OnEnable()
 {
     NSTSettings.EnsureSettingsExistsInScene();
 }