summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-10-16 18:30:08 -0700
committeryum <yum.food.vr@gmail.com>2022-10-16 18:30:08 -0700
commit81e18d7f725c7215cdafdf80adf7bf114be1a811 (patch)
tree5df0c14ed8530155ee9bc4d7de5b438ebc2fec91
parentd63c2a77b740006832d10a968f0c7f88b3efc284 (diff)
Programmatically set noop animation
Overwrite any animation containing an unknown GUID to the tastt noop animation. This seems to help the reset layer function properly.
-rw-r--r--libunity.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/libunity.py b/libunity.py
index c850f1a..2e375af 100644
--- a/libunity.py
+++ b/libunity.py
@@ -846,6 +846,25 @@ class UnityAnimator():
on_to_off = self.addTransition(off_anim.anchor)
self.addTransitionBooleanCondition(on_anim, on_to_off, toggle_param, False)
+ def setNoopAnimations(self, guid_map, noop_anim_path):
+ noop_anim_meta = Metadata()
+ noop_anim_meta.load(noop_anim_path)
+
+ for node in self.nodes:
+ if classId(node.anchor) != "1102":
+ continue
+ motion = node.mapping['AnimatorState'].mapping['m_Motion']
+ replace = False
+ if not "guid" in motion.mapping.keys():
+ replace = True
+ elif not motion.mapping["guid"] in guid_map:
+ replace = True
+ if not replace:
+ continue
+ motion.mapping["fileID"] = "7400000"
+ motion.mapping["guid"] = noop_anim_meta.guid
+ motion.mapping["type"] = "2"
+
def unityAnimatorToString(nodes):
lines = []
preamble = """
@@ -1178,6 +1197,24 @@ if __name__ == "__main__":
anim = parser0.parseFile(args.fx0)
print(str(anim))
+ elif args.cmd == "set_noop_anim":
+ if not args.fx0 or not args.guid_map:
+ print("--fx0 and --guid_map required")
+ parser.print_help()
+ parser.exit(1)
+
+ guid_map = {}
+ with open(args.guid_map, 'rb') as f:
+ guid_map = pickle.load(f)
+
+ print("Parsing {}".format(args.fx0), file=sys.stderr)
+ parser = MulticoreUnityParser()
+ anim = parser.parseFile(args.fx0)
+
+ anim.setNoopAnimations(guid_map, "Animations/TaSTT_Do_Nothing.anim")
+
+ print(str(anim))
+
else:
print("Unrecognized command: {}".format(args.cmd))