unexpected symbols
So I followed a video tutorial here and wrote the first script that was shown in the video but I got a bunch of unexpected symbol errors. I got errors for using these symbols: '=' '+' 'if' '=='
using UnityEngine;
using System.Collections;
public class CurrencyConverter : MonoBehaviour {
private static CurrencyConverter instance;
public static CurrencyConverter Instance{
get
{
return instance;
}
}
void Awake()
{
CreateInstance();
}
void CreateInstance()
{
if(instance == null)
{
instance = this;
}
}
public string GetCurrencyIntoString(float valueToConvert, bool currencyPerClick, bool currencyPerSec)
{
string converted;
if(valueToConvert >= 1000000000000)
{
converted = (valueToConvert / 1000000000000f).ToString ("f3") + " T";
} else if(valueToConvert >= 1000000000)
{
converted = (valueToConvert / 1000000000f).ToString ("f3") + " B";
} else if(valueToConvert >= 1000000)
{
converted = (valueToConvert / 1000000f).ToString ("f3") + " M";
} else if(valueToConvert >= 1000)
{
converted = (valueToConvert / 1000f).ToString ("f3") + " K";
}else
{
converted = "" + valueToConvert;
}
}
if(currencyPerSec == true)
{
converted = converted + " CPS";
}
if(currencyPerClick == true)
{
converted = converted + " CPC";
}
}
Answer by Jessespike · Mar 30, 2016 at 08:56 PM
The last two if-statements are not in the GetCurrencyIntoString function. Also GetCurrencyIntoString is not returning the converted string.
At the end of the script I added a return null;
to calm unity down and I continued to follow the video. But how would I return GetCurrencyIntoString if it's a float, a bool, and another bool?
Your answer
Follow this Question
Related Questions
Modyfing survival shooter script to add health 1 Answer
Parsing error and unexpected symbol 1 Answer
Parser Error - Unexpected symbol 2 Answers
Error CS1525|Unexpected " { " Please Help. Urgent. 1 Answer
C# - Unexpected Symbol ERROR? 1 Answer