From 6d9a76b3524e72a7dd06634c6dda6628772f7ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalle=20Sjo=CC=88stro=CC=88m?= Date: Fri, 19 Dec 2014 13:57:59 +0100 Subject: [PATCH] Added a serializable version of long. It is split into two ints instead.. --- Script/Utils/Id64.cs | 35 +++++++++++++++++++++++++++++++++++ Script/Utils/Id64.cs.meta | 8 ++++++++ 2 files changed, 43 insertions(+) create mode 100644 Script/Utils/Id64.cs create mode 100644 Script/Utils/Id64.cs.meta diff --git a/Script/Utils/Id64.cs b/Script/Utils/Id64.cs new file mode 100644 index 0000000..5e44ba3 --- /dev/null +++ b/Script/Utils/Id64.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using System.Collections; + +[System.Serializable] +public class Id64 +{ + public int low; + public int high; + + public Id64(long l) { + low = (int)(l & 0xFFFFFFFF); + high = (int)(l >> 32); + } + + public static implicit operator long(Id64 l) { + long h = ((long)l.high) << 32; + long lo = l.low & 0x00000000FFFFFFFF; + return h | lo; + } + + public static implicit operator Id64(long l) { + return new Id64(l); + } + + public override bool Equals(System.Object b) { + long la = this; + long lb = ((Id64)b); + return la.Equals(lb); + } + + public override int GetHashCode() { + long l = (long)this; + return l.GetHashCode(); + } +} \ No newline at end of file diff --git a/Script/Utils/Id64.cs.meta b/Script/Utils/Id64.cs.meta new file mode 100644 index 0000000..4a815e3 --- /dev/null +++ b/Script/Utils/Id64.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 26af317100f6144458cb56f62b1b062e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: