public override void OnInspectorGUI() { ConnectionGUI con = target as ConnectionGUI; if (m_groupViewController == null) { m_groupViewController = new GroupViewController(con.AssetGroupViewContext); } if (con == null) { return; } var count = 0; var assetGroups = con.AssetGroups; if (assetGroups == null) { return; } foreach (var assets in assetGroups.Values) { if (assets == null) { continue; } count += assets.Count; } var groupCount = assetGroups.Keys.Count; GUILayout.Label("Stats", "BoldLabel"); EditorGUILayout.LabelField("Total groups", groupCount.ToString()); EditorGUILayout.LabelField("Total items", count.ToString()); GUILayout.Space(8f); m_groupViewController.SetGroups(assetGroups); m_groupViewController.OnGroupViewGUI(); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_groupSizeByte == null) { return; } EditorGUILayout.HelpBox("Grouping by size: Create group of assets by size.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_groupSizeByte.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Grouping Size Settings", node, true)){ if (enabled) { m_groupSizeByte[editor.CurrentEditingGroup] = m_groupSizeByte.DefaultValue; m_groupingType[editor.CurrentEditingGroup] = m_groupingType.DefaultValue; m_groupNameFormat[editor.CurrentEditingGroup] = m_groupNameFormat.DefaultValue; } else { m_groupSizeByte.Remove(editor.CurrentEditingGroup); m_groupingType.Remove(editor.CurrentEditingGroup); m_groupNameFormat.Remove(editor.CurrentEditingGroup); } onValueChanged(); } }); using (disabledScope) { var newType = (GroupingType)EditorGUILayout.EnumPopup("Grouping Type", (GroupingType)m_groupingType[editor.CurrentEditingGroup]); if (newType != (GroupingType)m_groupingType[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Grouping Type", node, true)){ m_groupingType[editor.CurrentEditingGroup] = (int)newType; onValueChanged(); } } var newSizeText = EditorGUILayout.TextField("Size(KB)", m_groupSizeByte[editor.CurrentEditingGroup].ToString()); int newSize = 0; Int32.TryParse(newSizeText, out newSize); if (newSize != m_groupSizeByte[editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Grouping Size", node, true)){ m_groupSizeByte[editor.CurrentEditingGroup] = newSize; onValueChanged(); } } var newGroupNameFormat = EditorGUILayout.TextField("Group Name Format", m_groupNameFormat [editor.CurrentEditingGroup]); EditorGUILayout.HelpBox( "You can customize group name. You can use variable {OldGroup} for old group name and {NewGroup} for current matching name.", MessageType.Info); if (newGroupNameFormat != m_groupNameFormat [editor.CurrentEditingGroup]) { using (new RecordUndoScope("Change Group Name", node, true)) { m_groupNameFormat [editor.CurrentEditingGroup] = newGroupNameFormat; onValueChanged(); } } } } var newFreezeGroups = EditorGUILayout.ToggleLeft("Freeze group on build", m_freezeGroups); if (newFreezeGroups != m_freezeGroups) { using (new RecordUndoScope("Change Freeze Groups", node, true)){ m_freezeGroups = newFreezeGroups; onValueChanged(); } } EditorGUILayout.HelpBox("Freezing group will save group when build is performed, and any new asset from there will be put into new group.", MessageType.Info); using (new GUILayout.HorizontalScope()) { GUILayout.Label("Group setting"); GUILayout.FlexibleSpace(); if (GUILayout.Button("Import")) { if (ImportGroupsWithGUI(node)) { onValueChanged(); } } if (GUILayout.Button("Export")) { ExportGroupsWithGUI(node); } if (GUILayout.Button("Reset")) { if (EditorUtility.DisplayDialog("Do you want to reset group setting?", "This will erase current saved group setting.", "OK", "Cancel")) { m_savedGroups = null; onValueChanged(); } } } GUILayout.Space(8f); if (m_groupViewController != null) { m_groupViewController.OnGroupViewGUI(); } }