True. A value is returned before it’s incremented. Now that’s just silly 
@OP why not simply return a + 1;
? It’s completely meaningless the way it is.
Refrain from doing fancy operations until you get a good grip what’s going on with them.
We’re using ++ and – when we want to store the changed value back.
And it matters whether it comes before or after a variable. As Bunny83 said, there is a prefix variant along with the suffix one. Obviously, because we want to store the changed value back, you can’t use any of these on the expression, because they apply only to variables.
However, even though you’ve managed to change the original variable a, you’ve failed to notice two things:
- As Bunny83 observed, the change was practically ignored, because it comes after return.
- Even if you’d change this to pre-increment, the change would be ignored, because a is declared as a primitive value, and these are passed by value.
using UnityEngine;
public class MyClass : MonoBehaviour {
void Start() {
int a = 5;
MyIncrMethod(a);
Debug.Log(a); // 5
}
int MyIncrMethod(int a) {
a++;
}
}
If we add return, obviously we can capture the value and get it back, but that doesn’t change the fact that a stays the same.
using UnityEngine;
public class MyClass : MonoBehaviour {
void Start() {
int w = 5;
w = MyIncrMethod(w);
Debug.Log(w); // 6
}
int MyIncrMethod(int a) { // the value here is just a copy, because the argument is passed by value
a++; // this operation doesn't work on the original location in memory
return a; // we now capture locally incremented 'a' and return it
}
// this will also work
// int MyIncrMethod(int a) {
// return ++a;
// }
}
we could’ve just as well used return a + 1 for the same result
(this is, in fact, recommended in this case, why assigning something back if it’s going to be wasted?)
using UnityEngine;
public class MyClass : MonoBehaviour {
void Start() {
int w = 5; // notice the different names between two contexts?
w = MyIncrMethod(w); // any relationship ends here
Debug.Log(w); // 6
}
int MyIncrMethod(int a) {
return a + 1;
}
}
There is a way however to change the primitive value from inside the method
using UnityEngine;
public class MyClass : MonoBehaviour {
void Start() {
int w = 5;
MyIncrMethod(ref w); // the argument is now passed by reference
Debug.Log(w); // 6
}
void MyIncrMethod(ref int a) {
a++;
}
}