Example #1
0
        private void OnEnable()
        {
            Rect subPos = GetSubWindowArea();

            if (m_ManageTab == null)
            {
                m_ManageTab = new AssetBundleManageTab();
            }
            m_ManageTab.OnEnable(subPos, this);
            if (m_BuildTab == null)
            {
                m_BuildTab = new AssetBundleBuildTab();
            }
            m_BuildTab.OnEnable(subPos, this);
            if (m_InspectTab == null)
            {
                m_InspectTab = new AssetBundleInspectTab();
            }
            m_InspectTab.OnEnable(subPos, this);

            m_RefreshTexture = EditorGUIUtility.FindTexture("Refresh");


            //determine if we are "multi source" or not...
            multiDataSource = false;
            List <System.Type> types = AssetBundleDataSource.ABDataSourceProviderUtility.CustomABDataSourceTypes;

            if (types.Count > 1)
            {
                multiDataSource = true;
            }
        }
        public void SetBundle(AssetBundle bundle, string path = "", AssetBundleInspectTab.InspectTabData inspectTabData = null, AssetBundleInspectTab assetBundleInspectTab = null)
        {
            //static var...
            currentPath             = path;
            m_inspectTabData        = inspectTabData;
            m_assetBundleInspectTab = assetBundleInspectTab;

            //members
            m_Editor = null;
            if (bundle != null)
            {
                m_Editor = Editor.CreateEditor(bundle);
            }
        }
        private void OnEnable()
        {
            Rect subPos = GetSubWindowArea();

            if (m_ManageTab == null)
            {
                m_ManageTab = new AssetBundleManageTab();
            }
            m_ManageTab.OnEnable(subPos, this);
            if (m_BuildTab == null)
            {
                m_BuildTab = new AssetBundleBuildTab();
            }
            m_BuildTab.OnEnable(subPos, this);
            if (m_InspectTab == null)
            {
                m_InspectTab = new AssetBundleInspectTab();
            }
            m_InspectTab.OnEnable(subPos, this);

            m_RefreshTexture = EditorGUIUtility.FindTexture("Refresh");

            InitDataSources();
        }
 public InspectBundleTree(TreeViewState s, AssetBundleInspectTab parent) : base(s)
 {
     m_InspectTab = parent;
     showBorder   = true;
 }
        private void ExecuteBuild()
        {
            if (AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)
            {
                if (string.IsNullOrEmpty(m_UserData.m_OutputPath))
                {
                    BrowseForFolder();
                }

                if (string.IsNullOrEmpty(m_UserData.m_OutputPath)) //in case they hit "cancel" on the open browser
                {
                    Debug.LogError("AssetBundle Build: No valid output path for build.");
                    return;
                }

                if (m_ForceRebuild.state)
                {
                    string message = "Do you want to delete all files in the directory " + m_UserData.m_OutputPath;
                    if (m_CopyToStreaming.state)
                    {
                        message += " and " + m_streamingPath;
                    }
                    message += "?";
                    if (EditorUtility.DisplayDialog("File delete confirmation", message, "Yes", "No"))
                    {
                        try
                        {
                            if (Directory.Exists(m_UserData.m_OutputPath))
                            {
                                Directory.Delete(m_UserData.m_OutputPath, true);
                            }

                            if (m_CopyToStreaming.state)
                            {
                                if (Directory.Exists(m_streamingPath))
                                {
                                    Directory.Delete(m_streamingPath, true);
                                }
                            }
                        }
                        catch (System.Exception e)
                        {
                            Debug.LogException(e);
                        }
                    }
                }
                if (!Directory.Exists(m_UserData.m_OutputPath))
                {
                    Directory.CreateDirectory(m_UserData.m_OutputPath);
                }
            }

            BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;

            if (AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)
            {
                if (m_UserData.m_Compression == CompressOptions.Uncompressed)
                {
                    opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
                }
                else if (m_UserData.m_Compression == CompressOptions.ChunkBasedCompression)
                {
                    opt |= BuildAssetBundleOptions.ChunkBasedCompression;
                }
                foreach (var tog in m_ToggleData)
                {
                    if (tog.state)
                    {
                        opt |= tog.option;
                    }
                }
            }

            ABBuildInfo buildInfo = new ABBuildInfo();

            buildInfo.outputDirectory = m_UserData.m_OutputPath;
            buildInfo.options         = opt;
            buildInfo.buildTarget     = (BuildTarget)m_UserData.m_BuildTarget;
            if (m_InspectTab != null)
            {
                buildInfo.onBuild = (assetBundleName) => { m_InspectTab.AddBundleFolder(buildInfo.outputDirectory); m_InspectTab.RefreshBundles(); }
            }
            ;
            else if (parent != null)
            {
                m_InspectTab      = (parent as AssetBundleBrowserMain).m_InspectTab;
                buildInfo.onBuild = (assetBundleName) => { m_InspectTab.AddBundleFolder(buildInfo.outputDirectory); m_InspectTab.RefreshBundles(); };
            }

            AssetBundleModel.Model.DataSource.BuildAssetBundles(buildInfo);

            AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);

            if (m_CopyToStreaming.state)
            {
                DirectoryCopy(m_UserData.m_OutputPath, m_streamingPath);
            }
        }
        public void OnEnable(Rect pos, EditorWindow parent)
        {
            this.parent  = parent;
            m_InspectTab = (parent as AssetBundleBrowserMain).m_InspectTab;

            //LoadData...
            var dataPath = System.IO.Path.GetFullPath(".");

            dataPath  = dataPath.Replace("\\", "/");
            dataPath += "/Library/AssetBundleBrowserBuild.dat";

            if (File.Exists(dataPath))
            {
                BinaryFormatter bf   = new BinaryFormatter();
                FileStream      file = File.Open(dataPath, FileMode.Open);
                var             data = bf.Deserialize(file) as BuildTabData;
                if (data != null)
                {
                    m_UserData = data;
                }
                file.Close();
            }

            m_ToggleData = new List <ToggleData>();
            m_ToggleData.Add(new ToggleData(
                                 false,
                                 "Exclude Type Information",
                                 "Do not include type information within the asset bundle (don't write type tree).",
                                 m_UserData.m_OnToggles,
                                 BuildAssetBundleOptions.DisableWriteTypeTree));
            m_ToggleData.Add(new ToggleData(
                                 false,
                                 "Force Rebuild",
                                 "Force rebuild the asset bundles",
                                 m_UserData.m_OnToggles,
                                 BuildAssetBundleOptions.ForceRebuildAssetBundle));
            m_ToggleData.Add(new ToggleData(
                                 false,
                                 "Ignore Type Tree Changes",
                                 "Ignore the type tree changes when doing the incremental build check.",
                                 m_UserData.m_OnToggles,
                                 BuildAssetBundleOptions.IgnoreTypeTreeChanges));
            m_ToggleData.Add(new ToggleData(
                                 false,
                                 "Append Hash",
                                 "Append the hash to the assetBundle name.",
                                 m_UserData.m_OnToggles,
                                 BuildAssetBundleOptions.AppendHashToAssetBundleName));
            m_ToggleData.Add(new ToggleData(
                                 false,
                                 "Strict Mode",
                                 "Do not allow the build to succeed if any errors are reporting during it.",
                                 m_UserData.m_OnToggles,
                                 BuildAssetBundleOptions.StrictMode));
            m_ToggleData.Add(new ToggleData(
                                 false,
                                 "Dry Run Build",
                                 "Do a dry run build.",
                                 m_UserData.m_OnToggles,
                                 BuildAssetBundleOptions.DryRunBuild));


            m_ForceRebuild = new ToggleData(
                false,
                "Clear Folders",
                "Will wipe out all contents of build directory as well as StreamingAssets/AssetBundles if you are choosing to copy build there.",
                m_UserData.m_OnToggles);
            m_CopyToStreaming = new ToggleData(
                false,
                "Copy to StreamingAssets",
                "After build completes, will copy all build content to " + m_streamingPath + " for use in stand-alone player.",
                m_UserData.m_OnToggles);

            m_TargetContent      = new GUIContent("Build Target", "Choose target platform to build for.");
            m_CompressionContent = new GUIContent("Compression", "Choose no compress, standard (LZMA), or chunk based (LZ4)");

            if (m_UserData.m_UseDefaultPath)
            {
                ResetPathToDefault();
            }
        }
 //public InspectTreeItem(int id, int depth, string displayName) : base(id, depth, displayName)
 public InspectTreeItem(string path, AssetBundleInspectTab inspectTab) : base(path.GetHashCode(), 0, path)
 {
     m_BundlePath = path;
     m_Bundle     = null;
     m_InspectTab = inspectTab;
 }