How can I do something similar to the following.
I have a Function that modifys an int. For simplicity sake, lets say it generates a random number.
static int GenRand()
{
Random random = new Random();
return( random.Next(0, 100));
}
Now instead of returning a random number I want to pass a property of an object. For example Go.transform.position.x or Go.light.intensity.
(I’m aware the following does not work)
static void GenRand(ref int PropertyToChange)
{
Random random = new Random();
PropertyToChange = random.Next(0, 100));
}
GenRand(ref Go.transform.position.x);
My actual need is far more complex, but I’m looking for a general way to pass a arbitrary property to an function and have it modified by the result.
In other languages I would use a pointer(can’t to my knowledge in Unity), or by reference.
Any thoughts?