// TODO When .Net 4.5 becomes available in Unity: Replace IList<T> with IReadOnlyList<T> since we want to pass Array where number and order of list elements is read-only. public static bool TryReadFrom(IList <byte> data, ref int index, out SixteenByteOscData value) { if (index + byteCount > data.Count) { value = new SixteenByteOscData(); return(false); } value = new SixteenByteOscData( data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++], data[index++] ); return(true); }
public static bool TryReadFrom(byte[] data, ref int index, out Rect value) { // Try to get blob byte count. int byteCountPrefixValue; if (!TryReadAndEvaluateByteCountPrefix(data, index, out byteCountPrefixValue)) { value = Rect.zero; return(false); } index += FourByteOscData.byteCount; SixteenByteOscData valueData; if (!SixteenByteOscData.TryReadFrom(data, ref index, out valueData)) { value = Rect.zero; return(false); } value = valueData.rectValue; return(true); }
public static bool TryReadFrom(IList <byte> data, ref int index, out Quaternion value) { // Try to get blob byte count. int byteCountPrefixValue; if (!TryReadAndEvaluateByteCountPrefix(data, index, out byteCountPrefixValue)) { value = Quaternion.identity; return(false); } index += FourByteOscData.byteCount; SixteenByteOscData valueData; if (!SixteenByteOscData.TryReadFrom(data, ref index, out valueData)) { value = Quaternion.identity; return(false); } value = valueData.quaternionValue; return(true); }