[Editor] Variable is reseting to last manually entered value
I have this script (simplified to the extreme) enabled to run out of play mode.
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class HexTransform : MonoBehaviour {
public string aText;
void LateUpdate () {
print ("His name is: "+aText);
aText = "a";
}
}
I place that script onto a gameObject and enter some text into my variable.
Doing some mundane modifications (e.g. move the object position), the text wil gradually get longer everytime an update is made, working as intended. But in some specific circumstances, any modification made by the script will be lost, and the value will be reverted to what I last manually entered.
The circumstance is:
First, the gameObject has to be an instance of a prefab. I can't figure why it has to, but nothing odd will happen if it isn't.
Secondly, I need to drag a material onto the gameObject, that is different from the gameObject's current material. If I drag the material already in use, nothing odd will happens. So far, I've only seen this happen whilst draging a material onto the gameObject
What am I getting wrong? Is this a bug?
Your answer
![](https://koobas.hobune.stream/wayback/20220612105051im_/https://answers.unity.com/themes/thub/images/avi.jpg)