unrust_inbuilt/
guid.rs

1use genco::prelude::*;
2use unrust_proc_macro::unity_authoring;
3
4#[unity_authoring]
5pub struct UnityGUID {
6    pub hash: [u32; 4],
7}
8
9#[allow(non_snake_case)]
10pub fn UnityGUID_ingest_component(entity: &mut bevy::ecs::world::EntityMut, val: &UnityGUID) {
11    entity.insert(*val);
12}
13
14#[allow(non_snake_case)]
15pub fn UnityGUID_CSHARP_TOKEN() -> csharp::Tokens {
16    quote! {
17        [StructLayout(LayoutKind.Sequential)]
18        public unsafe struct UnityGUID
19        {
20            public fixed uint hash[4];
21
22            public static implicit operator Unity.Entities.Serialization.EntityPrefabReference(UnityGUID val) => new Unity.Entities.Serialization.EntityPrefabReference(new Unity.Entities.Hash128(val.hash[0], val.hash[1], val.hash[2], val.hash[3]));
23
24            public static implicit operator UnityGUID(Unity.Entities.Serialization.EntityPrefabReference val)
25            {
26                var guid = new UnityGUID();
27                var hashes = val.AssetGUID.Value;
28                guid.hash[0] = hashes[0];
29                guid.hash[1] = hashes[1];
30                guid.hash[2] = hashes[2];
31                guid.hash[3] = hashes[3];
32                return guid;
33            }
34        }
35
36        [StructLayout(LayoutKind.Sequential)]
37        public unsafe struct UnityPrefab
38        {
39            public int ResourceID;
40            public UnityEntity* Guid;
41            public nuint Length;
42        }
43    }
44}