I know this is basic, but I couldn't find the answer. I have a function which should return game object of different types. I like using switch method to describe each type stuff. The error and line it occurs on is shown in the code below:
GameObject getElement(string type)
{
GameObject newGO;
switch(type)
{
case "A":
newGO= functionWhichReturnsGameObjectWithTypeA();
break;
case "B":
newGO= functionWhichReturnsGameObjectWithTypeB();
break;
}
return newGO; // error: Use of unassigned local variable 'newGO'
}
GameObject myGO = getElement("A");