Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by prototyped · May 02 at 05:23 PM · data storagepersistencecardcardsunique-identifiers

Trading card game uniqe id generation

So in making a trading card game, I need to make sure every trading card has a unique ID, but I need the first character needs to identify what type of card it is, would it be best practice to use an ID generator and concatenate the identifier?

p.s. I low-key want the ID's to be ordered so that if you got all the cards you could kind of see the order each card was released but I feel like that's a bad idea just wanted to share this thought.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by MickyX · May 03 at 03:36 PM

I personally don't see whats wrong with adding some identifier information into the identifier if you want to do that

I guess you want something like CardID-Day-Month-Year-UniqueID

I would use GUIDs to do this

So you could have CardID: 1 - Lets you know which card it is Day - Month - Year let you know when it was released GUID is the unique reference for that particular card

In code this could look like

 public void GenerateNewCards(int numOfCards, string cardID, string dateInfo)
     {
         for (int i = 0; i < numOfCards; i++)
         {
             string newCardReference = string.Format("{0}-{1}-{2}", cardID,dateInfo, System.Guid.NewGuid().ToString());
             Debug.Log(newCardReference);
         }
     }

I ran that for 5 cards and got

 GenerateNewCards(5,"1","01-12-2022");

 1-01-12-2022-54ab56cb-8611-4100-a4d4-adeca2c3ee85
 1-01-12-2022-b5dd3c42-4a88-4b4e-bad5-8ae250a4660e
 1-01-12-2022-009f4831-a929-455c-9a0b-07ef9266f005
 1-01-12-2022-30b0da50-294d-4801-8637-fac368cddb34
 1-01-12-2022-d9b45f61-9ab3-45dd-b038-96898a578dfe


This should create you results that are unique and you can read the first bit to know what the card is and when it was released. You can then parse that string later to get that information out

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Monsoonexe · May 04 at 12:31 AM

In my games, I need a persistent, unique identifier when saving game state so that it can be loaded again on another play session. I accomplish this with the Guid class: https://docs.microsoft.com/en-us/dotnet/api/system.guid?view=net-6.0

E.g. string saveID = Guid.NewGuid().ToString(); If you need to determine an order to it, just add some arbitrary letters to it: string cardID = "a" + Guid.NewGuid().ToString(). "a" can be replaced with an array entry as well. Consider: string[] prefixes = new string[] { "a", "b", "c", ... "aa", "ab", "ac"} ;

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

137 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Playing Cards With Special Shrinking & Twisting Effects 1 Answer

How do I add new instances of a object into a list? 1 Answer

How to create set of cards? 1 Answer

Trading Card Game 5 Answers

(UNO card game) I can't get the data with GetComponent function for an instance of an object 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges