L
L
Lev Malyshev2020-12-06 11:06:52
Unity
Lev Malyshev, 2020-12-06 11:06:52

How to choose a character?

I have a scene in which you can choose a character, they open for records. For example, you have a time record in the game of 25 seconds, and then a character will open that opens at 25 seconds. While the character is not open, it has a black color (like it is not open yet) It happens like this

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class IsEnabled : MonoBehaviour
{
    public int NeedToUnlock;
    public Color NewColor;
    SpriteRenderer SpriteR;
    public Sprite Pink_Monster;
    public SpriteRenderer PinkMonster;

    void Start()
    {
        if (PlayerPrefs.GetInt("SaveScore") < NeedToUnlock)
        {
            GetComponent<SpriteRenderer>().color = Color.black;
        }

    }


In the game, it looks like this. 5fcc90e655179439699031.png
I need it so that when you click on the "Select" button, and then the game will have the character you chose. For example, I chose a white character and he appeared in the game (the game is on a different stage). Explain how to do it?
5fcc91066d44e124955245.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-12-06
@freeExec

https://wiki.unity3d.com/index.php/Singleton

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question