- Home /
Quiz Scoreboard
Hello, I want to make a script for score, at each question answered right the player gets a point but I can't figure how to make the script, so here it is:
using UnityEngine;
using System.Collections;
public class Final : MonoBehaviour {
public GUIStyle myStyle;
public int Score=0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Application.ExternalCall("RightQ1"))
Score+= 1;
}
void OnGUI(){
if(Score > 0)
GUI.Box(new Rect(0,0,Screen.width,Screen.height)," ",myStyle);
}
void Awake(){
DontDestroyOnLoad(transform.gameObject);
}
}
And I get this error: Assets/Scripts/Final.cs(16,17): error CS0029: Cannot implicitly convert type void' to
bool' What am I doing wrong?
Answer by _Petroz · May 22, 2011 at 09:46 AM
Assets/Scripts/Final.cs(16,17): error CS0029: Cannot implicitly convert type void' tobool'
The error is line 16:
if(Application.ExternalCall("RightQ1"))
The return type of that function is void:
http://unity3d.com/support/documentation/ScriptReference/Application.ExternalCall.html
You cannot use an if statement with a void function call.
Answer by MrBlahBla0123 · May 23, 2011 at 06:49 PM
Then how do I make it work?
You should use comments ins$$anonymous$$d of answer for this kind of follow on question. You posted a block of a code with an error, I pointed out your error. If you do not understand the code well enough to fix it, you should ins$$anonymous$$d ask a question like "how do I do X" rather than posting broken code. It is not clear what your intention is from the question you posted so I am unable to assist you further.
Your answer
Follow this Question
Related Questions
Login String to Bool Errors 1 Answer
Compile Errors for Script 1 Answer
[Closed] Getting CS0029 error when I try to check position of an object 1 Answer
Getting list music array 1 Answer
iphone keyboard .. 1 Answer