Hi,
I try to create a Button in WorldSpace. The Button is triggered by a Raycast when the Player press the LMB.
Then a function is called, that call the Action Function, which I have defined in public variables.
The Variables :
public MonoBehaviour ButtonActionClass;
public string FunctionName;
public float FunctionDelayTime = 0.0f;
The Function:
public void TriggerButton ()
{
if(!hasCondition)
{
ButtonActionClass.Invoke(FunctionName,FunctionDelayTime);
}
}
This code works pretty well, but the problem is that I can’t add parameters with this Invoke function.
So I tried something different :
public void TriggerButton ()
{
if(!hasCondition)
{
// ObjArray is a private Object[] ObjArray; in which I've added a few Variables
ButtonActionClass.GetType().GetMethod(FunctionName).Invoke(FunctionName,ObjArray);
}
}
But the Problem is that I have to replace every Target Function parameters to an Object and convert them, if this is possible at all.
So I hope that a solution can be found.
PS : Sorry for my English