summaryrefslogtreecommitdiffstats
path: root/Scripts
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-09-10 17:29:01 -0700
committeryum <yum.food.vr@gmail.com>2023-09-10 17:29:01 -0700
commit3db7723aa5c16358f73e3e8d3bb20a959ce43d5d (patch)
treea2dfa638188a774618d4814ad6b0e02bff511b80 /Scripts
parent4a4909919223a7446944c6248472c7f71a30307c (diff)
Users can now choose custom chatbox texture size in UI
Diffstat (limited to 'Scripts')
-rw-r--r--Scripts/libunity.py11
-rw-r--r--Scripts/remove_audio_sources.py7
-rw-r--r--Scripts/set_texture_sz.py24
3 files changed, 37 insertions, 5 deletions
diff --git a/Scripts/libunity.py b/Scripts/libunity.py
index 39348d4..77eeb95 100644
--- a/Scripts/libunity.py
+++ b/Scripts/libunity.py
@@ -446,7 +446,7 @@ class UnityAnimator():
self.nodes.append(node)
anchor = node.anchor
if anchor == None:
- raise Exception("Node is missing anchor: {}".format(str(node)))
+ anchor = self.allocateId()
if anchor in self.id_to_node:
raise Exception("Duplicate anchor: {}, node 1: {}, node 2: {}".format(anchor, str(node), str(self.id_to_node[anchor])))
self.id_to_node[anchor] = node
@@ -1013,9 +1013,11 @@ def unityYamlToString(nodes):
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
"""[1:][:-1]
- lines.append(preamble)
+ if len(nodes) > 1 or (len(nodes) == 1 and nodes[0].anchor):
+ lines.append(preamble)
for doc in nodes:
- lines.append("--- !u!" + doc.class_id + " &" + doc.anchor)
+ if len(nodes) > 1 or (len(nodes) == 1 and nodes[0].anchor):
+ lines.append("--- !u!" + doc.class_id + " &" + doc.anchor)
lines.append(str(doc))
result = '\n'.join(lines)
@@ -1134,7 +1136,8 @@ class UnityParser:
if self.cur_node == None:
self.cur_node = UnityDocument()
self.cur_node.anchor = event.anchor
- self.cur_node.class_id = anchor_to_class_id[event.anchor]
+ if event.anchor:
+ self.cur_node.class_id = anchor_to_class_id[event.anchor]
else:
self.cur_node = self.cur_node.addChildMapping(self.cur_scalar)
self.pushState(self.MAPPING_START)
diff --git a/Scripts/remove_audio_sources.py b/Scripts/remove_audio_sources.py
index 0b4e566..0486169 100644
--- a/Scripts/remove_audio_sources.py
+++ b/Scripts/remove_audio_sources.py
@@ -1,3 +1,4 @@
+import argparse
import libunity
import sys
@@ -16,5 +17,9 @@ def removeAudioSources(path: str):
f.write(libunity.unityYamlToString(anim.nodes))
if __name__ == "__main__":
- removeAudioSources(sys.argv[1])
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--prefab", type=str, help="Path to .prefab file.")
+ args = parser.parse_args()
+
+ removeAudioSources(args.prefab)
diff --git a/Scripts/set_texture_sz.py b/Scripts/set_texture_sz.py
new file mode 100644
index 0000000..f6fbb45
--- /dev/null
+++ b/Scripts/set_texture_sz.py
@@ -0,0 +1,24 @@
+import argparse
+import libunity
+import sys
+
+def setTextureSize(path: str, size: int):
+ parser = libunity.MulticoreUnityParser()
+ anim = parser.parseFile(path)
+
+ node = anim.nodes[0]
+ node.mapping['TextureImporter'].mapping['maxTextureSize'] = size
+ for plat in node.mapping['TextureImporter'].mapping['platformSettings'].sequence:
+ plat.mapping['maxTextureSize'] = size
+
+ with open(path, "w", encoding="utf-8") as f:
+ f.write(libunity.unityYamlToString(anim.nodes))
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--meta", type=str, help="Path to texture .meta file.")
+ parser.add_argument("--size", type=int, help="Texture size.")
+ args = parser.parse_args()
+
+ setTextureSize(args.meta, args.size)
+