summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-09-01 00:51:32 -0700
committeryum <yum.food.vr@gmail.com>2023-09-01 00:51:32 -0700
commit749854018ff279e3aadd60d89ac7354886d1630d (patch)
tree20db682b52919f72fd138d8123ecb6b189bfeb16
parent833ef96f677a60197abb417651ac306820e225f0 (diff)
Check in app_config.py, remove_audio_source.py
Oops, I meant to check these in earlier!
-rw-r--r--Scripts/app_config.py39
-rw-r--r--Scripts/remove_audio_sources.py20
2 files changed, 59 insertions, 0 deletions
diff --git a/Scripts/app_config.py b/Scripts/app_config.py
new file mode 100644
index 0000000..f911456
--- /dev/null
+++ b/Scripts/app_config.py
@@ -0,0 +1,39 @@
+import os
+import sys
+import typing
+
+def getConfig(path: str) -> typing.Dict[str, typing.Union[str, float, int, bool]]:
+ # Helper functions to detect and convert the type
+ def is_int(value: str) -> bool:
+ try:
+ int(value)
+ return True
+ except ValueError:
+ return False
+
+ def is_float(value: str) -> bool:
+ try:
+ float(value)
+ return True
+ except ValueError:
+ return False
+
+ def convert_value(key: str, value: str):
+ if key.startswith(("enable_", "remove_", "use_", "clear_")):
+ return bool(int(value))
+ elif is_int(value):
+ return int(value)
+ elif is_float(value):
+ return float(value)
+ else:
+ return value
+
+ config = {}
+ with open(path, 'r') as file:
+ for line in file:
+ key_value = line.strip().split(": ", maxsplit=1)
+ key = key_value[0]
+ value = key_value[1] if len(key_value) > 1 else ""
+ config[key] = convert_value(key, value.strip())
+ return config
+
diff --git a/Scripts/remove_audio_sources.py b/Scripts/remove_audio_sources.py
new file mode 100644
index 0000000..0b4e566
--- /dev/null
+++ b/Scripts/remove_audio_sources.py
@@ -0,0 +1,20 @@
+import libunity
+import sys
+
+def removeAudioSources(path: str):
+ parser = libunity.MulticoreUnityParser()
+ anim = parser.parseFile(path)
+ anchors = set()
+ node = anim.popNodeOfClass("82")
+ while node:
+ print("Killed audio source")
+ anchors.add(node.anchor)
+ node = anim.popNodeOfClass("82")
+ for node in anim.nodes:
+ anim.scrubReferencesByValue(node, values=anchors)
+ with open(path, "w", encoding="utf-8") as f:
+ f.write(libunity.unityYamlToString(anim.nodes))
+
+if __name__ == "__main__":
+ removeAudioSources(sys.argv[1])
+