Skip to content

Commit 4798c60

Browse files
authored
Merge pull request #19 from Unity-Technologies/dev
graph tool integration "can't create new stuff" bug fix support for multiple scenes in one bundle. a couple other other minor bugs
2 parents 09c1b40 + b433d65 commit 4798c60

File tree

13 files changed

+734
-234
lines changed

13 files changed

+734
-234
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Left hand pane showing a list of all bundles in the project. Available function
2222
* Bundles with variants are a darker grey and can be expanded to show the list of variants.
2323
* Right-click or slow-double-click to rename bundle or bundle folder.
2424
* If a bundle has any error, warning, or info message, an icon will appear on the right side. Mouse over the icon for more information.
25-
* If a bundle has a scene in it (making it a scene bundle) and anything else explicitly included, it will be marked as having an error. This bundle will not build until fixed.
25+
* If a bundle has at least one scene in it (making it a scene bundle) and non-scene assets explicitly included, it will be marked as having an error. This bundle will not build until fixed.
2626
* Bundles with duplicated assets will be marked with a warning (more information on duplication in Asset List section below)
2727
* Empty bundles will be marked with an info message. For a number of reasons, empty bundles are not very stable and can dissapear from this list at times.
2828
* Folders of bundles will be marked with the highest message from the contained bundles.
@@ -31,7 +31,7 @@ Left hand pane showing a list of all bundles in the project. Available function
3131
* Right click on multiple bundles to either move the assets from all selected bundles that are duplicates into a new bundle, or only those that are shared within the selection.
3232
* You can also drag duplicate assets out of the Asset List pane into the Bundle List to explicitly include them in a bundle. More info on this in the Asset List feature set below.
3333
* Right click or hit DEL to delete bundles.
34-
* Drag bundles around to move them into and out of folders, or merge them (if none are scene bundles).
34+
* Drag bundles around to move them into and out of folders, or merge them.
3535
* Drag assets from the Project Explorer onto bundels to add them.
3636
* Drag assets onto empty space to create a new bundle.
3737
* Right click to create new bundles or bundle folders.
@@ -55,7 +55,7 @@ Upper right hand pane providing a list of assets contained in whichever bundles
5555
* Note that this list of implicit includes can be incomplete. There are known issues with materials and textures not always showing up correctly.
5656
* As multiple assets can share dependencies, it is common for a given asset to be implicitly included in multiple bundles. If the tool detects this case, it will mark both the bundle and the asset in question with a warning icon.
5757
* To fix the duplicate-inclusion warnings, you can manually move assets into a new bundle or right click the bundle and selecting one of the "Move duplicate" options.
58-
* Drag assets from the Project Explorer into this view to add them to the selected bundle. This is only valid if only one bundle is selected, and it is not a scene bundle
58+
* Drag assets from the Project Explorer into this view to add them to the selected bundle. This is only valid if only one bundle is selected, and the asset type is compatable (scenes onto scene bundles, etc.)
5959
* Drag assets (explicit or implicit) from the Asset List into the Bundle List (to add them to different bundles, or a newly created bundle).
6060
* Right click or hit DEL to remove assets from bundles (does not remove assets from project).
6161
* Select or double-click assets to reveal them in the Project Explorer.
@@ -72,6 +72,9 @@ Lower right hand pane showing details of the asset(s) selected in the Asset List
7272
### Troubleshooting
7373
* *Can't rename or delet a specific bundle.* This is occasionally caused when first adding this tool to an existing project. Please force a reimport of your assets through the Unity menu system to refresh the data.
7474

