public void BuildObjects(GameObject colliderRoot) { SpringColliderSetup.DestroySpringColliders(colliderRoot); var allChildren = colliderRoot.BuildNameToComponentMap <Transform>(true); SetupDynamicsNulls(colliderRoot, allChildren, dynamicsNullRecords); // New objects may have been created by SetupDynamicNulls, so retrieve all the children again allChildren = colliderRoot.BuildNameToComponentMap <Transform>(true); foreach (var record in colliderRecords) { SetupColliderFromRecord(colliderRoot, allChildren, record); } }
public static ParsedSpringBoneSetup ReadSpringBoneSetupFromText ( GameObject springBoneRoot, GameObject colliderRoot, string recordText, IEnumerable <string> inputValidColliderNames ) { List <TextRecordParsing.Record> rawSpringBoneRecords = null; List <TextRecordParsing.Record> rawPivotRecords = null; try { var sourceRecords = TextRecordParsing.ParseRecordsFromText(recordText); TextRecordParsing.Record versionRecord = null; GetVersionFromSetupRecords(sourceRecords, out versionRecord); rawSpringBoneRecords = TextRecordParsing.GetSectionRecords(sourceRecords, "SpringBones"); if (rawSpringBoneRecords == null || rawSpringBoneRecords.Count == 0) { rawSpringBoneRecords = TextRecordParsing.GetSectionRecords(sourceRecords, null) .Where(item => item != versionRecord) .ToList(); } rawPivotRecords = TextRecordParsing.GetSectionRecords(sourceRecords, "Pivots"); } catch (System.Exception exception) { Debug.LogError("SpringBoneSetup: 元のテキストデータを読み込めませんでした!\n\n" + exception.ToString()); return(null); } var hasErrors = false; var errors = new List <TextRecordParsing.Record>(); var pivotRecords = SerializePivotRecords(rawPivotRecords, errors); var springBoneRecords = SerializeSpringBoneRecords(rawSpringBoneRecords, errors); if (errors.Count > 0) { hasErrors = true; } var validObjectNames = springBoneRoot.GetComponentsInChildren <Transform>(true) .Select(item => item.name) .Distinct() .ToList(); var validPivotRecords = new List <PivotSerializer>(); if (!VerifyPivotRecords(pivotRecords, validObjectNames, validPivotRecords)) { hasErrors = true; } var validPivotNames = new List <string>(validObjectNames); validPivotNames.AddRange(validPivotRecords.Select(record => record.name)); var validColliderNames = new List <string>(); var colliderTypes = SpringColliderSetup.GetColliderTypes(); validColliderNames.AddRange(colliderTypes .SelectMany(type => colliderRoot.GetComponentsInChildren(type, true)) .Select(item => item.name)); if (inputValidColliderNames != null) { validColliderNames.AddRange(inputValidColliderNames); } var validSpringBoneRecords = new List <SpringBoneSerializer>(); bool hasMissingColliders; if (!VerifySpringBoneRecords( springBoneRecords, validObjectNames, validPivotNames, validColliderNames, validSpringBoneRecords, out hasMissingColliders)) { hasErrors = true; } if (hasMissingColliders) { Debug.LogWarning("スプリングボーンセットアップ:一部のコライダーが見つかりません"); } return(new ParsedSpringBoneSetup { HasErrors = hasErrors, pivotRecords = validPivotRecords, springBoneRecords = validSpringBoneRecords }); }