I know a similar question has been asked, right here, but i dont have a static variable in my class. My class is such:
class InventoryItem
{
public var Name : String;
public var Type : String;
public var Info : String;
public var Price : int;
public var StackCap : int;
public var Rarity : String;
public var Amount:int;
public var worldObject : GameObject;
public var texRepresentation : Texture2D;
public var texSaved:Texture2D;
public var Selected:boolean=false;
public var HoveringItem:boolean=false;
}
but later when i try to add items to my inventory, and change the Amount variable, it changes on any other one i’m working with. Is there a way to fix this other then typing out, NewItem.Name=OldItem.Name for every single variable?
edit:
the error occures around a line similar to this.
var NewItem=new InventoryItem();
NewItem=item;
NewItem.Amount=item.StackCap;
item.Amount=RepeatAmount; // where repeat amount is = to leftover amount
so changing the item.Amount changes the NewItem.Amount too, and thats my issue.