Esempio n. 1
0
        void RenderOption()
        {
            var style = GUI.skin.FindStyle("flow node 2");

            GUI.BeginGroup(EditorContexts.mIns.GuiContext.OptionRect, style);

            GUI.Label(new Rect(0, 0, 50, EditorGuiContext.GuiHeight), "Option:");

            var lw = EditorGUIUtility.labelWidth;
            var lt = EditorGUI.indentLevel;

            EditorGUIUtility.labelWidth = 140;
            EditorGUI.indentLevel       = 0;

            BuildAssetBundleOptions optval    = (BuildAssetBundleOptions)((int)GetBuildAbOptions() << 1);
            BuildAssetBundleOptions optnewval = (BuildAssetBundleOptions)EditorGUI.EnumMaskField(new Rect(40, EditorGuiContext.GuiHeight, 350, EditorGuiContext.GuiHeight), new GUIContent("AssetBundle Options"), optval);

            if (optnewval != optval)
            {
                EditorPrefs.SetInt(BuildOptKey, (int)optnewval);
            }

            BuildTarget target    = EditorUserBuildSettings.activeBuildTarget;
            var         newtarget = (BuildTarget)EditorGUI.EnumPopup(new Rect(40, 2 * EditorGuiContext.GuiHeight, 350, EditorGuiContext.GuiHeight),
                                                                     new GUIContent("BuildTarget"), target);

            if (newtarget != target)
            {
                if (EditorUtility.DisplayDialog("info", "Change to " + newtarget, "yes", "no"))
                {
                    EditorUserBuildSettings.SwitchActiveBuildTarget(ConvertBuildTarget(newtarget), newtarget);
                }
            }

            EditorGUIUtility.labelWidth = lw;
            EditorGUI.indentLevel       = lt;

            bool oldgen = GetAutoDep();
            bool newval = GUI.Toggle(new Rect(40, 3 * EditorGuiContext.GuiHeight, 160, EditorGuiContext.GuiHeight), oldgen, "Auto Generate Dep");

            if (newval != oldgen)
            {
                EditorPrefs.SetBool(AutoGenDepKey, newval);
            }

            if (GUI.Button(new Rect(40, 4 * EditorGuiContext.GuiHeight + 5, 80, EditorGuiContext.GuiHeight), "Build"))
            {
                StartBuild();
            }

            if (GUI.Button(new Rect(125, 4 * EditorGuiContext.GuiHeight + 5, 120, EditorGuiContext.GuiHeight), "Build DepFile"))
            {
                GenerateDependencyInfo();
            }

            if (GUI.Button(new Rect(250, 4 * EditorGuiContext.GuiHeight + 5, 190, EditorGuiContext.GuiHeight), "Copy to StreamAssets"))
            {
                string streampath = AssetBundleHelper.StreamingAssetsPath;
                if (!Directory.Exists(streampath))
                {
                    Directory.CreateDirectory(streampath);
                }

                AssetBundleEditorHelper.DirectoryCopy(GetOutputPath(), streampath);
                AssetDatabase.Refresh();
            }

            if (GUI.Button(new Rect(445, 4 * EditorGuiContext.GuiHeight + 5, 140, EditorGuiContext.GuiHeight), "Clear StreamAssets"))
            {
                string streampath = AssetBundleHelper.StreamingAssetsPath;
                if (Directory.Exists(streampath))
                {
                    FileUtil.DeleteFileOrDirectory(AssetBundleEditorHelper.GetUnityAssetPath(streampath));
                    AssetDatabase.Refresh();
                }
            }

            if (GUI.Button(new Rect(590, 4 * EditorGuiContext.GuiHeight + 5, 120, EditorGuiContext.GuiHeight), "Clear BuildPath"))
            {
                string buildpath = GetOutputPath();
                if (Directory.Exists(buildpath))
                {
                    FileUtil.DeleteFileOrDirectory(AssetBundleEditorHelper.GetUnityAssetPath(buildpath));
                    AssetDatabase.Refresh();
                }
            }

            GUI.EndGroup();
        }