Hey, there!
I have a bunch of variables that I need to change to different names.
Currently they’re ordered and stored in a scriptable object ‘data’ and held in my character objects as vars.
I’m replacing all of the .cs file instances of vars with the name held in data*.*
My code abstract is…
foreach(string assetPath in AssetDatabase.GetAllAssetPaths())
for(int v = 0; v < data.Count; v++)
string findText = “vars[” + i.tostring + “]”;
string replaceText = data*.name;*
string finalFile = File.ReadAllText(assetPath);
finalFile = finalFile.Replace(findText, replaceText);
File.WriteAllText(finalFile)
It finds all the instances of vars in each file perfectly fine (the actual code finds all instances of vars in the file first), but when I try to replace them with string.Replace or Regex.Replace it doesn’t work.
When I change replace text to something without numbers it seems to work.
What am I doing wrong?