- Home /
Question by
Ochreous · Sep 11, 2012 at 11:40 PM ·
c#selectiongrid
How to insert an if statement for Selection Grid C#
Is there a way to insert an if statement for a Selection Grid? When I try to put in an if statement for this selection grid I get this error cannot implicitly convert type "int" to bool.
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public int intTest;
public int selectionGridInt = 0;
public string[] selectionStrings = {"Grid 1", "Grid 2", "Grid 3", "Grid 4"};
void update(){
if(selectionGridInt = 1){//error cannot implicitly convert type "int" to bool
++intTest;
}
}
void OnGUI () {
selectionGridInt = GUI.SelectionGrid (new Rect (25, 25, 100, 60), selectionGridInt, selectionStrings, 1);
}
}
Comment
Best Answer
Answer by DaveA · Sep 12, 2012 at 12:53 AM
if(selectionGridInt = 1) is an assignment within a conditional test. While legal C, it's really not good practice and I believe gives error you see. Try == instead of =
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer
Case structor in C# Unity 1 Answer
My unit won't stop moving (RTS) 0 Answers
Player lives script help 1 Answer