private void InspectBundle(BundleBuilderData.BundleInfo bundle) { var bundleName = string.IsNullOrEmpty(bundle.name) ? "(null)" : bundle.name; Block(bundleName, () => { Block("Basic", () => { EditorGUI.BeginChangeCheck(); bundle.note = EditorGUILayout.TextField("Info", bundle.note); bundle.tag = EditorGUILayout.TextField("Tag", bundle.tag); bundle.streamingAssets = EditorGUILayout.Toggle("StreamingAssets", bundle.streamingAssets); bundle.load = (Manifest.BundleLoad)EditorGUILayout.EnumPopup("Load", bundle.load); bundle.type = (Manifest.BundleType)EditorGUILayout.EnumPopup("Type", bundle.type); bundle.priority = EditorGUILayout.IntSlider("Priority", bundle.priority, 0, 10000); if (EditorGUI.EndChangeCheck()) { _data.MarkAsDirty(); } }); Block("Target Assets", () => { EditorGUILayout.BeginHorizontal(); GUILayout.Space(44f); var addObject = EditorGUILayout.ObjectField(null, typeof(Object), false); if (addObject != null) { Defer(() => { bundle.targets.Add(new BundleBuilderData.BundleAssetTarget() { enabled = true, target = addObject, }); }); } EditorGUILayout.EndHorizontal(); var size = bundle.targets.Count; for (var i = 0; i < size; i++) { var target = bundle.targets[i]; EditorGUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("X", GUILayout.Width(20f))) { if (EditorUtility.DisplayDialog("删除", $"确定删除资源项?", "确定", "取消")) { Defer(() => bundle.targets.Remove(target)); } } GUI.color = _GUIColor; EditorGUI.BeginChangeCheck(); target.enabled = EditorGUILayout.Toggle(target.enabled, GUILayout.Width(12f)); EditorGUILayout.ObjectField(target.target, typeof(Object), false); target.platform = (PackagePlatform)EditorGUILayout.EnumPopup(target.platform); if (EditorGUI.EndChangeCheck()) { _data.MarkAsDirty(); } EditorGUILayout.EndHorizontal(); } }); Block("Bundle Splits", () => { for (int splitIndex = 0, splitCount = bundle.splits.Count; splitIndex < splitCount; splitIndex++) { var split = bundle.splits[splitIndex]; var splitName = string.IsNullOrEmpty(split.name) ? "(default)" : split.name; Foldout(splitName, () => { var sliceCount = split.slices.Count; EditorGUI.BeginChangeCheck(); var duplicated = IsDuplicated(bundle, split); if (duplicated) { GUI.color = Color.yellow; split.name = EditorGUILayout.TextField( Text("bundle.split.name", "Name", "warning: duplicated bundle split name"), split.name); GUI.color = _GUIColor; } else { split.name = EditorGUILayout.TextField("Name", split.name); } split.encrypted = EditorGUILayout.Toggle("Encrypted?", split.encrypted); split.sliceObjects = EditorGUILayout.IntField("Slice Objects", split.sliceObjects); if (EditorGUI.EndChangeCheck()) { _data.MarkAsDirty(); } InspectRules(split.rules); var validIndex = 0; for (var sliceIndex = 0; sliceIndex < sliceCount; sliceIndex++) { var slice = split.slices[sliceIndex]; var assetCount = slice.assetGuids.Count; if (assetCount > 0) { validIndex++; Block("Slices", () => { var sliceName = slice.name; if (sliceCount > 1) { sliceName = string.Format("[{0}] {1}/{2}: {3}", validIndex, sliceIndex + 1, sliceCount, sliceName); } if (slice.streamingAssets) { GUI.color = Color.green; } EditorGUILayout.LabelField(sliceName); var intent = 40f; EditorGUILayout.BeginHorizontal(); GUILayout.Space(intent); EditorGUILayout.BeginVertical(); EditorGUI.BeginDisabledGroup(true); // var nStreamingAssets = EditorGUILayout.Toggle("StreamingAssets", slice.streamingAssets); // if (nStreamingAssets != slice.streamingAssets) // { // slice.streamingAssets = nStreamingAssets; // _data.MarkAsDirty(); // } EditorGUILayout.EnumPopup("Platform", slice.platform); EditorGUI.EndDisabledGroup(); for (var assetIndex = 0; assetIndex < assetCount; assetIndex++) { var assetGuid = slice.assetGuids[assetIndex]; EditorGUILayout.BeginHorizontal(); BundleBuilderWindow.DrawSingleAssetAttributes(_data, assetGuid); if (GUILayout.Button("?", GUILayout.Width(20f))) { BundleBuilderWindow.DisplayAssetAttributes(assetGuid); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); GUI.color = _GUIColor; }, () => { GUI.color = Color.magenta; var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f)); rect.y -= 2f; rect.height += 1f; if (GUI.Button(rect, Text("reconstruct.split.slice", "❃", "重构分包切分"))) { if (EditorUtility.DisplayDialog("重构", $"确定重构分包切分?", "确定", "取消")) { Defer(() => { slice.Reset(); BundleBuilder.Scan(_data); _data.MarkAsDirty(); }); } } GUI.color = _GUIColor; }, () => { GUI.color = Color.red; var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f)); rect.y -= 2f; rect.height += 1f; if (GUI.Button(rect, Text("delete.split.slice", "X", "删除分包切分"))) { if (EditorUtility.DisplayDialog("删除", $"确定删除分包切分?", "确定", "取消")) { Defer(() => { split.slices.Remove(slice); BundleBuilder.Scan(_data); _data.MarkAsDirty(); }); } } GUI.color = _GUIColor; }); } } }, () => { GUI.color = Color.yellow; var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f)); rect.y -= 2f; rect.height += 1f; EditorGUI.BeginDisabledGroup(splitIndex == 0); if (GUI.Button(rect, Text("moveup.split", "▲", "向前移动"))) { var newSplitIndex = splitIndex - 1; Defer(() => { bundle.splits.Remove(split); bundle.splits.Insert(newSplitIndex, split); _data.MarkAsDirty(); }); } EditorGUI.EndDisabledGroup(); GUI.color = _GUIColor; }, () => { GUI.color = Color.yellow; var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f)); rect.y -= 2f; rect.height += 1f; EditorGUI.BeginDisabledGroup(splitIndex == splitCount - 1); if (GUI.Button(rect, Text("movedown.split", "▼", "向后移动"))) { var newSplitIndex = splitIndex + 1; Defer(() => { bundle.splits.Remove(split); bundle.splits.Insert(newSplitIndex, split); _data.MarkAsDirty(); }); } EditorGUI.EndDisabledGroup(); GUI.color = _GUIColor; }, () => { GUI.color = Color.magenta; var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f)); rect.y -= 2f; rect.height += 1f; if (GUI.Button(rect, Text("reconstruct.split", "❃", "重构分包"))) { if (EditorUtility.DisplayDialog("重构", $"确定重构分包?", "确定", "取消")) { Defer(() => { split.Reset(); BundleBuilder.Scan(_data); _data.MarkAsDirty(); }); } } GUI.color = _GUIColor; }, () => { GUI.color = Color.red; var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f)); rect.y -= 2f; rect.height += 1f; if (GUI.Button(rect, Text("delete.split", "X", "删除分包"))) { if (EditorUtility.DisplayDialog("删除", $"确定删除分包?", "确定", "取消")) { Defer(() => { bundle.splits.Remove(split); _data.MarkAsDirty(); }); } } GUI.color = _GUIColor; }); } }, () => { GUI.color = Color.green; var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(20f)); rect.y -= 2f; rect.height += 1f; if (GUI.Button(rect, Text("add.split", "+", "添加分包"))) { Defer(() => { var newSplit = new BundleBuilderData.BundleSplit(); bundle.splits.Add(newSplit); _data.MarkAsDirty(); }); } GUI.color = _GUIColor; }); }); }