public override void OnPreviewGUI(Rect position, GUIStyle style) { // Fix for case 939947 where we didn't get the Layout event if the texture was null when changing color if (!ValidPreviewSetup() && Event.current.type != EventType.ExecuteCommand) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Color prevColor = GUI.color; GUI.color = new Color(1, 1, 1, 0.5f); GUILayout.Label("Reflection Probe not baked/ready yet"); GUI.color = prevColor; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return; } ReflectionProbe p = target as ReflectionProbe; if (p != null && p.texture != null && targets.Length == 1) { Editor editor = m_CubemapEditor; CreateTextureInspector(p.texture, ref editor); m_CubemapEditor = editor as TextureInspector; } if (m_CubemapEditor != null) { m_CubemapEditor.SetCubemapIntensity(GetProbeIntensity((ReflectionProbe)target)); m_CubemapEditor.OnPreviewGUI(position, style); } }
public override void OnPreviewGUI(Rect position, GUIStyle style) { if (!this.ValidPreviewSetup()) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.5f); GUILayout.Label("Reflection Probe not baked yet", new GUILayoutOption[0]); GUI.color = color; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { ReflectionProbe reflectionProbe = base.target as ReflectionProbe; if (reflectionProbe != null && reflectionProbe.texture != null && base.targets.Length == 1) { Editor cubemapEditor = this.m_CubemapEditor; Editor.CreateCachedEditor(reflectionProbe.texture, null, ref cubemapEditor); this.m_CubemapEditor = (cubemapEditor as TextureInspector); } if (this.m_CubemapEditor != null) { this.m_CubemapEditor.SetCubemapIntensity(this.GetProbeIntensity((ReflectionProbe)base.target)); this.m_CubemapEditor.OnPreviewGUI(position, style); } } }
public override void OnPreviewGUI(Rect position, GUIStyle style) { if (!this.ValidPreviewSetup()) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.5f); GUILayout.Label("Reflection Probe not baked yet"); GUI.color = color; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { ReflectionProbe target = this.target as ReflectionProbe; if ((UnityEngine.Object)target != (UnityEngine.Object)null && (UnityEngine.Object)target.texture != (UnityEngine.Object)null && this.targets.Length == 1) { Editor cubemapEditor = (Editor)this.m_CubemapEditor; Editor.CreateCachedEditor((UnityEngine.Object)target.texture, (System.Type)null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } if (!((UnityEngine.Object) this.m_CubemapEditor != (UnityEngine.Object)null)) { return; } this.m_CubemapEditor.SetCubemapIntensity(this.GetProbeIntensity((ReflectionProbe)this.target)); this.m_CubemapEditor.OnPreviewGUI(position, style); } }
private void RenderCubemap(Texture t, Vector2 previewDir, float previewDistance, float exposure) { m_PreviewUtility.camera.transform.position = -Vector3.forward * previewDistance; m_PreviewUtility.camera.transform.rotation = Quaternion.identity; Quaternion rot = Quaternion.Euler(previewDir.y, 0, 0) * Quaternion.Euler(0, previewDir.x, 0); m_Material.mainTexture = t; m_Material.SetMatrix(s_ShaderCubemapRotation, Matrix4x4.TRS(Vector3.zero, rot, Vector3.one)); // -1 indicates "use regular sampling"; mips 0 and larger sample only that mip level for preview float mipLevel = GetMipLevelForRendering(t); m_Material.SetFloat(s_ShaderMip, mipLevel); m_Material.SetFloat(s_ShaderAlpha, (m_PreviewType == PreviewType.Alpha) ? 1.0f : 0.0f); m_Material.SetFloat(s_ShaderIntensity, m_Intensity); m_Material.SetFloat(s_ShaderIsNormalMap, TextureInspector.IsNormalMap(t) ? 1.0f : 0.0f); m_Material.SetFloat(s_ShaderExposure, exposure); if (PlayerSettings.colorSpace == ColorSpace.Linear) { m_Material.SetInt("_ColorspaceIsGamma", 0); } else { m_Material.SetInt("_ColorspaceIsGamma", 1); } m_PreviewUtility.DrawMesh(m_Mesh, Vector3.zero, rot, m_Material, 0); m_PreviewUtility.Render(); }
internal static void WrapModePopup(SerializedProperty wrapU, SerializedProperty wrapV, SerializedProperty wrapW, bool isVolumeTexture, ref bool showPerAxisWrapModes) { if (TextureInspector.s_Styles == null) { TextureInspector.s_Styles = new TextureInspector.Styles(); } TextureWrapMode textureWrapMode = (TextureWrapMode)Mathf.Max(wrapU.intValue, 0); TextureWrapMode textureWrapMode2 = (TextureWrapMode)Mathf.Max(wrapV.intValue, 0); TextureWrapMode textureWrapMode3 = (TextureWrapMode)Mathf.Max(wrapW.intValue, 0); if (textureWrapMode != textureWrapMode2) { showPerAxisWrapModes = true; } if (isVolumeTexture) { if (textureWrapMode != textureWrapMode3 || textureWrapMode2 != textureWrapMode3) { showPerAxisWrapModes = true; } } if (!showPerAxisWrapModes) { if (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues)) { if (TextureInspector.IsAnyTextureObjectUsingPerAxisWrapMode(wrapU.serializedObject.targetObjects, isVolumeTexture)) { showPerAxisWrapModes = true; } } } int num = (int)((!showPerAxisWrapModes) ? textureWrapMode : ((TextureWrapMode)(-1))); EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = (!showPerAxisWrapModes && (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues))); num = EditorGUILayout.IntPopup(TextureInspector.s_Styles.wrapModeLabel, num, TextureInspector.s_Styles.wrapModeContents, TextureInspector.s_Styles.wrapModeValues, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck() && num != -1) { wrapU.intValue = num; wrapV.intValue = num; wrapW.intValue = num; showPerAxisWrapModes = false; } if (num == -1) { showPerAxisWrapModes = true; EditorGUI.indentLevel++; TextureInspector.WrapModeAxisPopup(TextureInspector.s_Styles.wrapU, wrapU); TextureInspector.WrapModeAxisPopup(TextureInspector.s_Styles.wrapV, wrapV); if (isVolumeTexture) { TextureInspector.WrapModeAxisPopup(TextureInspector.s_Styles.wrapW, wrapW); } EditorGUI.indentLevel--; } EditorGUI.showMixedValue = false; }
// Draw Reflection probe preview sphere private void OnPreSceneGUICallback(SceneView sceneView) { if (Event.current.type != EventType.Repaint) { return; } foreach (var t in targets) { ReflectionProbe p = (ReflectionProbe)t; if (!reflectiveMaterial) { return; } if (!StageUtility.IsGameObjectRenderedByCameraAndPartOfEditableScene(p.gameObject, Camera.current)) { return; } Matrix4x4 m = new Matrix4x4(); // @TODO: use MaterialPropertyBlock instead - once it actually works! // Tried to use MaterialPropertyBlock in 5.4.0b2, but would get incorrectly set parameters when using with Graphics.DrawMesh if (!m_CachedGizmoMaterials.ContainsKey(p)) { m_CachedGizmoMaterials.Add(p, Instantiate(reflectiveMaterial)); } Material mat = m_CachedGizmoMaterials[p] as Material; if (!mat) { return; } { // Get mip level float mipLevel = 0.0F; TextureInspector cubemapEditor = m_CubemapEditor as TextureInspector; if (cubemapEditor) { mipLevel = cubemapEditor.GetMipLevelForRendering(); } mat.SetTexture("_MainTex", p.texture); mat.SetMatrix("_CubemapRotation", Matrix4x4.identity); mat.SetFloat("_Mip", mipLevel); mat.SetFloat("_Alpha", 0.0f); mat.SetFloat("_Intensity", GetProbeIntensity(p)); // draw a preview sphere that scales with overall GO scale, but always uniformly var scale = p.transform.lossyScale.magnitude * 0.5f; m.SetTRS(p.transform.position, Quaternion.identity, new Vector3(scale, scale, scale)); Graphics.DrawMesh(sphereMesh, m, mat, 0, SceneView.currentDrawingSceneView.camera, 0); } } }
protected void DoAnisoLevelSlider() { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = this.m_Aniso.hasMultipleDifferentValues; int anisoLevel = EditorGUILayout.IntSlider("Aniso Level", this.m_Aniso.intValue, 0, 16, new GUILayoutOption[0]); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { this.m_Aniso.intValue = anisoLevel; } TextureInspector.DoAnisoGlobalSettingNote(anisoLevel); }
public override bool HasPreviewGUI() { if (base.targets.Length > 1) { return(false); } if (this.ValidPreviewSetup()) { Editor cubemapEditor = this.m_CubemapEditor; Editor.CreateCachedEditor(((ReflectionProbe)this.target).texture, null, ref cubemapEditor); this.m_CubemapEditor = (cubemapEditor as TextureInspector); } return(true); }
public override bool HasPreviewGUI() { if (this.targets.Length > 1) { return(false); } if (this.ValidPreviewSetup()) { Editor cubemapEditor = (Editor)this.m_CubemapEditor; Editor.CreateCachedEditor((UnityEngine.Object)((ReflectionProbe)this.target).texture, (System.Type)null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } return(true); }
public void OnPreviewGUI(Texture t, Rect r, GUIStyle background, float exposure, TextureInspector.PreviewMode previewMode, float mipLevel) { if (t == null) { return; } if (!SystemInfo.supports2DArrayTextures) { EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "2D texture array preview not supported"); return; } InitPreviewMaterialIfNeeded(); m_Material.mainTexture = t; int effectiveSlice = GetEffectiveSlice(t); m_Material.SetFloat(s_ShaderSliceIndex, (float)effectiveSlice); m_Material.SetFloat(s_ShaderToSrgb, QualitySettings.activeColorSpace == ColorSpace.Linear ? 1.0f : 0.0f); m_Material.SetFloat(s_ShaderIsNormalMap, TextureInspector.IsNormalMap(t) ? 1.0f : 0.0f); SetShaderColorMask(previewMode); int texWidth = Mathf.Max(t.width, 1); int texHeight = Mathf.Max(t.height, 1); float effectiveMipLevel = GetMipLevelForRendering(t, mipLevel); float zoomLevel = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1); Rect wantedRect = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel); PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); FilterMode oldFilter = t.filterMode; TextureUtil.SetFilterModeNoDirty(t, FilterMode.Point); EditorGUI.DrawPreviewTexture(wantedRect, t, m_Material, ScaleMode.StretchToFill, 0, effectiveMipLevel, UnityEngine.Rendering.ColorWriteMask.All, exposure); TextureUtil.SetFilterModeNoDirty(t, oldFilter); m_Pos = PreviewGUI.EndScrollView(); if (effectiveSlice != 0 || (int)effectiveMipLevel != 0) { EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10, r.width, 30), "Slice " + effectiveSlice + "\nMip " + effectiveMipLevel); } }
public Texture2D RenderStaticPreview(Texture target, string assetPath, Object[] subAssets, int width, int height) { if (!ShaderUtil.hardwareSupportsRectRenderTexture || !SystemInfo.supports2DArrayTextures) { return(null); } var texture = target as Texture2DArray; if (texture == null) { return(null); } var previewUtility = new PreviewRenderUtility(); previewUtility.BeginStaticPreview(new Rect(0, 0, width, height)); InitPreviewMaterialIfNeeded(); m_Material.mainTexture = texture; m_Material.SetFloat(s_ShaderColorMask, 15.0f); m_Material.SetFloat(s_ShaderMip, 0); m_Material.SetFloat(s_ShaderToSrgb, 0.0f); m_Material.SetFloat(s_ShaderIsNormalMap, TextureInspector.IsNormalMap(texture) ? 1.0f : 0.0f); int sliceDistance = previewUtility.renderTexture.width / 12; var elementCount = Mathf.Min(texture.depth, 6); Rect screenRect = new Rect(), sourceRect = new Rect(); var subRect = new Rect(0, 0, previewUtility.renderTexture.width - sliceDistance * (elementCount - 1), previewUtility.renderTexture.height - sliceDistance * (elementCount - 1)); for (var el = elementCount - 1; el >= 0; --el) { m_Material.SetFloat(s_ShaderSliceIndex, (float)el); subRect.x = sliceDistance * el; subRect.y = previewUtility.renderTexture.height - subRect.height - sliceDistance * el; var aspect = texture.width / (float)texture.height; GUI.CalculateScaledTextureRects(subRect, ScaleMode.ScaleToFit, aspect, ref screenRect, ref sourceRect); Graphics.DrawTexture(screenRect, texture, sourceRect, 0, 0, 0, 0, Color.white, m_Material); } var res = previewUtility.EndStaticPreview(); previewUtility.Cleanup(); return(res); }
public override bool HasPreviewGUI() { if (targets.Length > 1) { return(false); // We only handle one preview for reflection probes } // Ensure valid cube map editor (if possible) if (ValidPreviewSetup()) { Editor editor = m_CubemapEditor; CreateTextureInspector(((ReflectionProbe)target).texture, ref editor); m_CubemapEditor = editor as TextureInspector; } // If having one probe selected we always want preview (to prevent preview window from popping) return(true); }
public void OnPreSceneGUI() { if (Event.current.type != EventType.Repaint) { return; } ReflectionProbe reflectionProbe = (ReflectionProbe)this.target; if (!this.reflectiveMaterial) { return; } Matrix4x4 matrix = default(Matrix4x4); Material reflectiveMaterial = this.reflectiveMaterial; if (reflectionProbe.type == ReflectionProbeType.Cube) { float value = 0f; TextureInspector cubemapEditor = this.m_CubemapEditor; if (cubemapEditor) { value = cubemapEditor.GetMipLevelForRendering(); } reflectiveMaterial.mainTexture = reflectionProbe.texture; reflectiveMaterial.SetMatrix("_CubemapRotation", Matrix4x4.identity); reflectiveMaterial.SetFloat("_Mip", value); reflectiveMaterial.SetFloat("_Alpha", 0f); reflectiveMaterial.SetFloat("_Intensity", this.GetProbeIntensity(reflectionProbe)); float num = reflectionProbe.transform.lossyScale.magnitude * 0.5f; matrix.SetTRS(reflectionProbe.transform.position, Quaternion.identity, new Vector3(num, num, num)); Graphics.DrawMesh(ReflectionProbeEditor.sphereMesh, matrix, this.reflectiveMaterial, 0, SceneView.currentDrawingSceneView.camera); } else { reflectiveMaterial.SetTexture("_MainTex", reflectionProbe.texture); reflectiveMaterial.SetFloat("_ReflectionProbeType", 1f); reflectiveMaterial.SetFloat("_Intensity", 1f); Vector3 s = default(Vector3); s = reflectionProbe.transform.lossyScale * 0.2f; s.x *= -1f; s.z *= -1f; matrix.SetTRS(reflectionProbe.transform.position, reflectionProbe.transform.rotation * Quaternion.AngleAxis(90f, Vector3.right), s); Graphics.DrawMesh(ReflectionProbeEditor.planeMesh, matrix, this.reflectiveMaterial, 0, SceneView.currentDrawingSceneView.camera); } }
public void OnPreSceneGUI() { if (Event.current.type != EventType.Repaint) { return; } ReflectionProbe target = (ReflectionProbe)this.target; if (!(bool)((UnityEngine.Object) this.reflectiveMaterial)) { return; } Matrix4x4 matrix = new Matrix4x4(); Material reflectiveMaterial = this.reflectiveMaterial; if (target.type == ReflectionProbeType.Cube) { float num1 = 0.0f; TextureInspector cubemapEditor = this.m_CubemapEditor; if ((bool)((UnityEngine.Object)cubemapEditor)) { num1 = cubemapEditor.GetMipLevelForRendering(); } reflectiveMaterial.mainTexture = target.texture; reflectiveMaterial.SetMatrix("_CubemapRotation", Matrix4x4.identity); reflectiveMaterial.SetFloat("_Mip", num1); reflectiveMaterial.SetFloat("_Alpha", 0.0f); reflectiveMaterial.SetFloat("_Intensity", this.GetProbeIntensity(target)); float num2 = target.transform.lossyScale.magnitude * 0.5f; matrix.SetTRS(target.transform.position, Quaternion.identity, new Vector3(num2, num2, num2)); Graphics.DrawMesh(ReflectionProbeEditor.sphereMesh, matrix, this.reflectiveMaterial, 0, SceneView.currentDrawingSceneView.camera); } else { reflectiveMaterial.SetTexture("_MainTex", target.texture); reflectiveMaterial.SetFloat("_ReflectionProbeType", 1f); reflectiveMaterial.SetFloat("_Intensity", 1f); Vector3 vector3 = new Vector3(); Vector3 s = target.transform.lossyScale * 0.2f; s.x *= -1f; s.z *= -1f; matrix.SetTRS(target.transform.position, target.transform.rotation * Quaternion.AngleAxis(90f, Vector3.right), s); Graphics.DrawMesh(ReflectionProbeEditor.planeMesh, matrix, this.reflectiveMaterial, 0, SceneView.currentDrawingSceneView.camera); } }
public void TextureSettingsGUI() { bool isVolumeTexture = false; TextureInspector.WrapModePopup(this.m_WrapU, this.m_WrapV, this.m_WrapW, isVolumeTexture, ref this.m_ShowPerAxisWrapModes); Rect controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[0]); EditorGUI.BeginProperty(controlRect, IHVImageFormatImporterInspector.Styles.filterMode, this.m_FilterMode); EditorGUI.BeginChangeCheck(); FilterMode filterMode = (FilterMode)((this.m_FilterMode.intValue != -1) ? this.m_FilterMode.intValue : 1); filterMode = (FilterMode)EditorGUI.IntPopup(controlRect, IHVImageFormatImporterInspector.Styles.filterMode, (int)filterMode, IHVImageFormatImporterInspector.Styles.filterModeOptions, IHVImageFormatImporterInspector.Styles.filterModeValues); if (EditorGUI.EndChangeCheck()) { this.m_FilterMode.intValue = (int)filterMode; } EditorGUI.EndProperty(); }
public void OnPreviewSettings(Texture target) { Texture2DArray texture2DArray = target as Texture2DArray; RenderTexture renderTexture = target as RenderTexture; if (texture2DArray == null && renderTexture == null) { return; } if (texture2DArray != null) { m_Slice = (int)TextureInspector.PreviewSettingsSlider(Styles.arrayIcon, m_Slice, 0, texture2DArray.depth - 1, 60, 30, isInteger: true); } else { m_Slice = (int)TextureInspector.PreviewSettingsSlider(Styles.arrayIcon, m_Slice, 0, renderTexture.volumeDepth - 1, 60, 30, isInteger: true); } }
public void TextureSettingsGUI() { // NOTE: once we get ability to have 3D/Volume texture shapes, should pass true for isVolume based on m_TextureShape // Also, always consider we may have a volume if we don't know the target. bool isVolume = assetTarget == null; TextureInspector.WrapModePopup(m_WrapU, m_WrapV, m_WrapW, isVolume, ref m_ShowPerAxisWrapModes, assetTarget == null); Rect rect = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(rect, Styles.filterMode, m_FilterMode); EditorGUI.BeginChangeCheck(); FilterMode filter = (FilterMode)EditorGUI.IntPopup(rect, Styles.filterMode, m_FilterMode.intValue, Styles.filterModeOptions, Styles.filterModeValues); if (EditorGUI.EndChangeCheck()) { m_FilterMode.intValue = (int)filter; } EditorGUI.EndProperty(); }
public void TextureSettingsGUI() { // NOTE: once we get ability to have 3D/Volume texture shapes, should pass true for isVolume based on m_TextureShape bool isVolume = false; TextureInspector.WrapModePopup(m_WrapU, m_WrapV, m_WrapW, isVolume, ref m_ShowPerAxisWrapModes); Rect rect = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(rect, Styles.filterMode, m_FilterMode); EditorGUI.BeginChangeCheck(); FilterMode filter = m_FilterMode.intValue == -1 ? FilterMode.Bilinear : (FilterMode)m_FilterMode.intValue; filter = (FilterMode)EditorGUI.IntPopup(rect, Styles.filterMode, (int)filter, Styles.filterModeOptions, Styles.filterModeValues); if (EditorGUI.EndChangeCheck()) { m_FilterMode.intValue = (int)filter; } EditorGUI.EndProperty(); }
public void OnPreSceneGUI() { if (Event.current.type == EventType.Repaint) { ReflectionProbe target = (ReflectionProbe)this.target; if (this.reflectiveMaterial != null) { Matrix4x4 matrix = new Matrix4x4(); Material reflectiveMaterial = this.reflectiveMaterial; if (target.type == ReflectionProbeType.Cube) { float mipLevelForRendering = 0f; TextureInspector cubemapEditor = this.m_CubemapEditor; if (cubemapEditor != null) { mipLevelForRendering = cubemapEditor.GetMipLevelForRendering(); } reflectiveMaterial.mainTexture = target.texture; reflectiveMaterial.SetMatrix("_CubemapRotation", Matrix4x4.identity); reflectiveMaterial.SetFloat("_Mip", mipLevelForRendering); reflectiveMaterial.SetFloat("_Alpha", 0f); reflectiveMaterial.SetFloat("_Intensity", this.GetProbeIntensity(target)); float x = target.transform.lossyScale.magnitude * 0.5f; matrix.SetTRS(target.transform.position, Quaternion.identity, new Vector3(x, x, x)); Graphics.DrawMesh(sphereMesh, matrix, this.reflectiveMaterial, 0, SceneView.currentDrawingSceneView.camera); } else { reflectiveMaterial.SetTexture("_MainTex", target.texture); reflectiveMaterial.SetFloat("_ReflectionProbeType", 1f); reflectiveMaterial.SetFloat("_Intensity", 1f); Vector3 s = new Vector3(); s = (Vector3)(target.transform.lossyScale * 0.2f); s.x *= -1f; s.z *= -1f; matrix.SetTRS(target.transform.position, target.transform.rotation * Quaternion.AngleAxis(90f, Vector3.right), s); Graphics.DrawMesh(planeMesh, matrix, this.reflectiveMaterial, 0, SceneView.currentDrawingSceneView.camera); } } } }
private void OnPreSceneGUICallback(SceneView sceneView) { if (Event.current.type == EventType.Repaint) { UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { UnityEngine.Object @object = targets[i]; ReflectionProbe reflectionProbe = (ReflectionProbe)@object; if (!this.reflectiveMaterial) { break; } Matrix4x4 matrix = default(Matrix4x4); if (!this.m_CachedGizmoMaterials.ContainsKey(reflectionProbe)) { this.m_CachedGizmoMaterials.Add(reflectionProbe, UnityEngine.Object.Instantiate <Material>(this.reflectiveMaterial)); } Material material = this.m_CachedGizmoMaterials[reflectionProbe] as Material; if (!material) { break; } float value = 0f; TextureInspector cubemapEditor = this.m_CubemapEditor; if (cubemapEditor) { value = cubemapEditor.GetMipLevelForRendering(); } material.SetTexture("_MainTex", reflectionProbe.texture); material.SetMatrix("_CubemapRotation", Matrix4x4.identity); material.SetFloat("_Mip", value); material.SetFloat("_Alpha", 0f); material.SetFloat("_Intensity", this.GetProbeIntensity(reflectionProbe)); float num = reflectionProbe.transform.lossyScale.magnitude * 0.5f; matrix.SetTRS(reflectionProbe.transform.position, Quaternion.identity, new Vector3(num, num, num)); Graphics.DrawMesh(ReflectionProbeEditor.sphereMesh, matrix, material, 0, SceneView.currentDrawingSceneView.camera, 0); } } }
private void OnPreSceneGUICallback(SceneView sceneView) { if (Event.current.type == EventType.Repaint) { foreach (UnityEngine.Object obj2 in base.targets) { ReflectionProbe key = (ReflectionProbe)obj2; if (this.reflectiveMaterial == null) { break; } Matrix4x4 matrix = new Matrix4x4(); if (!this.m_CachedGizmoMaterials.ContainsKey(key)) { this.m_CachedGizmoMaterials.Add(key, UnityEngine.Object.Instantiate <Material>(this.reflectiveMaterial)); } Material material = this.m_CachedGizmoMaterials[key] as Material; if (material == null) { break; } float mipLevelForRendering = 0f; TextureInspector cubemapEditor = this.m_CubemapEditor; if (cubemapEditor != null) { mipLevelForRendering = cubemapEditor.GetMipLevelForRendering(); } material.SetTexture("_MainTex", key.texture); material.SetMatrix("_CubemapRotation", Matrix4x4.identity); material.SetFloat("_Mip", mipLevelForRendering); material.SetFloat("_Alpha", 0f); material.SetFloat("_Intensity", this.GetProbeIntensity(key)); float x = key.transform.lossyScale.magnitude * 0.5f; matrix.SetTRS(key.transform.position, Quaternion.identity, new Vector3(x, x, x)); Graphics.DrawMesh(sphereMesh, matrix, material, 0, SceneView.currentDrawingSceneView.camera, 0); } } }
private void RenderCubemap(Texture t, Vector2 previewDir, float previewDistance) { m_PreviewUtility.camera.transform.position = -Vector3.forward * previewDistance; m_PreviewUtility.camera.transform.rotation = Quaternion.identity; Quaternion rot = Quaternion.Euler(previewDir.y, 0, 0) * Quaternion.Euler(0, previewDir.x, 0); var mat = EditorGUIUtility.LoadRequired("Previews/PreviewCubemapMaterial.mat") as Material; mat.mainTexture = t; mat.SetMatrix(s_ShaderCubemapRotation, Matrix4x4.TRS(Vector3.zero, rot, Vector3.one)); // -1 indicates "use regular sampling"; mips 0 and larger sample only that mip level for preview float mipLevel = GetMipLevelForRendering(t); mat.SetFloat(s_ShaderMip, mipLevel); mat.SetFloat(s_ShaderAlpha, (m_PreviewType == PreviewType.Alpha) ? 1.0f : 0.0f); mat.SetFloat(s_ShaderIntensity, m_Intensity); mat.SetInt(s_ShaderIsNormalMap, TextureInspector.IsNormalMap(t) ? 1 : 0); mat.SetFloat(s_ShaderExposure, GetExposureValueForTexture(t)); m_PreviewUtility.DrawMesh(m_Mesh, Vector3.zero, rot, mat, 0); m_PreviewUtility.Render(); }
protected void DoWrapModePopup() { TextureInspector.WrapModePopup(this.m_WrapU, this.m_WrapV, this.m_WrapW, this.IsVolume(), ref this.m_ShowPerAxisWrapModes); }
public override string GetInfoString() { Texture texture = base.target as Texture; Texture2D texture2D = base.target as Texture2D; TextureImporter textureImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(texture)) as TextureImporter; string text = texture.width.ToString() + "x" + texture.height.ToString(); if (QualitySettings.desiredColorSpace == ColorSpace.Linear) { text = text + " " + TextureUtil.GetTextureColorSpaceString(texture); } bool flag = textureImporter && textureImporter.qualifiesForSpritePacking; bool flag2 = TextureInspector.IsNormalMap(texture); bool flag3 = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(texture)); bool flag4 = texture2D != null && TextureUtil.IsNonPowerOfTwo(texture2D); TextureFormat textureFormat = TextureUtil.GetTextureFormat(texture); bool flag5 = !flag3; if (flag4) { text += " (NPOT)"; } if (flag3) { text += " (Not yet compressed)"; } else if (flag2) { switch (textureFormat) { case TextureFormat.ARGB4444: text += " Nm 16 bit"; goto IL_176; case TextureFormat.RGB24: IL_11D: if (textureFormat != TextureFormat.DXT5) { text = text + " " + TextureUtil.GetTextureFormatString(textureFormat); goto IL_176; } text += " DXTnm"; goto IL_176; case TextureFormat.RGBA32: case TextureFormat.ARGB32: text += " Nm 32 bit"; goto IL_176; } goto IL_11D; IL_176 :; } else if (flag) { TextureFormat format; ColorSpace colorSpace; int num; textureImporter.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out format, out colorSpace, out num); string text2 = text; text = string.Concat(new string[] { text2, "\n ", TextureUtil.GetTextureFormatString(textureFormat), "(Original) ", TextureUtil.GetTextureFormatString(format), "(Atlas)" }); } else { text = text + " " + TextureUtil.GetTextureFormatString(textureFormat); } if (flag5) { text = text + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySizeLong(texture)); } if (TextureUtil.GetUsageMode(texture) == TextureUsageMode.AlwaysPadded) { int gPUWidth = TextureUtil.GetGPUWidth(texture); int gPUHeight = TextureUtil.GetGPUHeight(texture); if (texture.width != gPUWidth || texture.height != gPUHeight) { text += string.Format("\nPadded to {0}x{1}", gPUWidth, gPUHeight); } } return(text); }
public override void OnPreviewSettings() { if (this.IsCubemap()) { this.m_CubemapPreview.OnPreviewSettings(base.targets); } else { if (TextureInspector.s_Styles == null) { TextureInspector.s_Styles = new TextureInspector.Styles(); } Texture texture = base.target as Texture; bool flag = true; bool flag2 = false; bool flag3 = true; int num = 1; if (base.target is Texture2D || base.target is ProceduralTexture) { flag2 = true; flag3 = false; } UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { Texture texture2 = (Texture)targets[i]; if (!(texture2 == null)) { TextureFormat format = (TextureFormat)0; bool flag4 = false; if (texture2 is Texture2D) { format = (texture2 as Texture2D).format; flag4 = true; } else if (texture2 is ProceduralTexture) { format = (texture2 as ProceduralTexture).format; flag4 = true; } if (flag4) { if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format)) { if (TextureUtil.GetUsageMode(texture2) == TextureUsageMode.Default) { flag3 = true; } } } num = Mathf.Max(num, TextureUtil.GetMipmapCount(texture2)); } } if (flag2) { this.m_ShowAlpha = true; flag = false; } else if (!flag3) { this.m_ShowAlpha = false; flag = false; } if (flag && texture != null && !TextureInspector.IsNormalMap(texture)) { this.m_ShowAlpha = GUILayout.Toggle(this.m_ShowAlpha, (!this.m_ShowAlpha) ? TextureInspector.s_Styles.RGBIcon : TextureInspector.s_Styles.alphaIcon, TextureInspector.s_Styles.previewButton, new GUILayoutOption[0]); } GUI.enabled = (num != 1); GUILayout.Box(TextureInspector.s_Styles.smallZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.changed = false; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(num - 1), 0f, TextureInspector.s_Styles.previewSlider, TextureInspector.s_Styles.previewSliderThumb, new GUILayoutOption[] { GUILayout.MaxWidth(64f) })); GUILayout.Box(TextureInspector.s_Styles.largeZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
public override bool HasPreviewGUI() { if (base.targets.Length > 1) { return false; } if (this.ValidPreviewSetup()) { Editor cubemapEditor = this.m_CubemapEditor; Editor.CreateCachedEditor(((ReflectionProbe) this.target).texture, null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } return true; }
public override void OnPreviewGUI(Rect position, GUIStyle style) { if (!this.ValidPreviewSetup()) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.5f); GUILayout.Label("Reflection Probe not baked yet", new GUILayoutOption[0]); GUI.color = color; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { ReflectionProbe target = this.target as ReflectionProbe; if (((target != null) && (target.texture != null)) && (base.targets.Length == 1)) { Editor cubemapEditor = this.m_CubemapEditor; Editor.CreateCachedEditor(target.texture, null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } if (this.m_CubemapEditor != null) { this.m_CubemapEditor.SetCubemapIntensity(this.GetProbeIntensity((ReflectionProbe) this.target)); this.m_CubemapEditor.OnPreviewGUI(position, style); } } }
public override bool HasPreviewGUI() { if (this.targets.Length > 1) return false; if (this.ValidPreviewSetup()) { Editor cubemapEditor = (Editor) this.m_CubemapEditor; Editor.CreateCachedEditor((UnityEngine.Object) ((ReflectionProbe) this.target).texture, (System.Type) null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } return true; }
public override void OnPreviewGUI(Rect position, GUIStyle style) { if (!this.ValidPreviewSetup()) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, 0.5f); GUILayout.Label("Reflection Probe not baked yet"); GUI.color = color; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { ReflectionProbe target = this.target as ReflectionProbe; if ((UnityEngine.Object) target != (UnityEngine.Object) null && (UnityEngine.Object) target.texture != (UnityEngine.Object) null && this.targets.Length == 1) { Editor cubemapEditor = (Editor) this.m_CubemapEditor; Editor.CreateCachedEditor((UnityEngine.Object) target.texture, (System.Type) null, ref cubemapEditor); this.m_CubemapEditor = cubemapEditor as TextureInspector; } if (!((UnityEngine.Object) this.m_CubemapEditor != (UnityEngine.Object) null)) return; this.m_CubemapEditor.SetCubemapIntensity(this.GetProbeIntensity((ReflectionProbe) this.target)); this.m_CubemapEditor.OnPreviewGUI(position, style); } }
public override void OnPreviewSettings() { if (this.IsCubemap()) { this.m_CubemapPreview.OnPreviewSettings(this.targets); } else { if (TextureInspector.s_Styles == null) { TextureInspector.s_Styles = new TextureInspector.Styles(); } Texture target1 = this.target as Texture; bool flag1 = true; bool flag2 = false; bool flag3 = true; int a = 1; if (this.target is Texture2D || this.target is ProceduralTexture) { flag2 = true; flag3 = false; } foreach (Texture target2 in this.targets) { TextureFormat format = (TextureFormat)0; bool flag4 = false; if (target2 is Texture2D) { format = (target2 as Texture2D).format; flag4 = true; } else if (target2 is ProceduralTexture) { format = (target2 as ProceduralTexture).format; flag4 = true; } if (flag4) { if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format) && TextureUtil.GetUsageMode(target2) == TextureUsageMode.Default) { flag3 = true; } } a = Mathf.Max(a, TextureUtil.CountMipmaps(target2)); } if (flag2) { this.m_ShowAlpha = true; flag1 = false; } else if (!flag3) { this.m_ShowAlpha = false; flag1 = false; } if (flag1 && !TextureInspector.IsNormalMap(target1)) { this.m_ShowAlpha = GUILayout.Toggle(this.m_ShowAlpha, !this.m_ShowAlpha ? TextureInspector.s_Styles.RGBIcon : TextureInspector.s_Styles.alphaIcon, TextureInspector.s_Styles.previewButton, new GUILayoutOption[0]); } GUI.enabled = a != 1; GUILayout.Box(TextureInspector.s_Styles.smallZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.changed = false; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(a - 1), 0.0f, TextureInspector.s_Styles.previewSlider, TextureInspector.s_Styles.previewSliderThumb, GUILayout.MaxWidth(64f))); GUILayout.Box(TextureInspector.s_Styles.largeZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
public override string GetInfoString() { Texture target1 = this.target as Texture; Texture2D target2 = this.target as Texture2D; TextureImporter atPath = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath((UnityEngine.Object)target1)) as TextureImporter; string str1 = target1.width.ToString() + "x" + target1.height.ToString(); if (QualitySettings.desiredColorSpace == ColorSpace.Linear) { str1 = str1 + " " + TextureUtil.GetTextureColorSpaceString(target1); } bool flag1 = (bool)((UnityEngine.Object)atPath) && atPath.qualifiesForSpritePacking; bool flag2 = TextureInspector.IsNormalMap(target1); bool beCompressed = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath((UnityEngine.Object)target1)); bool flag3 = (UnityEngine.Object)target2 != (UnityEngine.Object)null && TextureUtil.IsNonPowerOfTwo(target2); TextureFormat textureFormat1 = TextureUtil.GetTextureFormat(target1); bool flag4 = !beCompressed; if (flag3) { str1 += " (NPOT)"; } string str2; if (beCompressed) { str2 = str1 + " (Not yet compressed)"; } else if (flag2) { TextureFormat textureFormat2 = textureFormat1; switch (textureFormat2) { case TextureFormat.ARGB4444: str2 = str1 + " Nm 16 bit"; break; case TextureFormat.ARGB32: str2 = str1 + " Nm 32 bit"; break; default: str2 = textureFormat2 == TextureFormat.DXT5 ? str1 + " DXTnm" : str1 + " " + TextureUtil.GetTextureFormatString(textureFormat1); break; } } else if (flag1) { TextureFormat desiredFormat; ColorSpace colorSpace; int compressionQuality; atPath.ReadTextureImportInstructions(EditorUserBuildSettings.activeBuildTarget, out desiredFormat, out colorSpace, out compressionQuality); str2 = str1 + "\n " + TextureUtil.GetTextureFormatString(textureFormat1) + "(Original) " + TextureUtil.GetTextureFormatString(desiredFormat) + "(Atlas)"; } else { str2 = str1 + " " + TextureUtil.GetTextureFormatString(textureFormat1); } if (flag4) { str2 = str2 + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySize(target1)); } if (TextureUtil.GetUsageMode(target1) == TextureUsageMode.AlwaysPadded) { int glWidth = TextureUtil.GetGLWidth(target1); int glHeight = TextureUtil.GetGLHeight(target1); if (target1.width != glWidth || target1.height != glHeight) { str2 += string.Format("\nPadded to {0}x{1}", (object)glWidth, (object)glHeight); } } return(str2); }
public override string GetInfoString() { Texture texture = this.target as Texture; Texture2D texture2D = this.target as Texture2D; string text = texture.width.ToString() + "x" + texture.height.ToString(); if (QualitySettings.desiredColorSpace == ColorSpace.Linear) { text = text + " " + TextureUtil.GetTextureColorSpaceString(texture); } bool flag = TextureInspector.IsNormalMap(texture); bool flag2 = TextureUtil.DoesTextureStillNeedToBeCompressed(AssetDatabase.GetAssetPath(texture)); bool flag3 = texture2D != null && TextureUtil.IsNonPowerOfTwo(texture2D); TextureFormat textureFormat = TextureUtil.GetTextureFormat(texture); bool flag4 = !flag2; if (flag3) { text += " (NPOT)"; } if (flag2) { text += " (Not yet compressed)"; } else { if (flag) { TextureFormat textureFormat2 = textureFormat; switch (textureFormat2) { case TextureFormat.ARGB4444: text += " Nm 16 bit"; goto IL_142; case TextureFormat.RGB24: case TextureFormat.RGBA32: IL_E9: if (textureFormat2 != TextureFormat.DXT5) { text = text + " " + TextureUtil.GetTextureFormatString(textureFormat); goto IL_142; } text += " DXTnm"; goto IL_142; case TextureFormat.ARGB32: text += " Nm 32 bit"; goto IL_142; } goto IL_E9; IL_142 :; } else { text = text + " " + TextureUtil.GetTextureFormatString(textureFormat); } } if (flag4) { text = text + "\n" + EditorUtility.FormatBytes(TextureUtil.GetStorageMemorySize(texture)); } if (TextureUtil.GetUsageMode(texture) == TextureUsageMode.AlwaysPadded) { int gLWidth = TextureUtil.GetGLWidth(texture); int gLHeight = TextureUtil.GetGLHeight(texture); if (texture.width != gLWidth || texture.height != gLHeight) { text += string.Format("\nPadded to {0}x{1}", gLWidth, gLHeight); } } return(text); }