Exemple #1
0
        private void ApplyAllMarks(Action <AssetAttributes> callback)
        {
            foreach (var searchMark in _searchMarks)
            {
                if (_searchResults.Contains(searchMark))
                {
                    var markAttrs = _data.GetAssetPathAttributes(searchMark.assetPath);
                    var bNew      = markAttrs == null;

                    callback(bNew ? _newAttrs : markAttrs);
                    if (bNew)
                    {
                        if (_newAttrs.priority != 0 || _newAttrs.packer != AssetPacker.Auto)
                        {
                            var newAttributes = _data.AddAssetPathAttributes(searchMark.assetPath);
                            newAttributes.priority = _newAttrs.priority;
                            newAttributes.packer   = _newAttrs.packer;
                            _newAttrs.priority     = 0;
                            _newAttrs.packer       = AssetPacker.Auto;
                        }
                    }
                    else
                    {
                        if (markAttrs.priority == 0 && markAttrs.packer == AssetPacker.Auto)
                        {
                            _data.RemoveAssetPathAttributes(searchMark.assetPath);
                        }
                    }
                }
            }
        }
        private static AssetAttributes DrawSingleAssetAttributes(BundleBuilderData data, string assetPath)
        {
            var fileInfoWidth = 60f;
            var fileInfo      = new FileInfo(assetPath);
            var fileSize      = fileInfo.Exists ? fileInfo.Length : 0L;
            var assetObject   = AssetDatabase.LoadMainAssetAtPath(assetPath);
            var attrs         = data.GetAssetPathAttributes(assetPath);
            var bNew          = attrs == null;

            if (bNew)
            {
                attrs = new AssetAttributes();
            }

            var nAssetPacker = (AssetPacker)EditorGUILayout.EnumPopup(attrs.packer, GUILayout.MaxWidth(110f));
            var nPriority    = EditorGUILayout.IntSlider(attrs.priority, 0, data.priorityMax, GUILayout.MaxWidth(220f));

            EditorGUILayout.ObjectField(assetObject, typeof(Object), false, GUILayout.MaxWidth(180f));
            EditorGUILayout.TextField(assetPath);
            EditorGUILayout.LabelField(PathUtils.GetFileSizeString(fileSize), _rightAlignStyle, GUILayout.MaxWidth(fileInfoWidth));

            if (nAssetPacker != attrs.packer)
            {
                attrs.packer = nAssetPacker;
                data.MarkAsDirty();
            }

            if (nPriority != attrs.priority)
            {
                attrs.priority = nPriority;
                data.MarkAsDirty();
            }

            if (attrs.priority == 0 && attrs.packer == AssetPacker.Auto)
            {
                data.RemoveAssetPathAttributes(assetPath);
            }
            else if (bNew)
            {
                if (attrs.priority != 0 || attrs.packer != AssetPacker.Auto)
                {
                    var newAttributes = data.AddAssetPathAttributes(assetPath);
                    newAttributes.priority = attrs.priority;
                    newAttributes.packer   = attrs.packer;
                }
            }

            return(attrs);
        }
Exemple #3
0
        private static AssetAttributes DrawSearchResultAssetAttributes(Rect elementRect, BundleBuilderData data, SearchResult result, BundleBuilderWindow builder, bool batchMode)
        {
            var assetPath      = result.assetPath;
            var fileInfoWidth  = 60f;
            var sliceInfoWidth = 260f;
            var fileInfo       = new FileInfo(assetPath);
            var fileSize       = fileInfo.Exists ? fileInfo.Length : 0L;
            var attrs          = data.GetAssetPathAttributes(assetPath);
            var bNew           = attrs == null;

            if (bNew)
            {
                attrs = new AssetAttributes();
            }

            var iRect        = new Rect(elementRect.x, elementRect.y, 110f, elementRect.height);
            var nAssetPacker = (AssetPacker)EditorGUI.EnumPopup(iRect, attrs.packer);

            iRect.x     += 110f + 8f;
            iRect.width  = 220f;
            iRect.height = elementRect.height - 2f;
            var nPriority = EditorGUI.IntSlider(iRect, attrs.priority, 0, data.priorityMax);

            iRect.x     += iRect.width;
            iRect.width  = 180f;
            iRect.height = elementRect.height - 4f;
            if (assetPath.StartsWith("Assets/"))
            {
                var assetObject = AssetDatabase.LoadMainAssetAtPath(assetPath);
                EditorGUI.ObjectField(iRect, assetObject, typeof(Object), false);
            }
            else
            {
                EditorGUI.LabelField(iRect, "<External>");
            }
            iRect.x     += iRect.width;
            iRect.width  = fileInfoWidth;
            iRect.height = elementRect.height - 2f;
            EditorGUI.LabelField(iRect, PathUtils.GetFileSizeString(fileSize), _rightAlignStyle);

            iRect.x    += iRect.width;
            iRect.width = elementRect.width - iRect.x - sliceInfoWidth - 20f + 20f;
            EditorGUI.TextField(iRect, assetPath);

            iRect.x     += iRect.width;
            iRect.width  = sliceInfoWidth;
            iRect.height = elementRect.height - 2f;
            if (result.bundleInfo != null)
            {
                EditorGUI.TextField(iRect, result.bundleSlice.name);
                iRect.x    += iRect.width;
                iRect.width = 20f;
                if (GUI.Button(iRect, ">"))
                {
                    BundleAssetsWindow.Inspect(data, new List <BundleBuilderData.BundleInfo>(new[] { result.bundleInfo }));
                }
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUI.TextField(iRect, "<null>");
                iRect.x    += iRect.width;
                iRect.width = 20f;
                GUI.Button(iRect, ">");
                EditorGUI.EndDisabledGroup();
            }

            if (batchMode)
            {
                if (nAssetPacker != attrs.packer)
                {
                    builder?.ApplyAllMarks(attributes => attributes.packer = nAssetPacker);
                }

                if (nPriority != attrs.priority)
                {
                    var deltaPriority = nPriority - attrs.priority;
                    builder?.ApplyAllMarks(attributes => attributes.priority = Math.Max(0,
                                                                                        Math.Min(data.priorityMax, attributes.priority + deltaPriority)));
                }
            }
            else
            {
                if (nAssetPacker != attrs.packer)
                {
                    attrs.packer = nAssetPacker;
                    data.MarkAsDirty();
                }

                if (nPriority != attrs.priority)
                {
                    attrs.priority = nPriority;
                    data.MarkAsDirty();
                }

                if (attrs.priority == 0 && attrs.packer == AssetPacker.Auto)
                {
                    data.RemoveAssetPathAttributes(assetPath);
                }
                else if (bNew)
                {
                    if (attrs.priority != 0 || attrs.packer != AssetPacker.Auto)
                    {
                        var newAttributes = data.AddAssetPathAttributes(assetPath);
                        newAttributes.priority = attrs.priority;
                        newAttributes.packer   = attrs.packer;
                    }
                }
            }

            return(attrs);
        }