private void ApplyMold(GameObject go, BakingMold mold, bool includeChildren) { Undo.RecordObject(go, "Apply baking mold"); mold.staticFlags.TryApply(go); if (go.TryGetComponent <MeshRenderer>(out var renderer)) { mold.castShadows.TryApply(renderer); mold.lightmapScale.TryApply(renderer); mold.stitchSeams.TryApply(renderer); mold.navMeshArea.TryApply(renderer); } if (includeChildren) { for (int i = 0; i < go.transform.childCount; i++) { var child = go.transform.GetChild(i).gameObject; ApplyMold(child, mold, true); } } }
// Add Shortcut possibility to each mold private void OnApplyButtonClicked(BakingMold mold) { ShowNotification(new GUIContent($"{mold.name} Applied")); var includeChildren = GetShouldIncludeChildren(Selection.gameObjects); foreach (var go in Selection.gameObjects) { switch (includeChildren) { default: case ShouldIncludeChildren.Cancel: return; case ShouldIncludeChildren.HasNoChildren: case ShouldIncludeChildren.DontIncludeChildren: ApplyMold(go, mold, false); break; case ShouldIncludeChildren.IncludeChildren: ApplyMold(go, mold, true); break; } } }