From 535c1b8838a86f8571da0dd3f2eb2b1787af4f5a Mon Sep 17 00:00:00 2001 From: Scott Przybylski Date: Wed, 24 May 2023 13:46:40 -0700 Subject: [PATCH] Fixes to work with Unity 2020. --- .../Editor/Scripts/MeshProjector.cs | 4 ++-- .../UnityTechnologies/RTHandleCollection.cs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Assets/Terrain Align/Editor/Scripts/MeshProjector.cs b/Assets/Terrain Align/Editor/Scripts/MeshProjector.cs index 4e5be8a..c11bde4 100644 --- a/Assets/Terrain Align/Editor/Scripts/MeshProjector.cs +++ b/Assets/Terrain Align/Editor/Scripts/MeshProjector.cs @@ -127,7 +127,7 @@ private void Init() renderTextureDescriptions.Add(new RenderTextureDescription(RenderTextureIDs.meshHeight, GraphicsFormat.R16_UNorm, true)); renderTextureDescriptions.Add(new RenderTextureDescription(RenderTextureIDs.combinedHeightMap, GraphicsFormat.R16_UNorm, true)); renderTextureDescriptions.Add(new RenderTextureDescription(RenderTextureIDs.heightMapCurrent, GraphicsFormat.R16_UNorm, true)); - renderTextureDescriptions.Add(new RenderTextureDescription(RenderTextureIDs.cameraDepthRT, GraphicsFormat.DepthAuto, false)); + renderTextureDescriptions.Add(new RenderTextureDescription(RenderTextureIDs.cameraDepthRT, GraphicsFormat.None, false)); // create RT handles m_rtCollection = new RTHandleCollection(); @@ -174,7 +174,7 @@ public Projector CreateProjector() break; default: - throw new ArgumentOutOfRangeException( "Unsupported direction: " + settings.direction); + throw new ArgumentOutOfRangeException( "Unsupported direction: " + settings.direction); } diff --git a/Assets/Terrain Align/Editor/Scripts/UnityTechnologies/RTHandleCollection.cs b/Assets/Terrain Align/Editor/Scripts/UnityTechnologies/RTHandleCollection.cs index 14d16a4..8ff219f 100644 --- a/Assets/Terrain Align/Editor/Scripts/UnityTechnologies/RTHandleCollection.cs +++ b/Assets/Terrain Align/Editor/Scripts/UnityTechnologies/RTHandleCollection.cs @@ -1,9 +1,9 @@ /// This class is based on the Unity Technologies Terrain Tools. /// License: -/// -/// Terrain Tools copyright © 2020 Unity Technologies ApS +/// +/// Terrain Tools copyright � 2020 Unity Technologies ApS /// Licensed under the Unity Companion License for Unity-dependent projects--see Unity Companion License. -/// Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions. +/// Unless expressly provided otherwise, the Software under this license is made available strictly on an �AS IS� BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions. /// /// https://docs.unity3d.com/Packages/com.unity.terrain-tools@3.0/license/LICENSE.html /// @@ -67,7 +67,7 @@ public RTHandle this[ string name ] m_Handles[ m_NameToHash[ name ] ] = value; } } - + /// /// RTHandleCollection constructor /// @@ -113,7 +113,7 @@ public bool ContainsRTHandle( string name ) { return m_NameToHash.ContainsKey( name ); } - + /// /// Check to see if a RTHandle with the provided hash value exists already /// The hash or integer value used to identify a RTHandle in this RTHandleCollection @@ -141,6 +141,11 @@ public void GatherRTHandles( int width, int height, int depth = 0 ) foreach( int key in m_Hashes ) { var desc = new RenderTextureDescriptor( width, height, m_Formats[ key ], depth ); + if (m_Formats[key] == GraphicsFormat.None) + { + desc.colorFormat = RenderTextureFormat.Depth; + desc.depthBufferBits = 32; + } m_Handles[ key ] = RTUtils.GetNewHandle( desc ); m_Handles[ key ].RT.Create(); } @@ -224,7 +229,7 @@ public void Dispose() public virtual void Dispose(bool dispose) { if(m_Disposed) return; - + if(!dispose) return; ReleaseRTHandles();