/// <summary>
        /// Primary Reader for PackedBits.
        /// </summary>
        public static ulong ReadPackedBits(this uint buffer, ref int bitposition, int bits)
        {
            var packsize = BitCounter.UsedBitCount(bits);
            int cnt      = (int)buffer.Read(ref bitposition, (int)packsize);

            return(buffer.Read(ref bitposition, cnt));
        }
        /// <summary>
        /// EXPERIMENTAL: Primary WritePacked Method
        /// </summary>
        public static ushort WritePackedBits(this ushort buffer, byte value, ref int bitposition, int bits)
        {
            int countbits = BitCounter.UsedBitCount((uint)bits);
            int cnt       = value.UsedBitCount();

            buffer = buffer.Write((uint)(cnt), ref bitposition, (int)countbits);
            buffer = buffer.Write(value, ref bitposition, cnt);

            //UnityEngine.Debug.Log(value + " = ones : " + cnt + " / " + (int)countbits + "  total bits: " + ((int)countbits + cnt));
            return(buffer);
        }