예제 #1
0
        public void BeginPreview(Rect r, GUIStyle previewBackground)
        {
            if (m_previewOpened)
            {
                Debug.LogError("Previous PreviewRenderUtility.BeginPreview() was not closed with PreviewRenderUtility.EndPreview()");
                return;
            }

            m_previewOpened = true;

            Texture defaultEnvTexture = ReflectionProbe.defaultTexture;

            if (Unsupported.SetOverrideLightingSettings(previewScene.scene))
            {
                RenderSettings.ambientMode  = AmbientMode.Flat;
                RenderSettings.ambientLight = ambientColor;

                RenderSettings.defaultReflectionMode   = UnityEngine.Rendering.DefaultReflectionMode.Custom;
                RenderSettings.customReflectionTexture = defaultEnvTexture;
            }

            InitPreview(r);

            if (previewBackground == null || previewBackground == GUIStyle.none || previewBackground.normal.background == null)
            {
                return;
            }

            Graphics.DrawTexture(
                previewBackground.overflow.Add(new Rect(0, 0, m_RenderTexture.width, m_RenderTexture.height)),
                previewBackground.normal.background, new Rect(0, 0, 1, 1), previewBackground.border.left,
                previewBackground.border.right, previewBackground.border.top, previewBackground.border.bottom,
                new Color(.5f, .5f, .5f, 0.5f), null
                );
        }
        public void BeginPreview(Rect r, GUIStyle previewBackground)
        {
            Texture defaultEnvTexture = ReflectionProbe.defaultTexture;

            if (Unsupported.SetOverrideLightingSettings(previewScene.scene))
            {
                RenderSettings.ambientMode  = AmbientMode.Flat;
                RenderSettings.ambientLight = ambientColor;

                RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;
                RenderSettings.customReflection      = defaultEnvTexture as Cubemap;
            }

            InitPreview(r);

            if (previewBackground == null || previewBackground == GUIStyle.none)
            {
                return;
            }

            Graphics.DrawTexture(
                previewBackground.overflow.Add(new Rect(0, 0, m_RenderTexture.width, m_RenderTexture.height)),
                previewBackground.normal.background,
                new Rect(0, 0, 1, 1),
                previewBackground.border.left, previewBackground.border.right, previewBackground.border.top,
                previewBackground.border.bottom,
                new Color(.5f, .5f, .5f, 0.5f),
                null
                );
        }
        public void BeginPreview(Rect r, GUIStyle previewBackground)
        {
            Texture defaultEnvTexture = ReflectionProbe.defaultTexture;

            if (Unsupported.SetOverrideLightingSettings(previewScene.scene))
            {
                RenderSettings.ambientMode  = AmbientMode.Flat;
                RenderSettings.ambientLight = ambientColor;

                RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;
                RenderSettings.customReflection      = defaultEnvTexture as Cubemap;
            }

            InitPreview(r);
        }
예제 #4
0
        public void BeginStaticPreview(Rect r)
        {
            InitPreview(r);
            var color = new Color(82 / 255f, 82 / 255f, 82 / 255f, 1.0f);
            var darkGreyBackground = new Texture2D(1, 1, TextureFormat.RGBA32, true);

            darkGreyBackground.SetPixel(0, 0, color);
            darkGreyBackground.Apply();
            Graphics.DrawTexture(new Rect(0, 0, m_RenderTexture.width, m_RenderTexture.height), darkGreyBackground);
            Object.DestroyImmediate(darkGreyBackground);

            if (!EditorApplication.isUpdating && Unsupported.SetOverrideLightingSettings(previewScene.scene))
            {
                // User can set an ambientColor if they want to override the default black color
                // Cannot grab the main scene light probe/color instead as this is sometimes run on a worker without access to the original probe/color.
                RenderSettings.ambientMode  = AmbientMode.Flat;
                RenderSettings.ambientLight = ambientColor;
                // Reflection mode should be set to the default (skybox) to stay consistent with the worker thread settings when the preview is created while saving
                RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Skybox;
            }
        }
        public void BeginStaticPreview(Rect r)
        {
            InitPreview(r);
            var color = new Color(82 / 255f, 82 / 255f, 82 / 255f, 1.0f);
            var darkGreyBackground = new Texture2D(1, 1, TextureFormat.RGBA32, true);

            darkGreyBackground.SetPixel(0, 0, color);
            darkGreyBackground.Apply();
            Graphics.DrawTexture(new Rect(0, 0, m_RenderTexture.width, m_RenderTexture.height), darkGreyBackground);
            Object.DestroyImmediate(darkGreyBackground);

            if (!EditorApplication.isUpdating)
            {
                var     oldProbe          = RenderSettings.ambientProbe;
                Texture defaultEnvTexture = ReflectionProbe.defaultTexture;
                if (Unsupported.SetOverrideLightingSettings(previewScene.scene))
                {
                    // Most preview windows just want the light probe from the main scene so by default we copy it here. It can then be overridden if user wants.
                    RenderSettings.ambientProbe          = oldProbe;
                    RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;
                    RenderSettings.customReflection      = defaultEnvTexture as Cubemap;
                }
            }
        }