@@ -143,20 +143,19 @@ private readonly bool TryLoadMaterial(Entity material, IsMaterialRequest request
143143 LoadData message = new ( world , request . address ) ;
144144 if ( context . TryHandleMessage ( ref message ) != default )
145145 {
146- if ( message . IsLoaded )
146+ if ( message . TryConsume ( out ByteReader data ) )
147147 {
148148 //todo: handle different formats, especially gltf
149149 const string Vertex = "vertex" ;
150150 const string Fragment = "fragment" ;
151- using ByteReader reader = new ( message . Bytes ) ;
152- using JSONObject jsonObject = reader . ReadObject < JSONObject > ( ) ;
153- bool hasVertexProperty = jsonObject . Contains ( Vertex ) ;
154- bool hasFragmentProperty = jsonObject . Contains ( Fragment ) ;
155- message . Dispose ( ) ;
151+ using JSONObject jsonObject = data . ReadObject < JSONObject > ( ) ;
152+ bool hasVertexProperty = jsonObject . TryGetText ( Vertex , out ReadOnlySpan < char > vertexText ) ;
153+ bool hasFragmentProperty = jsonObject . TryGetText ( Fragment , out ReadOnlySpan < char > fragmentText ) ;
154+ data . Dispose ( ) ;
156155 if ( hasVertexProperty && hasFragmentProperty )
157156 {
158- Address vertexAddress = new ( jsonObject . GetText ( Vertex ) ) ;
159- Address fragmentAddress = new ( jsonObject . GetText ( Fragment ) ) ;
157+ Address vertexAddress = new ( vertexText ) ;
158+ Address fragmentAddress = new ( fragmentText ) ;
160159 ShaderKey vertexKey = new ( world , vertexAddress ) ;
161160 if ( ! cachedShaders . TryGetValue ( vertexKey , out Shader vertexShader ) )
162161 {
0 commit comments