/// <summary>
    /// Call with command-line options to build assetbundles.
    /// </summary>
    public static void BuildAssetbundles()
    {
        string settingPath = "Assets/AssetBundleManager/Editor/AssetBundleBuildSetting.asset";

        AssetBundles.BundleBuilder builder = (AssetBundles.BundleBuilder)AssetDatabase.LoadAssetAtPath(settingPath, typeof(AssetBundles.BundleBuilder));
        if (builder != null)
        {
            builder.Build();
        }
        else
        {
            EditorUtility.DisplayDialog("AssetBundle Build Error", "Failed to load builder", "ok");
        }
    }
 static public void CreateBuildSetting()
 {
     BundleBuilder.CreateBuildSetting();
 }
示例#3
0
        public override void OnInspectorGUI()
        {
            // Add header
            GUIStyle headerStyle = new GUIStyle(GUI.skin.label);

            headerStyle.fontSize         = 14;
            headerStyle.normal.textColor = Color.white;
            headerStyle.fontStyle        = FontStyle.Bold;
            EditorGUILayout.LabelField("AssetBundle Setting Tool", headerStyle, GUILayout.Height(20));
            EditorGUILayout.Space();

            // Set external scritableobject for preprcessing and postprocessing if it is necessary.
            builder.external = EditorGUILayout.ObjectField("External:", builder.external, typeof(ScriptableObject), true) as ScriptableObject;
            EditorGUILayout.Space();

            // Set assetbundle build target.
            SetBuildTarget();
            EditorGUILayout.Space();

            // AssetBundle Options
            SetBundleOptions();
            EditorGUILayout.Space();

            // Output path setting
            EditorGUILayout.LabelField("Output Path:", EditorStyles.boldLabel);

            using (new EditorGUILayout.HorizontalScope())
            {
                string path = string.Empty;
                if (string.IsNullOrEmpty(builder.outputPath))
                {
                    path = BundleBuilder.GetProjectPath();
                }
                else
                {
                    path = builder.outputPath;
                }

                builder.outputPath = GUILayout.TextField(builder.outputPath, GUILayout.MinWidth(250));
                if (GUILayout.Button("...", GUILayout.Width(20)))
                {
                    string projectFolder = Path.Combine(BundleBuilder.GetProjectPath(), builder.outputPath);
                    path = EditorUtility.OpenFolderPanel("Select folder", projectFolder, "");
                    if (path.Length != 0)
                    {
                        builder.outputPath = path.Replace(BundleBuilder.GetProjectPath(), "");
                    }
                }
            }
            EditorGUILayout.Space();

            // Build
            EditorGUILayout.LabelField("AssetBundle Build:", EditorStyles.boldLabel);
            if (GUILayout.Button("Build"))
            {
                //HACK: To prevent InvalidOperationException.
                //  See http://answers.unity3d.com/questions/852155/invalidoperationexception-operation-is-not-valid-d-1.html
                EditorApplication.delayCall += builder.Build;
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(builder);
                AssetDatabase.SaveAssets();
            }
        }
示例#4
0
 public static void CreateBuildSetting()
 {
     BundleBuilder instance = ScriptableObject.CreateInstance<BundleBuilder>();
     AssetDatabase.CreateAsset(instance, "Assets/AssetBundleManager/Editor/AssetBundleBuildSetting.asset");
     AssetDatabase.SaveAssets();
 }
示例#5
0
 void OnEnable()
 {
     builder = target as BundleBuilder;
 }