// public function to use in ring button OnClick() in his inspector public void SelectRing(int id) { if (PlayerPrefs.GetInt(rings.carID.ToString() + "Ring" + id.ToString()) == 3) // 3=>true , 0=>false // Find current car T_Rings component { rings = GameObject.FindObjectOfType <T_Rings> (); // We have 6 rings, and first de activate all rings rings.SetRing(0, false); rings.SetRing(1, false); rings.SetRing(2, false); rings.SetRing(3, false); rings.SetRing(4, false); rings.SetRing(5, false); // And then activate current selected ring: rings.SetRing(id, true); PlayerPrefs.SetInt(rings.carID.ToString() + "RingID", id); tShop.ShowWindow(false); } else // The current selected ring is not unlocked, We unlock it with reducing money from player total moneys and unlock ring // Find current car T_Rings component { rings = GameObject.FindObjectOfType <T_Rings> (); // We have 6 rings, and first de activate all rings rings.SetRing(0, false); rings.SetRing(1, false); rings.SetRing(2, false); rings.SetRing(3, false); rings.SetRing(4, false); rings.SetRing(5, false); // And then activate current selected ring: rings.SetRing(id, true); tShop.carID = rings.carID; tShop.itemID = id; // tShop.currentItemPrice.text = tShop.ringPrice[id].ToString(); tShop.itemType = ItemType.Ring; tShop.ShowWindow(true); } }