Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Making an Encounter Saving System for my Shiny PKMN Counter tool

Discussion in 'Scripting' started by Sol_Slacker, Aug 6, 2020.

  1. Sol_Slacker

    Sol_Slacker

    Joined:
    Jul 17, 2020
    Posts:
    2
    I'm trying to create a function for my Shiny Pokemon Counter application that saves the data of the current hunt when you manually confirm that you've encountered your target. I want to then load this data and all other entries of this data and display them in a UI that lists the history of your encounters.

    To do so, how would I go about saving the set of data comprised of the time from when the save function was called, 3 strings, and 3 ints when prompted and loading these sets of data so I can feed them into the UI? I am rather new to Unity and programming in general, and I'm having trouble figuring out how exactly to do this.


    Below is a screenshot of the app running in the Unity editor. The data I'm working with are the target Pokemon's name as a string, the number of the Dropdown UI option that holds a sprite of the target Pokemon as an int (which I will use to get that sprite in the new UI), the type of the encounter (like regular encounters, hatching eggs, hordes, soft resetting) as a string, the type of the chaining method being used (fishing, SOS, pokeradar, or N/A if not chaining) as a string, the number of encounters as an int, and the number chained to as an int.

    The UI to count the chain and its reset button are disabled if the third dropdown is on Non-Chain. The function to increment the chain count is also disabled if the third dropdown is on Non-Chain. So, I want to be able to have the chain type string and chain count int omitted at some point during the process, and I'm assuming this is to be when the data is being displayed in the UI rather than when saving the data, as I could probably tell the Chain elements in the UI not to display if they're a certain string or int value.
    upload_2020-8-6_16-33-6.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Check into some save/load tutorials for the basic mechanics of getting game data into a state that you can write to disk, then restore from disk.

    After that, it's up to you to decide what data actually needs to be saved in the above game. Work through a tutorial, start by saving one or two values and restoring them properly. Get a feel for what you're up against before you try to save/load 57,000 items all at once and it has an issue. :)
     
  3. Sol_Slacker

    Sol_Slacker

    Joined:
    Jul 17, 2020
    Posts:
    2
    I've gone through two tutorials so far and gotten them to work as intended, but the problem is that these tutorials are for saving/overwriting and loading one file, rather than creating a new file every time.
    upload_2020-8-6_18-21-36.png

    I want to know how to change the first of the two functions here used in the tutorial to create a new file every time, likely using a combination of the date and target Pokemon for the file name (example: Riolu_8_6_2020.pkmn), and the second one to load all of these files in a way that will allow me to plug their data into the UI I intend to design. I might also try to add a function that deletes a selected entry by pressing an 'X' button in the top right of its entry.
    upload_2020-8-6_18-37-33.png
    The UI would probably look something like this (but bigger, with color, a scrollbar, and a button to close it).