bool IsNew(UndoObjectInfo obj, int spot) { if (StoredObject.Count <= 0) { return(true); } UndoObjectInfo LastObj = StoredObject[spot - 1]; if (LastObj.Object == obj.Object) { if (LastObj.Name.Equals(obj.Name) && LastObj.Position == obj.Position && LastObj.Rotation == obj.Rotation && LastObj.Material == obj.Material) { return(false); } else { return(true); } } else { return(true); } }
public void Store(GameObject gameObj, int spot) { NewObject = false; UndoObjectInfo obj = new UndoObjectInfo(); obj.Object = gameObj; obj.Name = gameObj.name; obj.Position = gameObj.transform.position; obj.Scale = gameObj.transform.localScale; obj.Rotation = gameObj.transform.rotation; if (gameObj.GetComponent <Renderer>()) { obj.Material = gameObj.GetComponent <Renderer>().material; } if (gameObj.GetComponent <MeshFilter>()) { obj.Mesh = gameObj.GetComponent <MeshFilter>().mesh; } NewObject = IsNew(obj, spot); if (NewObject == true) { spot = SetSpot(spot); StoredObject.Insert(spot - 1, obj); } }