private void OnGUI()
        {
            GUILayout.FlexibleSpace();

            EditorGUILayout.BeginHorizontal();
            _packageName = EditorGUILayout.TextField("Package Name", _packageName);
            GUILayout.Label(JEMAssetsBuilderConfiguration.GetExtension());
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Add", GUILayout.Height(22)))
            {
                AddPackage();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Exports directly target array of objects.
        /// </summary>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="InvalidOperationException"/>
        public static void ExportDirectly([NotNull] string filePath, [NotNull] Object[] objects)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException(nameof(filePath));
            }
            if (objects == null)
            {
                throw new ArgumentNullException(nameof(objects));
            }
            if (objects.Length == 0)
            {
                return;
            }
            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            // Try to load configuration first
            JEMAssetsBuilderConfiguration.Load();

            // Create package from received data
            var package = new JEMAssetBuilderPackage
            {
                Name = Path.GetFileName(filePath).Remove(Path.GetFileName(filePath).Length - JEMAssetsBuilderConfiguration.GetExtension().Length,
                                                         JEMAssetsBuilderConfiguration.GetExtension().Length)
            };

            // Write objects to new package
            foreach (var obj in objects)
            {
                package.AddAsset(obj);
            }

            // Export package.
            ExportPackages(Path.GetDirectoryName(filePath) ?? throw new InvalidOperationException(), new[] { package });
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Gets full path to file of this package.
 /// </summary>
 public string GetFile() => $"{JEMAssetsBuilderConfiguration.GetDirectory()}\\{Name}{JEMAssetsBuilderConfiguration.GetExtension()}";
Ejemplo n.º 4
0
        public static void ExportSelectedDirectly(MenuCommand menuCommand)
        {
            if (Selection.objects.Length == 0)
            {
                EditorUtility.DisplayDialog("Oops.", "No assets selected to build.", "Ok");
            }
            else
            {
                // Try to load configuration first
                JEMAssetsBuilderConfiguration.TryLoadConfiguration();

                // Get save file path
                var path = EditorUtility.SaveFilePanel("Export Assets", Environment.CurrentDirectory, "myAssetBundle", JEMAssetsBuilderConfiguration.GetExtension().Remove(0, 1));
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                // Export directly.
                ExportDirectly(path, Selection.objects);
            }
        }