GetReadOnlySpan <T>(this NativeSlice <T> slice) where T : unmanaged { var ptr = NativeSliceUnsafeUtility.GetUnsafeReadOnlyPtr(slice); return(new Span <T>(ptr, slice.Length)); }
/// <summary> /// Writes a frame of input to the file. /// </summary> /// <param name="inputs">a frame of input to write.</param> public unsafe void WriteInputs(NativeSlice <PlayerInput> inputs) { Assert.IsTrue(inputs.Length == _config.PlayerCount); var ptr = (byte *)NativeSliceUnsafeUtility.GetUnsafeReadOnlyPtr(inputs); int size = _config.PlayerCount * UnsafeUtility.SizeOf <PlayerInput>(); _writer.Write(XXHash.Hash64(ptr, size)); _writer.WriteBytes(ptr, size); }