i can display my score stars in unity properly
As show above but in actual Android device it isnt showing
where have i gone wrong cant seem to figure it out.
here is score script:-
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class score1 : MonoBehaviour
{
public static score1 instance;
private Text scoreText;
private int scr;
public GameObject[] stars;
void Start()
{
PlayerPrefs.SetInt("Score", score1.instance.GetScore());
StartCoroutine(StartStar());
}
// Start is called before the first frame update
void Awake()
{
scoreText = GameObject.Find("scores").GetComponent<Text>();
MakeInstance();
}
// Update is called once per frame
void MakeInstance()
{
if (instance == null)
instance = this;
}
public void IncrementScore()
{
scr++;
scoreText.text = "Score:" + scr;
StartCoroutine(ShowStarrCo());
}
public int GetScore()
{
return this.scr;
}
IEnumerator ShowStarrCo()
{
if (scr < 3)
{
stars[0].SetActive(false);
stars[1].SetActive(false);
stars[2].SetActive(false);
yield return new WaitForSeconds(0);
}
else if (scr < 7)
{
stars[0].SetActive(true);
stars[1].SetActive(false);
stars[2].SetActive(false);
}
else if (scr < 15)
{
stars[0].SetActive(true);
yield return new WaitForSeconds(1);
stars[1].SetActive(true);
stars[2].SetActive(false);
yield return new WaitForSeconds(0);
}
else
{
stars[0].SetActive(true);
yield return new WaitForSeconds(1);
stars[1].SetActive(true);
yield return new WaitForSeconds(1);
stars[2].SetActive(true);
}
}
IEnumerator StartStar()
{
if (scr == 0)
{
stars[0].SetActive(false);
stars[1].SetActive(false);
stars[2].SetActive(false);
yield return new WaitForSeconds(0);
}
}

