Please help me completing this script
Hello everyone, I am completely new in coding and i need help on completing this code, where: There are two buttons, right and left. When right button clicked then value of a CarNumber decreased by 1, while, when left button clicked then value of CarNumber increased by 1. Value of CarNumber must be between 10-13 only. if value is already maximum and button clicked for increase then it will be reset to minimum value. and while value is already minimum and button clicked for decrease then it will be set to maximum value. Like: 10>11>12>13>10 and 13>12>11>10>13 i tried to write above code myself but didn't succeed. This is the code I write:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CarLock : MonoBehaviour
{
public int CarNumber = 10;
public int greenSelect;
public void onClickRight()
{
CarNumber--;
PlayerPrefs.SetInt("CarNumberPref", CarNumber);
}
public void onClickLeft()
{
CarNumber++;
PlayerPrefs.SetInt("CarNumberPref", CarNumber);
}
void Update()
{
greenSelect = PlayerPrefs.GetInt("CarNumberPref");
Debug.Log(greenSelect);
}
}
please help me.
Your answer
Follow this Question
Related Questions
Guidance on creating a ClickCounter 0 Answers
Faster Way to Increment PlayerPrefs Int 1 Answer
Playerprefs, i dont know how to use 0 Answers
How do I use PlayerPrefs properly? 1 Answer
how i save and load my coins look the script please 0 Answers