#GUID load system

1 messages · Page 1 of 1 (latest)

knotty relic
#

placeholder

#

right now i have implemented backend for some NPC/entities data, take this as an example

    public struct Crop
    {
        [JsonInclude] public Dictionary<CropStatus, string> Appearance; // mesh guid as string
        [JsonInclude] public Dictionary<CropStatus, string[]> Material; // material guids as string array

        //PlantCropUI use only
        [JsonInclude] public string Icon; // sprite guid 
        [JsonInclude] public string DetailBg; // sprite guid 
        [JsonInclude] public string DetailImage; // sprite guid
    }```

when theyre back , they will have a string of guid , associates with certain assets (and it probably wont be a prefab or even a SO, but just sole assets like a sprite/avatar/materials....etc)

currently , i have a way to generate a fixed GUID inside a SO, this guid wont be changing, so it should be fine
```cs
public class GUIDSO : ScriptableObject
{
    [SerializeField] private string guidString = Guid.NewGuid().ToString();

    [NonSerialized]
    private Guid guid = Guid.Empty;

    public Guid Guid
    {
        get
        {
            if (guid == Guid.Empty)
            {
                guid = new Guid(guidString);
            }
       
            return guid;
        }       
    }
}```
#

so , what i need is actually linking the ..... lets say Icon guid is "1234" , to an asset with guid 1234, generated by this approach

winter frost
knotty relic
#

ty

candid bluff
#

I know it's outside of what was asked but I wonder if Addressables wouldn't be a more suitable approach here

#

This feels a lot like AssetReferences

knotty relic
#

u will never save down a 100mb models into a server , right?

candid bluff
#

Are you asking me if I would download a car?

knotty relic
#

u will save down a reference, like an ID or something else

#

guid is doing that

knotty relic
#

and when u get back the data from server, u use the guid to get back the asset reference

candid bluff
#

Addressables might already be solving the thing you're trying to solve here, and might save you time :) Unless I misunderstood what you're going for

knotty relic
#

i didnt really use addressable that much, because my previous 2 teams use that too, but they ended up pretty bad

#

maybe its more like their problems tho lol

knotty relic
knotty relic
# candid bluff Addressables might already be solving the thing you're trying to solve here, and...

can you guarantee or have the confidence to tell me the reference provided by addressable, will be constant/ exactly the same even if:

  • the project is cloned to someone else PC and opened (different directory ofc)
  • will never change even across different network sessions
  • the asset moved places or changed name
  • the asset dragged away from project and put inside the project again ( or reimport)

the reference is compatible to string, and can be searched based on a string or a primitive type

candid bluff
# knotty relic can you guarantee or have the confidence to tell me the reference provided by ad...

Yes; Well, for the last point,

the asset dragged away from project and put inside the project again ( or reimport)
This will depend on whether the meta file remains unchanged or not.

When you build your addressables group, it generates a catalog that you commit with your project, and with this the reference will persist on other machines too.
I am no expert in Addressables, but I am using it in my own networking framework to track and reference asset types for replication, and it's working pretty much as expected.

winter frost
#

the asset dragged away from project and put inside the project again ( or reimport)
assuming you mean fully removed and then readded to the project, i don't think that'd be possible for any generated identifier. you'd have to hash the file contents or something to get something like that

knotty relic
#

im asking about the last one, because the guid generated by this approach

public class GUIDSO : ScriptableObject
{
    [SerializeField] private string guidString = Guid.NewGuid().ToString();

    [NonSerialized]
    private Guid guid = Guid.Empty;

    public Guid Guid
    {
        get
        {
            if (guid == Guid.Empty)
            {
                guid = new Guid(guidString);
            }
       
            return guid;
        }       
    }
}```

really wont change
#

i tried deleting meta files of this SO , reimport the SO , changed the name of SO

#

but yeah, i think i need to think deep about it

winter frost
#

what do you mean "reimport the SO"

knotty relic
#

do my project really need this high level of flexibility

winter frost
#

the guid there is saved in the SO file, as data, not metadata

knotty relic
winter frost
#

right, because the guid was serialized

#

it's basically just a guid as a file

#

but if you "reimport" it like that, the references to the SO itself can break

#

since there's no persisting metadata

knotty relic
#

i think 4th one is optional , i only need the first 3 to work

candid bluff
#

But there still needs to be a link between an Asset and this SO, no? And if the Asset changes, or the SO changes, that link won't persist either way

knotty relic
#

especially persistent across network sessions and different PC (my other teammates might need to work on project as well)