Example #1
0
 private void ResetPathToDefault()
 {
     m_UseDefaultPath = true;
     m_OutputPath     = "AssetBundles/";
     m_OutputPath    += m_BuildTarget.ToString();
     EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
 }
 private void ResetPathToDefault()
 {
     m_useDefaultPath = true;
     EditorPrefs.SetBool(kBuildPrefPrefix + "DefaultOutputBuildPath", m_useDefaultPath);
     m_outputPath  = "AssetBundles/";
     m_outputPath += m_buildTarget.ToString();
     EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_outputPath);
 }
        public void OnGUI(Rect pos)
        {
            //options
            EditorGUILayout.Space();
            GUILayout.BeginVertical();
            m_buildTarget     = (ValidBuildTarget)EditorGUILayout.EnumPopup("Target", m_buildTarget);
            m_options         = (BuildAssetBundleOptions)EditorGUILayout.EnumMaskPopup("Options", m_options);
            m_ForceRebuild    = GUILayout.Toggle(m_ForceRebuild, "Clear all build folders on build");
            m_CopyToStreaming = GUILayout.Toggle(m_CopyToStreaming, "Copy bundles to " + m_streamingPath);


            //output path
            EditorGUILayout.Space();
            m_UseDefaultPath = GUILayout.Toggle(m_UseDefaultPath, "Use default output directory.");
            GUILayout.BeginHorizontal();
            if (string.IsNullOrEmpty(m_outputPath))
            {
                m_outputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath");
            }

            var origPath = m_outputPath;

            if (m_UseDefaultPath)
            {
                m_outputPath  = "AssetBundles/";
                m_outputPath += m_buildTarget.ToString();
                GUILayout.Label("Output Directory:  ");
                GUILayout.Label(m_outputPath);
            }
            else
            {
                GUILayout.Label("Output Directory:  ");
                m_outputPath = GUILayout.TextArea(m_outputPath);
            }
            if (m_outputPath != origPath)
            {
                EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_outputPath);
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();



            // build.
            EditorGUILayout.Space();
            if (GUILayout.Button("Build"))
            {
                ExecuteBuild();
            }
            GUILayout.EndVertical();
        }
