From ac69366dccaf377d20f029b4b58bac2314f61159 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 20 Dec 2022 18:21:59 -0800 Subject: Bugfix: animators may now include Unicode characters Completed first end-to-end test on a third party avatar :) --- Scripts/libtastt.py | 18 +++++++++--------- Scripts/libunity.py | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'Scripts') diff --git a/Scripts/libtastt.py b/Scripts/libtastt.py index cc9c751..9efd0e9 100644 --- a/Scripts/libtastt.py +++ b/Scripts/libtastt.py @@ -181,11 +181,11 @@ def generateClearAnimation(anim_dir, guid_map): anim_name = generate_utils.getClearAnimationName() anim_path = os.path.join(anim_dir, anim_name + ".anim") print("Generating clear animation at {}".format(anim_path)) - with open(anim_path, "w") as f: + with open(anim_path, "w", encoding="utf-8") as f: f.write(libunity.unityYamlToString([anim_node])) # Generate metadata meta = libunity.Metadata() - with open(anim_path + ".meta", "w") as f: + with open(anim_path + ".meta", "w", encoding="utf-8") as f: f.write(str(meta)) # Add metadata to guid map guid_map[anim_path] = meta.guid @@ -224,11 +224,11 @@ def generateToggleAnimations(anim_dir, shader_param, guid_map): anim_suffix = "_On" anim_path = os.path.join(anim_dir, shader_param + anim_suffix + ".anim") - with open(anim_path, "w") as f: + with open(anim_path, "w", encoding="utf-8") as f: f.write(libunity.unityYamlToString([anim_node])) # Generate metadata meta = libunity.Metadata() - with open(anim_path + ".meta", "w") as f: + with open(anim_path + ".meta", "w", encoding="utf-8") as f: f.write(str(meta)) # Add metadata to guid map guid_map[anim_path] = meta.guid @@ -264,11 +264,11 @@ def generateFloatAnimation(anim_name: str, anim_dir: str, # Serialize animation to file anim_path = os.path.join(anim_dir, anim_name + ".anim") - with open(anim_path, "w") as f: + with open(anim_path, "w", encoding="utf-8") as f: f.write(libunity.unityYamlToString([anim_node])) # Generate metadata meta = libunity.Metadata() - with open(anim_path + ".meta", "w") as f: + with open(anim_path + ".meta", "w", encoding="utf-8") as f: f.write(str(meta)) # Add metadata to guid map guid_map[anim_path] = meta.guid @@ -321,11 +321,11 @@ def generateAnimations(anim_dir, guid_map): clip.mapping['m_EditorCurves'].sequence.append(curve) # Serialize animation to file anim_path = os.path.join(anim_dir, anim_name + ".anim") - with open(anim_path, "w") as f: + with open(anim_path, "w", encoding="utf-8") as f: f.write(libunity.unityYamlToString([node])) # Generate metadata meta = libunity.Metadata() - with open(anim_path + ".meta", "w") as f: + with open(anim_path + ".meta", "w", encoding="utf-8") as f: f.write(str(meta)) # Add metadata to guid map guid_map[anim_path] = meta.guid @@ -583,7 +583,7 @@ if __name__ == "__main__": with open(args.guid_map, 'rb') as f: guid_map = pickle.load(f) os.makedirs(os.path.dirname(args.fx_dest), exist_ok=True) - with open(args.fx_dest, "w") as f: + with open(args.fx_dest, "w", encoding="utf-8") as f: f.write(str(generateFX(guid_map, args.gen_anim_dir))) with open(args.guid_map, 'wb') as f: pickle.dump(guid_map, f) diff --git a/Scripts/libunity.py b/Scripts/libunity.py index 0c5228a..9ab0f19 100644 --- a/Scripts/libunity.py +++ b/Scripts/libunity.py @@ -1145,7 +1145,7 @@ class UnityParser: class MulticoreUnityParser: def parseFile(self, yaml_file): yaml_str = "" - with open(yaml_file, "r") as f: + with open(yaml_file, "r", encoding="utf-8") as f: yaml_str = f.read() return self.parse(yaml_str) @@ -1211,7 +1211,7 @@ class MulticoreUnityParser: def parseFile(self, yaml_file): yaml_str = "" - with open(yaml_file, "r") as f: + with open(yaml_file, "r", encoding="utf-8") as f: yaml_str = f.read() return self.parse(yaml_str) @@ -1225,7 +1225,7 @@ def getGuidMap(d): continue suffix = ".meta" if path.endswith(suffix): - with open(path, "r") as f: + with open(path, "r", encoding="utf-8") as f: for line in f: if line.startswith("guid"): guid = line.split()[1] @@ -1271,7 +1271,7 @@ if __name__ == "__main__": anim0.merge(anim1) print("Serializing to {}".format(args.fx_dest), file=sys.stderr) - with open(args.fx_dest, "w") as f: + with open(args.fx_dest, "w", encoding="utf-8") as f: f.write(unityYamlToString(anim0.nodes)) elif args.cmd == "guid_map": @@ -1355,7 +1355,7 @@ if __name__ == "__main__": guid_map) print("Serializing to {}".format(args.fx_dest), file=sys.stderr) - with open(args.fx_dest, "w") as f: + with open(args.fx_dest, "w", encoding="utf-8") as f: f.write(str(anim)) with open(args.guid_map, 'wb') as f: @@ -1388,7 +1388,7 @@ if __name__ == "__main__": anim.setNoopAnimations(guid_map, args.gen_anim_dir + "/TaSTT_Do_Nothing.anim") - with open(args.fx_dest, "w") as f: + with open(args.fx_dest, "w", encoding="utf-8") as f: f.write(str(anim)) else: -- cgit v1.2.3