Quantcast
Channel: Questions in topic: "credits"
Viewing all articles
Browse latest Browse all 71

Not all code paths return a value?

$
0
0
I'm getting an error in Unity that I've never gotten before. It says: *Assets/Scripts/Managers/PlayerFunds.cs(20,22): error CS0161: `PlayerFunds.SaveCredits()': not all code paths return a value* The script I'm writing is very simple so I don't understant what the problem may be. Here is the code: using UnityEngine; using System.Collections; public class PlayerFunds : MonoBehaviour { public int playerCredits; void Start() { playerCredits = PlayerPrefs.GetInt("Credits"); } public void AddCredits(int amount) { playerCredits += amount; } public void SubtractCredits(int amount) { playerCredits -= amount; } public float SaveCredits() { PlayerPrefs.SetInt("Credits", playerCredits); } }

Viewing all articles
Browse latest Browse all 71

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>