75+
### External Tool Integration
76+
Other tools that generate asset bundle data can choose to integrate with the browser. Currently the primary example is the [Asset Bundle Graph Tool](https://bitbucket.org/Unity-Technologies/assetbundlegraphtool). If integrations are detected, then a selection bar will appear near the top of the browser. It will allow you to select the Default data source (Unity's AssetDatabase) or an integrated tool. If none are detected, the selector is not present, though you can add it by right-clicking on the tab header and selecting "Custom Sources".
77+
7578
# Usage - Build
7679
The Build tab provides basic build functionality to get you started using asset bundles. In most profressional scenarios, users will end up needing a more advanced build setup. All are welcome to use the build code in this tool as a starting point for writing their own once this no longer meets their needs. Interface:
7780
* *Build Target* - Platform the bundles will be built for

UnityEngine.AssetBundles/Editor/AssetBundleBrowser/AssetBundleBrowserMain.cs

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
using System.Collections.Generic;
12
using UnityEditor;
23
using UnityEditor.IMGUI.Controls;
34

45
namespace UnityEngine.AssetBundles
56
{
67

7-
public class AssetBundleBrowserMain : EditorWindow
8+
public class AssetBundleBrowserMain : EditorWindow, IHasCustomMenu
89
{
910

1011
public const float kButtonWidth = 150;
@@ -13,7 +14,7 @@ enum Mode
1314
{
1415
Browser,
1516
Builder,
16-
//Inspect,
17+
Inspect,
1718
}
1819
[SerializeField]
1920
Mode m_Mode;
@@ -39,6 +40,19 @@ static void ShowWindow()
3940
window.titleContent = new GUIContent("AssetBundles");
4041
window.Show();
4142
}
43+
44+
[SerializeField]
45+
public bool multiDataSource = false;
46+
public virtual void AddItemsToMenu(GenericMenu menu)
47+
{
48+
//menu.AddSeparator(string.Empty);
49+
menu.AddItem(new GUIContent("Custom Sources"), multiDataSource, FlipDataSource);
50+
}
51+
public void FlipDataSource()
52+
{
53+
multiDataSource = !multiDataSource;
54+
}
55+
4256
private void OnEnable()
4357
{
4458

@@ -49,13 +63,26 @@ private void OnEnable()
4963
if(m_BuildTab == null)
5064
m_BuildTab = new AssetBundleBuildTab();
5165
m_BuildTab.OnEnable(subPos, this);
66+
//if (m_InspectTab == null)
67+
// m_InspectTab = new AssetBundleInspectTab();
68+
//m_InspectTab.OnEnable(subPos, this);
5269

5370
m_RefreshTexture = EditorGUIUtility.FindTexture("Refresh");
71+
72+
73+
//determine if we are "multi source" or not...
74+
multiDataSource = false;
75+
List<System.Type> types = AssetBundleDataSource.ABDataSourceProviderUtility.CustomABDataSourceTypes;
76+
if (types.Count > 1)
77+
multiDataSource = true;
5478
}
5579

5680
private Rect GetSubWindowArea()
5781
{
58-
Rect subPos = new Rect(0, k_MenubarPadding, position.width, position.height - k_MenubarPadding);
82+
float padding = k_MenubarPadding;
83+
if (multiDataSource)
84+
padding += k_MenubarPadding * 0.5f;
85+
Rect subPos = new Rect(0, padding, position.width, position.height - padding);
5986
return subPos;
6087
}
6188

@@ -66,6 +93,9 @@ private void Update()
6693
case Mode.Builder:
6794
//m_BuildTab.Update();
6895
break;
96+
case Mode.Inspect:
97+
//m_InspectTab.Update();
98+
break;
6999
case Mode.Browser:
70100
default:
71101
m_ManageTab.Update();
@@ -82,6 +112,9 @@ private void OnGUI()
82112
case Mode.Builder:
83113
m_BuildTab.OnGUI(GetSubWindowArea());
84114
break;
115+
case Mode.Inspect:
116+
//m_InspectTab.OnGUI(GetSubWindowArea());
117+
break;
85118
case Mode.Browser:
86119
default:
87120
m_ManageTab.OnGUI(GetSubWindowArea());
@@ -104,10 +137,70 @@ void ModeToggle()
104137
GUILayout.Space(m_RefreshTexture.width + k_ToolbarPadding);
105138
}
106139
float toolbarWidth = position.width - k_ToolbarPadding * 4 - m_RefreshTexture.width;
107-
string[] labels = new string[2] { "Configure", "Build" };
140+
string[] labels = new string[2] { "Configure", "Build" };//, "Inspect" };
108141
m_Mode = (Mode)GUILayout.Toolbar((int)m_Mode, labels, "LargeButton", GUILayout.Width(toolbarWidth) );
109142
GUILayout.FlexibleSpace();
110-
GUILayout.EndHorizontal();
143+
GUILayout.EndHorizontal();
144+
if(multiDataSource)
145+
{
146+
//GUILayout.BeginArea(r);
147+
GUILayout.BeginHorizontal();
148+
149+
using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
150+
{
151+
GUILayout.Label("Bundle Data Source:");
152+
GUILayout.FlexibleSpace();
153+
var c = new GUIContent(string.Format("{0} ({1})", AssetBundleModel.Model.DataSource.Name, AssetBundleModel.Model.DataSource.ProviderName), "Select Asset Bundle Set");
154+
if (GUILayout.Button(c , EditorStyles.toolbarPopup) )
155+
{
156+
GenericMenu menu = new GenericMenu();
157+
bool firstItem = true;
158+
159+
foreach (var info in AssetBundleDataSource.ABDataSourceProviderUtility.CustomABDataSourceTypes)
160+
{
161+
List<AssetBundleDataSource.ABDataSource> dataSourceList = null;
162+
dataSourceList = info.GetMethod("CreateDataSources").Invoke(null, null) as List<AssetBundleDataSource.ABDataSource>;
163+
164+
165+
if (dataSourceList == null)
166+
continue;
167+
168+
if (!firstItem)
169+
{
170+
menu.AddSeparator("");
171+
}
172+
173+
foreach (var ds in dataSourceList)
174+
{
175+
menu.AddItem(new GUIContent(string.Format("{0} ({1})", ds.Name, ds.ProviderName)), false,
176+
() =>
177+
{
178+
var thisDataSource = ds;
179+
AssetBundleModel.Model.DataSource = thisDataSource;
180+
m_ManageTab.ForceReloadData();
181+
}
182+
);
183+
}
184+
185+
firstItem = false;
186+
}
187+
188+
menu.ShowAsContext();
189+
}
190+
191+
GUILayout.FlexibleSpace();
192+
if (AssetBundleModel.Model.DataSource.IsReadOnly())
193+
{
194+
GUIStyle tbLabel = new GUIStyle(EditorStyles.toolbar);
195+
tbLabel.alignment = TextAnchor.MiddleRight;
196+
197+
GUILayout.Label("Read Only", tbLabel);
198+
}
199+
}
200+
201+
GUILayout.EndHorizontal();
202+
//GUILayout.EndArea();
203+
}
111204
}
112205

113206

0 commit comments

Comments
 (0)