hi i try make fonction for return variable for exemple void ref int check ( ){ return ref variable; }
ref is an argument keyword. You pass a primitive to a method as a reference, not return one. What it is you're trying to do?
Perhaps he's referring to this? https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/ref-returns EDIT: It's a C# 7 feature. Unity's not quite there yet.
ok thank's i try found the easy way to get variable from class via on inspector and go back with him in another fonction what's the unity c# version for information ?
remember your return type is the first word after public or private, so if you put void myfunction(){} It means there is no return.
https://bitbucket.org/alexzzzz/unity-c-5.0-and-6.0-integration/src hi found solution working in unity at this time it's difficulty for import in 2017
Yes, use normal OOP techniques. Getter/Setter would be enough for that, I don't see any benefit from your choice using the ref-keyword in returns (besides that it's not officially supported any way), as it just breaks the encapsulation without any further advantage. If you've got a reference to the object that you'd call your "Cool()" - method on, you could as well just call "SetXYZ(int value)" and the instance would still be in control of the internal logic, validation and assigment. The changes would aswell be reflected in the inspector. Besides that, your int variable is public anyway. This is kinda redundant to having the Cool() method, as you could manipulate it directly. The ref-return feature has got its usages, but this is apparently none of the ones you'd use it for. It's just a way to reference values you don't want to copy all the time directly and IMO you shouldn't expose such a functionality in any way, because literally everyone calling this function and using the result as 'ref local' is able change the state from the outside and corrupt an object's state. It's just evil if used incorrectly.
sure without encapsulation advantage is less fun. what's you call ? "SetXYZ(int value)" and the instance would still be in control of the internal logic