Beispiel #1
0
        private void BuildsToDps()
        {
            Dependences.Clear();
            AssetbundleBuilds.ReverseForEach((buildItem) => {
                buildItem.CrossRefence = false;
                buildItem.FileLength = 0;
                for (int i = 0; i < buildItem.assetNames.Count; i++)
                {
                    string assetpath = buildItem.assetNames[i];
                    ABDeprndence info = ContainsAsset(assetpath);
                    if (info==null)
                    {
                        info = new ABDeprndence();
                        info.AssetPath = assetpath;
                        info.FileLength = IO.GetFileLength(assetpath);
                        info.Size = IO.GetFileSize(info.FileLength);

                        AssetImporter importer = AssetImporter.GetAtPath(assetpath);
                        info.BundleName = importer.assetBundleName + "." + importer.assetBundleVariant;

                        Dependences.Add(info);
                    }
                    else
                    {
                        buildItem.CrossRefence = true;
                    }
                    info.AssetBundles.Add(buildItem.assetBundleName);
                    buildItem.FileLength += info.FileLength;
                }
                buildItem.Size = IO.GetFileSize(buildItem.FileLength);


            });

        }
            private void ABBContentWinGUI(Rect rect)
            {
                rect.DrawOutLine(2, Color.black);
                int lineCount = ChossedABB == null ? 0 : ChossedABB.assetNames.Count;

                ABBContentTable.Calc(rect, new Vector2(rect.x, rect.y + LineHeight), ABBContentScrollPos, LineHeight, lineCount, ABBContentSetting);
                this.Label(ABBContentTable.titleRow.position, "", TitleStyle)
                .Label(ABBContentTable.titleRow[AssetName].position, AssetName)
                .Label(ABBContentTable.titleRow[Bundle].position, Bundle)
                .Label(ABBContentTable.titleRow[Size].position, Size);
                Event e = Event.current;

                this.DrawScrollView(() =>
                {
                    for (int i = ABBContentTable.firstVisibleRow; i < ABBContentTable.lastVisibleRow + 1; i++)
                    {
                        ABDeprndence asset = GetDpByName(ChossedABB.assetNames[i]);
                        GUIStyle style     = i % 2 == 0 ? EntryBackEven : EntryBackodd;

                        if (e.type == EventType.Repaint)
                        {
                            style.Draw(ABBContentTable.rows[i].position, false, false, ABBContentTable.rows[i].selected, false);
                        }

                        this.Label(ABBContentTable.rows[i][Size].position, asset.Size)
                        .Label(ABBContentTable.rows[i][AssetName].position, asset.AssetName)
                        .Label(ABBContentTable.rows[i][Preview].position, asset.ThumbNail)
                        .Label(ABBContentTable.rows[i][Bundle].position, asset.BundleName)
                        .Pan(() => {
                            if (asset.AssetBundles.Count == 1)
                            {
                                this.Label(ABBContentTable.rows[i][CrossRef].position, EditorGUIUtility.IconContent("Collab"));
                            }
                            else
                            {
                                this.Label(ABBContentTable.rows[i][CrossRef].position, asset.AssetBundles.Count.ToString(), GUIStyles.Get("CN CountBadge"));
                            }
                        });

                        if (e.modifiers == EventModifiers.Control &&
                            e.button == 0 && e.clickCount == 1 &&
                            ABBContentTable.rows[i].position.Contains(Event.current.mousePosition))
                        {
                            ABBContentTable.ControlSelectRow(i);
                            window.Repaint();
                        }
                        else if (e.modifiers == EventModifiers.Shift &&
                                 e.button == 0 && e.clickCount == 1 &&
                                 ABBContentTable.rows[i].position.Contains(e.mousePosition))
                        {
                            ABBContentTable.ShiftSelectRow(i);
                            window.Repaint();
                        }
                        else if (e.button == 0 && e.clickCount == 1 &&
                                 ABBContentTable.rows[i].position.Contains(e.mousePosition))
                        {
                            ABBContentTable.SelectRow(i);
                            ChoosedAsset = asset;
                            window.Repaint();
                        }
                    }
                }, ABBContentTable.view, ref ABBContentScrollPos, ABBContentTable.content, false, false);

                Handles.color = Color.black;

                for (int i = 0; i < ABBContentTable.titleRow.columns.Count; i++)
                {
                    var item = ABBContentTable.titleRow.columns[i];

                    if (i != 0)
                    {
                        Handles.DrawAAPolyLine(1, new Vector3(item.position.x - 2,
                                                              item.position.y,
                                                              0),
                                               new Vector3(item.position.x - 2,
                                                           item.position.yMax - 2,
                                                           0));
                    }
                }
                ABBContentTable.position.DrawOutLine(2, Color.black);

                Handles.color = Color.white;

                if (e.button == 0 && e.clickCount == 1 &&
                    (ABBContentTable.view.Contains(e.mousePosition) &&
                     !ABBContentTable.content.Contains(e.mousePosition)))
                {
                    ABBContentTable.SelectNone();
                    ChoosedAsset = null;
                    window.Repaint();
                }
                if (e.button == 1 && e.clickCount == 1 && ABBContentTable.content.Contains(e.mousePosition))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Delete"), false, () => {
                        ABBContentTable.selectedRows.ReverseForEach((row) =>
                        {
                            window.RemoveAsset(ChossedABB.assetNames[row.rowID], ChossedABB.assetBundleName);
                        });
                        window.UpdateInfo();
                        ChoosedAsset = null;
                    });

                    menu.ShowAsContext();
                    if (e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }
            }
            private void ABBWinGUI(Rect rect)
            {
                rect.DrawOutLine(2, Color.black);
                Event e = Event.current;

                ABBListViewCalc.Calc(rect, rect.position, ABBScrollPos, LineHeight, AssetbundleBuilds.Count, ABBSetting);
                this.DrawScrollView(() =>
                {
                    for (int i = ABBListViewCalc.firstVisibleRow; i < ABBListViewCalc.lastVisibleRow + 1; i++)
                    {
                        if (e.modifiers == EventModifiers.Control &&
                            e.button == 0 && e.clickCount == 1 &&
                            ABBListViewCalc.rows[i].position.Contains(e.mousePosition))
                        {
                            ABBListViewCalc.ControlSelectRow(i);
                            window.Repaint();
                        }
                        else if (e.modifiers == EventModifiers.Shift &&
                                 e.button == 0 && e.clickCount == 1 &&
                                 ABBListViewCalc.rows[i].position.Contains(e.mousePosition))
                        {
                            ABBListViewCalc.ShiftSelectRow(i);
                            window.Repaint();
                        }
                        else if (e.button == 0 && e.clickCount == 1 &&
                                 ABBListViewCalc.rows[i].position.Contains(e.mousePosition)
                                 /*  && ListView.viewPosition.Contains(Event.current.mousePosition) */)
                        {
                            ABBListViewCalc.SelectRow(i);
                            ChossedABB = AssetbundleBuilds[i];
                            window.Repaint();
                        }

                        GUIStyle style = i % 2 == 0 ? EntryBackEven : EntryBackodd;
                        if (e.type == EventType.Repaint)
                        {
                            style.Draw(ABBListViewCalc.rows[i].position, false, false, ABBListViewCalc.rows[i].selected, false);
                        }
                        this.Label(ABBListViewCalc.rows[i][ABName].position, AssetbundleBuilds[i].assetBundleName);
                        if (AssetbundleBuilds[i].CrossRefence)
                        {
                            this.Label(ABBListViewCalc.rows[i][RefCount].position, EditorGUIUtility.IconContent("console.warnicon.sml"));
                        }
                        else
                        {
                            this.Label(ABBListViewCalc.rows[i][RefCount].position, EditorGUIUtility.IconContent("Collab"));
                        }
                    }
                }, ABBListViewCalc.view,
                                    ref ABBScrollPos,
                                    ABBListViewCalc.content, false, false);

                if (e.button == 0 && e.clickCount == 1 &&
                    (ABBListViewCalc.view.Contains(e.mousePosition) &&
                     !ABBListViewCalc.content.Contains(e.mousePosition)))
                {
                    ABBListViewCalc.SelectNone();
                    window.Repaint();
                    ChoosedAsset = null;
                    ChossedABB   = null;
                }

                if (e.button == 1 && e.clickCount == 1 &&
                    ABBListViewCalc.content.Contains(e.mousePosition))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Delete"), false, () => {
                        ChoosedAsset = null;
                        ChossedABB   = null;
                        ABBListViewCalc.selectedRows.ReverseForEach((row) => {
                            int index = row.rowID;
                            window.DeleteBundle(AssetbundleBuilds[index].assetBundleName);
                        });


                        window.UpdateInfo();
                    });

                    menu.ShowAsContext();
                    if (e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }
            }