コード例 #1
0
    unsafe public static EntityGuid GetEntityGuid(GameObject go, int index)
    {
#if false
        var id = GlobalObjectId.GetGlobalObjectId(go);
        // For the time being use InstanceID until we support GlobalObjectID API
        //Debug.Log(id);
        var hash = Hash128.Compute($"{id}:{index}");

        EntityGuid entityGuid;
        Assert.AreEqual(sizeof(EntityGuid), sizeof(Hash128));
        UnsafeUtility.MemCpy(&entityGuid, &hash, sizeof(Hash128));
        return(entityGuid);
#else
        EntityGuid entityGuid;
        entityGuid.a = (ulong)go.GetInstanceID();
        entityGuid.b = (ulong)index;

        return(entityGuid);
#endif
    }