// 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); } } }
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 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); } } }