示例#1
0
def updateNavMeshParamsForScene(scene_file_name):
    pprint("Updating file '{}'...".format(scene_file_name))
    doc = UnityDocument.load_yaml(scene_file_name)
    for entry in doc.entries:
        if entry.__class__.__name__ == 'NavMeshSettings':
            # print(entry.__class__.__name__)
            buildSettings = getattr(entry, 'm_BuildSettings', None)
            # pprint(buildSettings)
            buildSettings['agentRadius'] = '0.175'
            buildSettings['agentHeight'] = '1.1'
            buildSettings['agentClimb'] = '0.5'
            buildSettings['manualCellSize'] = '0'
            buildSettings['cellSize'] = '0.058333334'

    doc.dump_yaml()
示例#2
0
def updateNavMeshParamsForScene(scene_file_name):
    pprint("Updating file '{}'...".format(scene_file_name))
    doc = UnityDocument.load_yaml(scene_file_name)
    for entry in doc.entries:
        if entry.__class__.__name__ == "NavMeshSettings":
            # print(entry.__class__.__name__)
            buildSettings = getattr(entry, "m_BuildSettings", None)
            # pprint(buildSettings)
            buildSettings["agentRadius"] = "0.2"
            buildSettings["agentHeight"] = "1.8"
            buildSettings["agentClimb"] = "0.5"
            buildSettings["manualCellSize"] = "1"

            buildSettings["cellSize"] = "0.03"

    doc.dump_yaml()
#finds the guids of all the files

import json
import os
guids = {}
from unityparser import UnityDocument

import helper

projectDirectory = "/media/ramiro/DATA/User/Desktop/InMotion/Inmotion--Jogo/InMotion_GameFiles/Assets"
excludedDirectories = ["Library", "UniGLTF", "Assets\\Orbbec\\Scripts"]

paths, files = helper.getFiles(projectDirectory,
                               ext=".meta",
                               excludedDirectories=excludedDirectories)

for p, f in zip(paths, files):
    doc = UnityDocument.load_yaml(os.path.join(p, f))
    guids[doc.entry["guid"]] = (p, f[0:len(f) - len(".meta")])

with open("guids.json", "w") as f:
    json.dump(guids, f)
print("Done!")
 def normalize(self, input, output):
     doc = UnityDocument.load_yaml(input)
     for entry in doc.entries:
         entry.__dict__ = dict(sorted(entry.__dict__.items()))
     doc.dump_yaml(output)
from unityparser import UnityDocument

import argparse
import os

parser = argparse.ArgumentParser(description='Add ROS define symbols')
parser.add_argument('ros', type=str, help='ROS version: ros1 or ros2')

project_settings_filepath = os.path.join(".", "tutorials", "pick_and_place", "PickAndPlaceProject", "ProjectSettings", "ProjectSettings.asset")
if not os.path.exists(project_settings_filepath):
    raise FileNotFoundError("Not found %s".format(project_settings_filepath))
settings = UnityDocument.load_yaml(project_settings_filepath)
symbols = settings.entries[0].scriptingDefineSymbols

args = parser.parse_args()
if args.ros == "ros1":
		if symbols[1] is None:
				symbols[1] = "ROS1"
		else:
				symbols[1] += ";ROS1"
elif args.ros == "ros2":
		if symbols[1] is None:
				symbols[1] = "ROS2"
		else:
				symbols[1] += ";ROS2"
else:
    raise ValueError("Invalid input ROS version. Must be either ros1 or ros2")
settings.dump_yaml(project_settings_filepath)