After using Texture2D.SetPixel and Apply, can't reset texture using SetTexture

First I am storing a texture in a global variable, in Start():

private Texture2D tex1;
tex1 = (Texture2D)GameObject.Find(“plane1”).GetComponent().material.GetTexture(“_MainTex”);

Then I execute some code like this to apply a border to the texture, when a key is pressed:

var borderColor = new Color(1, 0, 0, 1);
for (int x = 0; x < image.width; x++) {
for (int y = 0; y < image.height; y++) {
if (x < borderWidth || x > image.width - 1 - borderWidth) image.SetPixel(x, y, borderColor);
else if (y < borderWidth || y > image.height - 1 - borderWidth) image.SetPixel(x, y, borderColor);
}
}
image.Apply();

That code works.

Then later, upon a different keypress, I try to load the original texture back again with:

GameObject.Find(“plane1”).GetComponent().material.SetTexture(“_MainTex”, tex1);

This doesn’t work.

Please help if you have some clue why. I’ve been googling, trying things, rinsing-and-repeating for hours now. Going a litle crazy.

Please use code tags when posting code so it’s easier to read: Using code tags properly

Where does your image variable come from? Could it be that it points to the same texture as tex1, so your border code is changing your original texture and not a copy of it?