Not all code paths return a value (145391)

He I have just tried to code and I am running into a issue.

Assets/Side Button/Sliders.cs(25,21): error CS0161: `Sliders.button11()': not all code paths return a value

My code is as follows:

public bool button11(){
		personalprofile.SetActive (true);
		worked.SetActive (false);
		design.SetActive (false);
		producer.SetActive (false);
		developer.SetActive (false);
		aditionalinfo.SetActive (false);
	}

Methods have a return value. Writing a method public bool button11() is telling the machine that you have a public method called button11 that returns a bool. However you are not returning a value so your compiler is confused why you told it to expect a bool. Either change the return type to void, i.e. public void button11(){ or return a value in the method, i.e. return false; https://msdn.microsoft.com/en-us/library/ms173114.aspx

1 Answer

1

You’ve got your method to return a boolean value, and you don’t have a return statement. Change it to:

 public void button11(){
         personalprofile.SetActive (true);
         worked.SetActive (false);
         design.SetActive (false);
         producer.SetActive (false);
         developer.SetActive (false);
         aditionalinfo.SetActive (false);
     }