Есть переменная которая увеличивается с каждым кликом на рандомное число. Нужно сделать так чтобы если переменная была в промежутки 24-38 на новой сцене создавался определенный спрайт А в другом промежутке 0-23 другой спрайт
Regal1ze, Тогда переформулируй вопрос, потому что переменная которая увеличивается и промежутки для спрайтов вообще ни при чём
вот: using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Sprite sprite1; public Sprite sprite2; private int yourVariable; void Start() { yourVariable = 0; } void Update() { if (Input.GetMouseButtonDown(0)) { yourVariable += Random.Range(0, 39); } if(yourVariable >= 24 && yourVariable <= 38){ GameObject.Find("Canvas").GetComponent<SpriteRenderer>().sprite = sprite1; } else { GameObject.Find("Canvas").GetComponent<SpriteRenderer>).sprite = sprite2; } } } CSHARP using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Sprite sprite1; public Sprite sprite2; private int yourVariable; void Start() { yourVariable = 0; } void Update() { if (Input.GetMouseButtonDown(0)) { yourVariable += Random.Range(0, 39); } if(yourVariable >= 24 && yourVariable <= 38){ GameObject.Find("Canvas").GetComponent<SpriteRenderer>().sprite = sprite1; } else { GameObject.Find("Canvas").GetComponent<SpriteRenderer>).sprite = sprite2; } } }