Example #1
0
    GetReadOnlySpan <T>(this NativeSlice <T> slice)
        where T : unmanaged
    {
        var ptr = NativeSliceUnsafeUtility.GetUnsafeReadOnlyPtr(slice);

        return(new Span <T>(ptr, slice.Length));
    }
Example #2
0
        /// <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);
        }