Ejemplo n.º 1
0
        private void ApplyAllMarks(Action <AssetAttributes> callback)
        {
            foreach (var searchMark in _searchMarks)
            {
                if (_searchResults.Contains(searchMark))
                {
                    var markAttrs = _data.GetAssetAttributes(searchMark.assetGuid);
                    var bNew      = markAttrs == null;

                    callback(bNew ? _newAttrs : markAttrs);
                    if (bNew)
                    {
                        if (_newAttrs.priority != 0 || _newAttrs.packer != AssetPacker.Auto)
                        {
                            var newAttributes = _data.AddAssetAttributes(searchMark.assetGuid);
                            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.RemoveAssetAttributes(searchMark.assetGuid);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static AssetAttributes DrawSingleAssetAttributes(BundleBuilderData data, string assetGuid,
                                                                 BundleBuilderWindow builder, bool batchMode, Action additionalOp)
        {
            var assetPath   = AssetDatabase.GUIDToAssetPath(assetGuid);
            var assetObject = AssetDatabase.LoadMainAssetAtPath(assetPath);
            var attrs       = data.GetAssetAttributes(assetGuid);
            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);
            var fileInfoWidth = 60f;

            EditorGUILayout.LabelField(GetFileSizeString(assetPath), _rightAlignStyle, GUILayout.MaxWidth(fileInfoWidth));
            additionalOp?.Invoke();

            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.RemoveAssetAttributes(assetGuid);
                }
                else if (bNew)
                {
                    if (attrs.priority != 0 || attrs.packer != AssetPacker.Auto)
                    {
                        var newAttributes = data.AddAssetAttributes(assetGuid);
                        newAttributes.priority = attrs.priority;
                        newAttributes.packer   = attrs.packer;
                    }
                }
            }

            return(attrs);
        }
Ejemplo n.º 3
0
        private static AssetAttributes DrawSingleAssetAttributes(BundleBuilderData data, string assetGuid,
                                                                 BundleBuilderWindow builder, bool batchMode, bool rLookup)
        {
            var assetPath   = AssetDatabase.GUIDToAssetPath(assetGuid);
            var assetObject = AssetDatabase.LoadMainAssetAtPath(assetPath);
            var attrs       = data.GetAssetAttributes(assetGuid);
            var bNew        = attrs == null;

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

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

            EditorGUILayout.ObjectField(assetObject, typeof(Object), false, GUILayout.MaxWidth(180f));
            EditorGUILayout.TextField(assetPath);
            if (rLookup)
            {
                BundleBuilderData.BundleInfo  rBundleInfo;
                BundleBuilderData.BundleSplit rBundleSplit;
                BundleBuilderData.BundleSlice rBundleSlice;
                var exists = data.Lookup(assetGuid, out rBundleInfo, out rBundleSplit, out rBundleSlice);
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextField(exists ? rBundleSlice.name : "<null>");
                EditorGUI.EndDisabledGroup();
                if (GUILayout.Button(">", GUILayout.Width(20f)))
                {
                    BundleAssetsWindow.Inspect(data, new List <BundleBuilderData.BundleInfo>(new[] { rBundleInfo }));
                }
            }

            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.RemoveAssetAttributes(assetGuid);
                }
                else if (bNew)
                {
                    if (attrs.priority != 0 || attrs.packer != AssetPacker.Auto)
                    {
                        var newAttributes = data.AddAssetAttributes(assetGuid);
                        newAttributes.priority = attrs.priority;
                        newAttributes.packer   = attrs.packer;
                    }
                }
            }

            return(attrs);
        }