I have a class that manages a RenderTexture, like so:
public class OceanRenderTexture : MonoBehaviour
{
public RenderTexture renderTexture;
private float multiplier = 1.0f;
void Start()
{
renderTexture.hideFlags = HideFlags.DontSave;
}
void Update()
{
Assert.IsNotNull(renderTexture);
multiplier = GameConfiguration.GetWaterTextureQualityMultiplier(GameConfiguration.Instance.OffscreenTextureQuality);
// The screen resolution may have changed, or the mutiplier setting!
int w = Mathf.FloorToInt(Screen.width * multiplier);
int h = Mathf.FloorToInt(Screen.height * multiplier);
if (renderTexture.width != w || renderTexture.height != h)
{
renderTexture.Release();
renderTexture.width = w;
renderTexture.height = h;
renderTexture.Create();
}
}
}
At runtime, the width and height may need to update. But when this happens, I do not want to incur a change on disk - the change should be disregarded whenever this happens at runtime.
(the reasoning is that we’re getting a lot of git conflicts because of this constantly changing file)
I figured that this would be easy: I’m setting HideFlags.DontSave
in Start()
, but this does not work. The file is still changed on disk after running the game once:
Please note: it’s a deliberate choice not to instantiate a clone at runtime - I have several references to this texture in data files and I do not want to update the references - I’d rather use the original asset.
How can I go about this? Thanks!