Example #4
0
        public void OnGUI(Rect pos)
        {
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
            bool newState = false;

            //basic options
            EditorGUILayout.Space();
            GUILayout.BeginVertical();

            // build target
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) {
                ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_BuildTarget);
                if (tgt != m_BuildTarget)
                {
                    m_BuildTarget = tgt;
                    if (m_UseDefaultPath)
                    {
                        m_OutputPath  = "AssetBundles/";
                        m_OutputPath += m_BuildTarget.ToString();
                        EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                    }
                }
            }


            ////output path
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) {
                EditorGUILayout.Space();
                GUILayout.BeginHorizontal();
                var newPath = EditorGUILayout.TextField("Output Path", m_OutputPath);
                if (newPath != m_OutputPath)
                {
                    m_UseDefaultPath = false;
                    m_OutputPath     = newPath;
                    EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_OutputPath);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f)))
                {
                    BrowseForFolder();
                }
                if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f)))
                {
                    ResetPathToDefault();
                }
                if (string.IsNullOrEmpty(m_OutputPath))
                {
                    m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath");
                }
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();

                newState = GUILayout.Toggle(
                    m_ForceRebuild.state,
                    m_ForceRebuild.content);
                if (newState != m_ForceRebuild.state)
                {
                    if (newState)
                    {
                        m_OnToggles.Add(m_ForceRebuild.content.text);
                    }
                    else
                    {
                        m_OnToggles.Remove(m_ForceRebuild.content.text);
                    }
                    m_ForceRebuild.state = newState;
                }
                newState = GUILayout.Toggle(
                    m_CopyToStreaming.state,
                    m_CopyToStreaming.content);
                if (newState != m_CopyToStreaming.state)
                {
                    if (newState)
                    {
                        m_OnToggles.Add(m_CopyToStreaming.content.text);
                    }
                    else
                    {
                        m_OnToggles.Remove(m_CopyToStreaming.content.text);
                    }
                    m_CopyToStreaming.state = newState;
                }
            }

            // advanced options
            using (new EditorGUI.DisabledScope(!AssetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) {
                EditorGUILayout.Space();
                m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings");
                if (m_AdvancedSettings)
                {
                    var indent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel = 1;
                    CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup(
                        m_CompressionContent,
                        (int)m_Compression,
                        m_CompressionOptions,
                        m_CompressionValues);

                    if (cmp != m_Compression)
                    {
                        m_Compression = cmp;
                    }
                    foreach (var tog in m_ToggleData)
                    {
                        newState = EditorGUILayout.ToggleLeft(
                            tog.content,
                            tog.state);
                        if (newState != tog.state)
                        {
                            if (newState)
                            {
                                m_OnToggles.Add(tog.content.text);
                            }
                            else
                            {
                                m_OnToggles.Remove(tog.content.text);
                            }
                            tog.state = newState;
                        }
                    }
                    EditorGUILayout.Space();
                    EditorGUI.indentLevel = indent;
                }
            }

            // build.
            EditorGUILayout.Space();
            if (GUILayout.Button("Build"))
            {
                EditorApplication.delayCall += ExecuteBuild;
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
        public void OnGUI(Rect pos)
        {
            m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition);
            bool newState = false;

            //basic options
            EditorGUILayout.Space();
            GUILayout.BeginVertical();
            ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_buildTarget);

            if (tgt != m_buildTarget)
            {
                m_buildTarget = tgt;
                EditorPrefs.SetInt(kBuildPrefPrefix + "BuildTarget", (int)m_buildTarget);
                if (m_useDefaultPath)
                {
                    m_outputPath  = "AssetBundles/";
                    m_outputPath += m_buildTarget.ToString();
                    EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_outputPath);
                }
            }


            ////output path
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            var newPath = EditorGUILayout.TextField("Output Path", m_outputPath);

            if (newPath != m_outputPath)
            {
                m_useDefaultPath = false;
                m_outputPath     = newPath;
                EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath", m_outputPath);
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f)))
            {
                BrowseForFolder();
            }
            if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f)))
            {
                ResetPathToDefault();
            }
            if (string.IsNullOrEmpty(m_outputPath))
            {
                m_outputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath");
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            newState = GUILayout.Toggle(
                m_ForceRebuild.state,
                m_ForceRebuild.content);
            if (newState != m_ForceRebuild.state)
            {
                EditorPrefs.SetBool(m_ForceRebuild.PrefKey, newState);
                m_ForceRebuild.state = newState;
            }
            newState = GUILayout.Toggle(
                m_CopyToStreaming.state,
                m_CopyToStreaming.content);
            if (newState != m_CopyToStreaming.state)
            {
                EditorPrefs.SetBool(m_CopyToStreaming.PrefKey, newState);
                m_CopyToStreaming.state = newState;
            }


            // advanced options
            EditorGUILayout.Space();
            m_advancedSettings = EditorGUILayout.Foldout(m_advancedSettings, "Advanced Settings");
            if (m_advancedSettings)
            {
                var indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 1;
                CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup(
                    m_CompressionContent,
                    (int)m_compression,
                    m_CompressionOptions,
                    m_CompressionValues);

                if (cmp != m_compression)
                {
                    m_compression = cmp;
                    EditorPrefs.SetInt(kBuildPrefPrefix + "Compression", (int)m_compression);
                }
                foreach (var tog in m_toggleData)
                {
                    newState = EditorGUILayout.ToggleLeft(
                        tog.content,
                        tog.state);
                    if (newState != tog.state)
                    {
                        EditorPrefs.SetBool(tog.PrefKey, newState);
                        tog.state = newState;
                    }
                }
                EditorGUILayout.Space();
                EditorGUI.indentLevel = indent;
            }

            // build.
            EditorGUILayout.Space();
            if (GUILayout.Button("Build"))
            {
                ExecuteBuild();
            }
            GUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }