Search Unity

Saving and loading names of prefabs.

Discussion in 'Scripting' started by Kirby26, Aug 29, 2019.

  1. Kirby26

    Kirby26

    Joined:
    Mar 3, 2019
    Posts:
    13
    Hi. i was wondering how to do this. I want:

    i spawn a prefab of a cow 3 times.

    I change the name of every cow, like, mason, juanita and leonarda.

    Then, i save and quit.

    I open.

    (this is what i dont know how to do)
    ----
    I load. it instantiate 3 cows with the names mason, juanita and leonarda.
    -----

    its like save every name of everything of the name with the tag cow. and when i load, it instantiate 3 cows with tag cow and for anyone of them give it the name.

    I want this because i have the code of stetics of every cow. if a name is Mason, it load mason stetics.

    Sorry for the bad english
     
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
  3. Kirby26

    Kirby26

    Joined:
    Mar 3, 2019
    Posts:
    13
    I'm sorry, you didn't understand me well. My English is pretty bad, so it's my fault.

    I know how to save and load. But, I don't know how to do what I say.

    Save all the names of prefabs with a tag (i know how to do this)

    I want you to press the upload button. All cows are installed. And that they automatically be assigned the name and tag saved. Only that matters, that the name and tag match. That is:
    malon with tag cow.
    johnson with tag cow
    alonso with tag cow
     
  4. Sciirof

    Sciirof

    Joined:
    Apr 5, 2013
    Posts:
    14
    So what do you not know how to do? Instantiate 3 cows?
     
    Joe-Censored likes this.
  5. patSilva

    patSilva

    Joined:
    Mar 25, 2019
    Posts:
    27
  6. Kirby26

    Kirby26

    Joined:
    Mar 3, 2019
    Posts:
    13
    Dahh. im S*** at englishXD

    I know how to instantiate those 3 cows. I want the code to put the 3 names i saved.

    I know how to save and looad things.

    Part 1 Check how many items with tag cow are in the scene
    Part 2. Save the number.

    this:
    Part 3. Save the array of names of the items tagged with cow.
    //
    Part 4. When you use load. Instantiate the same number of cows you save.

    this:
    Part 5. Now every cow is named only cow, the prefab who i instantiate. I want to put them the names i save. The order doesnt matter. i onlye need to have 3 items with the names i saved.
    //
     
  7. Kirby26

    Kirby26

    Joined:
    Mar 3, 2019
    Posts:
    13
    I DONE IT!.