Example #1
0
        public AssetAttributes AddAssetAttributes(string guid)
        {
            AssetAttributes attrs;

            if (!assetAttributesMap.TryGetValue(guid, out attrs))
            {
                attrs = assetAttributesMap[guid] = new AssetAttributes();
                MarkAsDirty();
            }
            return(attrs);
        }
Example #2
0
        public AssetAttributes AddAssetPathAttributes(string assetPath)
        {
            AssetAttributes attrs;

            if (!assetAttributesMap.TryGetValue(assetPath, out attrs))
            {
                attrs = assetAttributesMap[assetPath] = new AssetAttributes();
                MarkAsDirty();
            }
            return(attrs);
        }
        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);
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
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);
        }