Scriptable object unique ID
I have been trawling through google but can't seem to find a decent answer.
What I want to do is create/get a persistent unique ID for a scriptable object. Ideally I don't want to have to manually type in a number/ID. I also can't use data stored in the object as a base because it changes.
Anyone got any thoughts/ideas on how to do this?
Answer by jonathan8ben · Aug 29, 2021 at 08:51 PM
All done, in the scriptable object create a string variable to store a uiniqueID. Given the class name is ItemBase, In the scriptable object constructor do the following.
protected ItemBase() { BaseItemID = Guid.NewGuid().ToString(); }
Now each time you make an object it will be assigned a unique id.
Your answer
Follow this Question
Related Questions
holding references inside ScriptableObjects or identifiers (int) ? 0 Answers
Does loading a ScriptableObject on runtime and modifying it affect the ScriptableObject in file? 1 Answer
Scripting Movement Fails for Instantiated Prefab 2 Answers
Items/Inventory system using Scriptable Objects and Composition instead Inheritance. 0 Answers
What is the benefit of creating a scriptable object? 2 Answers