I searched a bit, but I cannot find a way to save the link to another variable in a specific variable. I am trying to make a class to undo the actions made by the user;
class UndoAction
{
public object var;
public object val;
public UndoAction(ref object var, object val)
{
this.var = var;
this.val = val;
}
public static List<UndoAction> history = new List<UndoAction>();
public static void AddHistory(ref object var, object val)
{
history.Add(new UndoAction(ref var, val));
}
}
I think you can see what I'm trying to achieve here.
The problem I am facing is
this.var = var;
does not store the link, but the value of the reference 'var'. How can I save the link, so I can just run;
this.var = val;
"cancel" action, in my case?
source
share