public void ImportPhysics([NotNull] ModelLoadResult loadResult) { SwayAsset.FixSwayReferences(loadResult.HeadSway, loadResult.BodySway); var objectMap = new Dictionary <string, GameObject>(); AddSwayColliders(loadResult.Body, loadResult.BodySway, objectMap); AddSwayColliders(loadResult.Head, loadResult.HeadSway, objectMap); AddSwayBones(loadResult.Body, loadResult.BodySway, objectMap); AddSwayBones(loadResult.Head, loadResult.HeadSway, objectMap); ProcessCollisionIgnores(loadResult, objectMap); }
private static SwayController LoadSwayController([NotNull] string filePath) { SwayController result = null; const string swayEnds = "_sway"; var manager = new AssetsManager(); manager.LoadFiles(filePath); foreach (var assetFile in manager.assetsFileList) { foreach (var obj in assetFile.Objects) { if (obj.type != ClassIDType.TextAsset) { continue; } var textAsset = obj as TextAsset; if (textAsset == null) { throw new ArgumentNullException(nameof(textAsset), "Sway data is null."); } if (!textAsset.m_Name.EndsWith(swayEnds)) { continue; } var raw = textAsset.m_Script; var str = Encoding.UTF8.GetString(raw); str = ReplaceNewLine.Replace(str, "\n"); result = SwayAsset.Parse(str); break; } } return(result); }
public static (SwayController Body, SwayController Head) LoadSwayControllers([NotNull] string bodyFilePath, [NotNull] string headFilePath) { var body = LoadSwayController(bodyFilePath); if (body == null) { throw new ArgumentNullException(nameof(body), "Body sway is null."); } var head = LoadSwayController(headFilePath); if (head == null) { throw new ArgumentNullException(nameof(head), "Head sway is null."); } SwayAsset.FixSwayReferences(body, head); return(Body : body, Head : head); }