I've been searching around a bit, but I can't find any way to store a reference to another variable in a certain variable. I'm trying to make a class to undo things done 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 guess you can see what I'm trying to achieve here.
The problem I ran on;
this.var = var;
doesn't store the reference, but the value of the referenced 'var'. How can I store the reference itself, so I can simply run;
this.var = val;
to "undo" an action, in my case?