I got this warning on several functions. I read in Unity Answes that I should define the type that the function returns (I don’t know why, all the other functions work properly without type defining). So this is the function:
function Axis(){
if(type == SBIType.Key) return axisInterpolation;
else if(type == SBIType.Axis){
if(positive != "" negative != "") return (Input.GetAxisRaw(positive) + Input.GetAxisRaw(negative))/2;
else if(positive != "") return Input.GetAxisRaw(positive)*1.0f;
else if(negative != "")return Input.GetAxis(negative)*1.0f;
} else return 0.0f;
}
The warning won’t go away even if I define the return type:
function Axis() : float{ ...
Also if I make the function like that:
function Axis() : float{
var axis : float = 0.0f;
if(type == SBIType.Key) axis = axisInterpolation;
else if(type == SBIType.Axis){
if(positive != "" negative != "") axis = (Input.GetAxisRaw(positive) + Input.GetAxisRaw(negative))/2;
else if(positive != "") axis = Input.GetAxisRaw(positive)*1.0f;
else if(negative != "")axis = Input.GetAxis(negative)*1.0f;
}
return axis;
}
The warning will disappear…
I want to know what’s actually happening here. Can somebody shed some light ?
Cheers!