예제 #1
0
        public void FitToScene(SceneSizer sceneSizer)
        {
            Vector3    targetExtents  = new Vector3(0.001f, 0.001f, 0.001f);
            Vector3    targetPosition = sceneSizer.gameObject.transform.position;
            Quaternion targetRotation = sceneSizer.gameObject.transform.rotation;

            if (TargetFillCollider != null)
            {
                targetExtents  = TargetFillCollider.bounds.extents;
                targetPosition = TargetFillCollider.transform.position;
                targetRotation = transform.rotation;
            }

            gameObject.transform.position   = targetPosition;
            gameObject.transform.rotation   = targetRotation;
            gameObject.transform.localScale = gameObject.transform.localScale *
                                              Mathf.Max(TargetFillCollider.bounds.extents.x, TargetFillCollider.bounds.extents.y, TargetFillCollider.bounds.extents.z) /
                                              Mathf.Max(targetExtents.x, targetExtents.y, targetExtents.z);
        }
예제 #2
0
        private void ViewContentLoaded()
        {
            if (ViewLoader.Instance != null)
            {
                GameObject content      = ViewLoader.Instance.GetCurrentContent();
                SceneSizer contentSizer = content.GetComponent <SceneSizer>();
                smallestZoom = Mathf.Max(content.transform.localScale.x, content.transform.localScale.y, content.transform.localScale.z);

                // make sure all content is to the same scale by removing the fill percentage, so this is the scale that fits to view volume
                if (contentSizer != null)
                {
                    smallestZoom /= contentSizer.FullScreenFillPercentage;
                }

                // adjust the smallest zoom from the content's loaded state to our target min zoom size (currently fitted to view volume)
                if (TransitionManager.Instance != null)
                {
                    smallestZoom *= TargetMinZoomSize / Mathf.Max(TransitionManager.Instance.ViewVolume.transform.lossyScale.x, TransitionManager.Instance.ViewVolume.transform.lossyScale.y, TransitionManager.Instance.ViewVolume.transform.lossyScale.z);
                }
            }
        }
예제 #3
0
        public static Bounds GetContentBounds()
        {
            Bounds currentBounds = new Bounds();

            if (ViewLoader.Instance.GetCurrentContent() != null)
            {
                var        content      = ViewLoader.Instance.GetCurrentContent();
                SceneSizer contentSizer = content.GetComponent <SceneSizer>();
                if (contentSizer != null && contentSizer.TargetFillCollider != null)
                {
                    Renderer r = contentSizer.TargetFillCollider.GetComponent <Renderer>();
                    if (r != null)
                    {
                        currentBounds = r.bounds;
                    }
                    else
                    {
                        currentBounds = contentSizer.TargetFillCollider.bounds;
                    }
                }
            }

            return(currentBounds);
        }
예제 #4
0
        private void UpdateShaderProperties()
        {
            GameObject currentContent = ViewLoader.Instance.GetCurrentContent();

            if (currentContent)
            {
                SceneSizer sceneSizer = currentContent.GetComponent <SceneSizer>();
                if (sceneSizer)
                {
                    float    scalar    = sceneSizer.GetScalar();
                    Vector3  contentWP = currentContent.transform.position;
                    Renderer renderer  = GetComponentInChildren <Renderer>();
                    if (renderer)
                    {
                        Material mat = renderer.sharedMaterial;
                        if (mat)
                        {
                            mat.SetFloat("_ContentRadius", scalar);
                            mat.SetVector("_ContentWorldPos", contentWP);
                        }
                    }
                }
            }
        }
예제 #5
0
 private void Awake()
 {
     sizer = GetComponent <SceneSizer>();
 }