Example #1
0
        void runBuild()
        {
            if (isBuilding)
            {
                return;
            }
            isBuilding = true;

            try
            {
                VFSManagerEditor.RefreshManager(true);

                var builder = new VFSBuilder()
                              .UseProfile(cur_select_xprofile_name)
                              .SetConfig(VFSManagerEditor.VFSConfig);

                if (mList_pipeline != null && mList_pipeline.Count > 0)
                {
                    var pipeline = new BuilderPipeline();
                    foreach (var type in mList_pipeline)
                    {
                        pipeline.AddLast(Activator.CreateInstance(type) as IBuildHandler);
                    }
                    builder.UsePipeline(pipeline);
                }
                builder.EnableTipsGUI = true;
                builder.CopyToStreamingAssetsFolder     = cur_copyToStreamingAssetFolder;
                builder.ClearAssetBundleSignAfterBuild  = cur_clearAllABSignAfterFinish;
                builder.ClearAssetBundleSignBeforeBuild = cur_clearAllABSign;
                builder.ForceRebuild      = cur_ForceRebuild;
                builder.ClearOutputFolder = cur_ClearOutputFolder;
                builder.Build(cur_select_platform, cur_select_compress);


                this.ShowNotification(new GUIContent("Build Finish"));
                isBuilding = false;
                //mBuilded = true;
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                isBuilding = false;
            }
        }
Example #2
0
        private static DateTime mCurAssetDataTime; //获取Asset查询结果时,VFSManager的刷新时间

        private static void OnPostHeaderGUI(Editor editor)
        {
            if (VFSManagerEditor.VFSConfig == null)
            {
                return;
            }
            if (editor.targets.Length == 1)
            {
                string guid = string.Empty;
                if (VFSEditorUtil.GetPathAndGUIDFromTarget(editor.target, out string path, ref guid, out Type mainAssetType))
                {
                    mCurSelectedAssetPath = path;


                    if (!IsTypeIgnore(mainAssetType) && path.StartsWith("Assets/") && !editor.target.name.IsNullOrEmpty())
                    {
                        if (mCurSelectedAssetPath != mCurShowAssetPath || mCurAssetDataTime != VFSManagerEditor.LastRefreshManagerTime)
                        {
                            //获取数据
                            VFSManagerEditor.QueryAsset(path, out mCurAssetData, false);
                            mCurShowAssetPath = mCurSelectedAssetPath;
                            mCurAssetDataTime = VFSManagerEditor.LastRefreshManagerTime;
                        }

                        GUILayout.Space(10);

                        EditorGUILayout.BeginVertical(style_bg);
                        EditorGUILayout.LabelField("VFS Preview", EditorStyles.centeredGreyMiniLabel);

                        if (mCurAssetData.ManagedByVFS)
                        {
                            GUILayout.Label("Managed By VFS.", style_txt_bold);

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Group : ", style_txt_bold, GUILayout.MaxWidth(95));
                            EditorGUILayout.LabelField(mCurAssetData.GroupName);
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Build Type :", style_txt_bold, GUILayout.MaxWidth(95));
                            EditorGUILayout.LabelField(mCurAssetData.BuildType.ToString());
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("Develop Type :", style_txt_bold, GUILayout.MaxWidth(95));
                            EditorGUILayout.LabelField(mCurAssetData.DevType.ToString());
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            GUILayout.Label("AB Path : ", style_txt_bold, GUILayout.MaxWidth(65));
                            EditorGUILayout.LabelField(mCurAssetData.AssetBundleFileName);
                            GUILayout.EndHorizontal();

                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button(IsChinese?"复制路径":"Copy Path", GUILayout.Width(80)))
                            {
                                GUIUtility.systemCopyBuffer = path;
                            }
                            GUILayout.EndHorizontal();
                        }
                        else
                        {
                            GUILayout.Label("Non VFS managed asset.");
                            GUILayout.BeginHorizontal(style_btn);
                            if (GUILayout.Button("Dashboard"))
                            {
                                VFSConfigDashboardIMGUI.OpenUI();
                            }
                            GUILayout.EndHorizontal();
                        }

                        EditorGUILayout.Separator();

                        EditorGUILayout.EndVertical();
                    }
                }
            }
        }
Example #3
0
        private void OnGUI()
        {
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal(style_head);
            GUILayout.Label("Profile:", GUILayout.Width(55));


            if (xprofiles == null || (select_xprofile - 1) > xprofiles.Length)
            {
                refreshXprofilesCacheData();
            }

            select_xprofile = EditorGUILayout.Popup(select_xprofile, xprofiles);
            GUILayout.EndHorizontal();

            //数据
            string cur_xprofile_name = xprofiles[select_xprofile];

            if (mCurProfileRecord == null || xprofiles[select_xprofile] != mCurProfileRecord.ProfileName)
            {
                mCurProfileRecord = VFSManagerEditor.GetProfileRecord(xprofiles[select_xprofile]);
                addConfiguredValueToCache();
            }

            // 工具栏
            GUILayout.Space(5);
            mToolbar_Index = GUILayout.Toolbar(mToolbar_Index, toolbar_str);

            if (mToolbar_Index == 0)
            {
                #region Group列表

                GUILayout.BeginVertical(style_body);
                v2_body_groups_scrollview = EditorGUILayout.BeginScrollView(v2_body_groups_scrollview);


                //表头
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Group", GUILayout.Width(165));
                GUILayout.Label("|", GUILayout.Width(10));
                GUILayout.Label(IsChinese ? "资源存储位置" : "Assets Storage Location", GUILayout.Width(150));
                GUILayout.Label("|", GUILayout.Width(10));
                GUILayout.Label("Disable", GUILayout.Width(50));

                EditorGUILayout.EndHorizontal();


                if (groups == null)
                {
                    groups = VFSManagerEditor.GetGroups();
                    //groupNames = VFSManagerEditor.GetGroupNames();
                }

                foreach (var group in groups)
                {
                    GUILayout.BeginHorizontal();
                    //GroupName
                    GUILayout.Label(group.GroupName, style_txt_group_item, GUILayout.Width(170));
                    GUILayout.Space(5);
                    //资源存储位置
                    GroupHandleMode handleMode = group.HandleMode;


                    if (handleMode == GroupHandleMode.LocalAndUpdatable || handleMode == GroupHandleMode.LocalOrRemote)
                    {
                        //可以主动设置资源位置
                        if (!assetLocation_cache.ContainsKey(cur_xprofile_name))
                        {
                            assetLocation_cache.Add(cur_xprofile_name, new Dictionary <string, ProfileRecord.E_GroupAssetsLocation>());
                        }

                        if (!assetLocation_cache[cur_xprofile_name].ContainsKey(group.GroupName))
                        {
                            assetLocation_cache[cur_xprofile_name].Add(group.GroupName, ProfileRecord.E_GroupAssetsLocation.Local);
                        }

                        assetLocation_cache[cur_xprofile_name][group.GroupName] = (ProfileRecord.E_GroupAssetsLocation)EditorGUILayout.EnumPopup(assetLocation_cache[cur_xprofile_name][group.GroupName], GUILayout.Width(150));

                        GUILayout.Space(2);
                    }
                    else
                    {
                        //写死资源位置
                        if (handleMode == GroupHandleMode.LocalOnly)
                        {
                            setAssetLocationCacheValue(cur_xprofile_name, group.GroupName, ProfileRecord.E_GroupAssetsLocation.Local);
                            GUILayout.Label($"[{ProfileRecord.E_GroupAssetsLocation.Local.ToString()}]", GUILayout.Width(150));
                        }
                        else if (handleMode == GroupHandleMode.RemoteOnly)
                        {
                            setAssetLocationCacheValue(cur_xprofile_name, group.GroupName, ProfileRecord.E_GroupAssetsLocation.Remote);
                            GUILayout.Label($"[{ProfileRecord.E_GroupAssetsLocation.Remote.ToString()}]", GUILayout.Width(150));
                        }
                    }

                    GUILayout.Space(10);
                    //Disable
                    if (group.ExtensionGroup)
                    {
                        //可以主动设置group disable
                        if (!disable_expansionGroup_cache.ContainsKey(cur_xprofile_name))
                        {
                            disable_expansionGroup_cache.Add(cur_xprofile_name, new Dictionary <string, bool>());
                        }

                        if (!disable_expansionGroup_cache[cur_xprofile_name].ContainsKey(group.GroupName))
                        {
                            disable_expansionGroup_cache[cur_xprofile_name].Add(group.GroupName, false);
                        }
                        GUILayout.Space(10);
                        disable_expansionGroup_cache[cur_xprofile_name][group.GroupName] = EditorGUILayout.Toggle(disable_expansionGroup_cache[cur_xprofile_name][group.GroupName], GUILayout.Width(50));
                    }
                    else
                    {
                        GUILayout.Label("[-]", style_label_center, GUILayout.Width(36));
                        setGroupDisableCacheValue(cur_xprofile_name, group.GroupName, false);
                    }

                    GUILayout.EndHorizontal();
                }



                EditorGUILayout.EndScrollView();



                GUILayout.EndVertical();
                #endregion
            }
            else if (mToolbar_Index == 1)
            {
                #region WebVFS URLs

                if (mWebVFS_Net_Config == null)
                {
                    mWebVFS_Net_Config = XConfig.CreateConfigIfNotExists <WebVFSNetworkConfig>(TinaX.VFSKit.Const.VFSConst.Config_WebVFS_URLs);
                }
                if (mWebVFS_Net_Config_serialized == null)
                {
                    mWebVFS_Net_Config_serialized = new SerializedObject(mWebVFS_Net_Config);
                }
                if (mCur_WebVFS_profileNmae == null || mCur_WebVFS_profileNmae != cur_xprofile_name)
                {
                    if (mWebVFS_Net_Config.Configs == null || !mWebVFS_Net_Config.Configs.Any(item => item.ProfileName == cur_xprofile_name))
                    {
                        ArrayUtil.Combine(ref mWebVFS_Net_Config.Configs, new WebVFSNetworkConfig.NetworkConfig[] {
                            new WebVFSNetworkConfig.NetworkConfig()
                            {
                                ProfileName = cur_xprofile_name
                            }
                        });
                        mWebVFS_Net_Config_serialized.UpdateIfRequiredOrScript();
                    }
                    for (int i = 0; i < mWebVFS_Net_Config.Configs.Length; i++)
                    {
                        if (mWebVFS_Net_Config.Configs[i].ProfileName == cur_xprofile_name)
                        {
                            mCur_ProfileIndex_InWebVFS = i;
                        }
                    }
                    SerializedProperty cur_config = mWebVFS_Net_Config_serialized.FindProperty("Configs").GetArrayElementAtIndex(mCur_ProfileIndex_InWebVFS);
                    SerializedProperty cur_urls   = cur_config.FindPropertyRelative("Urls");

                    reorderableList_urls = new ReorderableList(
                        mWebVFS_Net_Config_serialized,
                        cur_urls,
                        true,
                        true,
                        true,
                        true);
                    reorderableList_urls.drawElementCallback = (rect, index, selected, focused) =>
                    {
                        SerializedProperty itemData = reorderableList_urls.serializedProperty.GetArrayElementAtIndex(index);
                        SerializedProperty mode     = itemData.FindPropertyRelative("NetworkMode");
                        SerializedProperty url      = itemData.FindPropertyRelative("BaseUrl");
                        SerializedProperty helloUrl = itemData.FindPropertyRelative("HelloUrl");

                        rect.y     += 2;
                        rect.height = EditorGUIUtility.singleLineHeight * 1;

                        var rect_mode = rect;
                        EditorGUI.PropertyField(rect_mode, mode, new GUIContent(IsChinese ? "网络模式" : "Network Mode"));
                        //--------------------------------------------------------------------------------------------
                        var rect_url_label = rect;
                        rect_url_label.y    += EditorGUIUtility.singleLineHeight + 2;
                        rect_url_label.width = 58;
                        GUI.Label(rect_url_label, IsChinese ? "基础Url" : "Base Url");

                        var rect_url = rect;
                        rect_url.y     += EditorGUIUtility.singleLineHeight + 2;
                        rect_url.width -= 62;
                        rect_url.x     += 62;
                        EditorGUI.PropertyField(rect_url, url, GUIContent.none);
                        //---------------------------------------------------------------------------------------------------

                        var rect_hellourl_label = rect;
                        rect_hellourl_label.y    += EditorGUIUtility.singleLineHeight * 2 + 4;
                        rect_hellourl_label.width = 58;
                        GUI.Label(rect_hellourl_label, IsChinese ? "HelloUrl" : "Hello Url");

                        var rect_helloUrl = rect;
                        rect_helloUrl.y     += EditorGUIUtility.singleLineHeight * 2 + 4;
                        rect_helloUrl.width -= 62;
                        rect_helloUrl.x     += 62;
                        EditorGUI.PropertyField(rect_helloUrl, helloUrl, GUIContent.none);
                    };
                    reorderableList_urls.elementHeightCallback = (index) =>
                    {
                        return(EditorGUIUtility.singleLineHeight * 3 + 10);
                    };
                    reorderableList_urls.drawHeaderCallback = (rect) =>
                    {
                        GUI.Label(rect, IsChinese?"Web Urls":"Web Urls");
                    };

                    mCur_WebVFS_profileNmae = cur_xprofile_name;
                }

                GUILayout.BeginVertical(style_body);
                v2_body_webvfs_scrollview = EditorGUILayout.BeginScrollView(v2_body_webvfs_scrollview);

                reorderableList_urls.DoLayoutList();
                //EditorGUILayout.PropertyField(cur_urls);

                EditorGUILayout.EndScrollView();

                GUILayout.EndVertical();
                #endregion
            }

            #region 保存和重置值的两个按钮
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            //包存cache的值
            if (GUILayout.Button(IsChinese ? "保存设置" : "Save", GUILayout.Width(100)))
            {
                #region Group Profile
                foreach (var item in assetLocation_cache)
                {
                    //item.key: profile,
                    var profile = VFSManagerEditor.GetProfileRecord(item.Key); //因为获取到的是class,所以直接修改它就行了
                    //item.value 是一个字典,key = groupName, value = value
                    foreach (var item2 in item.Value)
                    {
                        //接下来要在结构体上操作了,所以不能拉过来操作了,只能找到下标之后直接去修改
                        if (!profile.GroupProfileRecords.Any(gpr => gpr.GroupName == item2.Key))
                        {
                            ArrayUtil.Combine(ref profile.GroupProfileRecords, new ProfileRecord.S_GroupProfileRecord[]
                            {
                                new ProfileRecord.S_GroupProfileRecord()
                                {
                                    GroupName = item2.Key,
                                }
                            });
                        }

                        for (var i = 0; i < profile.GroupProfileRecords.Length; i++)
                        {
                            if (profile.GroupProfileRecords[i].GroupName == item2.Key)
                            {
                                profile.GroupProfileRecords[i].Location = item2.Value;
                                break;
                            }
                        }
                    }

                    VFSManagerEditor.AddProfileIfNotExists(profile);
                }

                foreach (var item in disable_expansionGroup_cache)
                {
                    //item.key: profile,
                    var profile = VFSManagerEditor.GetProfileRecord(item.Key); //因为获取到的是class,所以直接修改它就行了
                    //item.value 是一个字典,key = groupName, value = value
                    foreach (var item2 in item.Value)
                    {
                        //接下来要在结构体上操作了,所以不能拉过来操作了,只能找到下标之后直接去修改
                        if (!profile.GroupProfileRecords.Any(gpr => gpr.GroupName == item2.Key))
                        {
                            ArrayUtil.Combine(ref profile.GroupProfileRecords, new ProfileRecord.S_GroupProfileRecord[]
                            {
                                new ProfileRecord.S_GroupProfileRecord()
                                {
                                    GroupName = item2.Key,
                                }
                            });
                        }

                        for (var i = 0; i < profile.GroupProfileRecords.Length; i++)
                        {
                            if (profile.GroupProfileRecords[i].GroupName == item2.Key)
                            {
                                profile.GroupProfileRecords[i].DisableGroup = item2.Value;
                                break;
                            }
                        }
                    }

                    VFSManagerEditor.AddProfileIfNotExists(profile);
                }

                //foreach (var item in developMode_cache)
                //{
                //    //item.key: profile,
                //    var profile = VFSManagerEditor.GetProfileRecord(item.Key); //因为获取到的是class,所以直接修改它就行了
                //    //item.value 是 是否为开发模式的value
                //    profile.DevelopMode = item.Value;
                //    VFSManagerEditor.AddProfileIfNotExists(profile);
                //}


                //通知VFSManager保存到disk
                VFSManagerEditor.SaveProfileRecord();
                #endregion

                #region WebVFS URL
                mWebVFS_Net_Config_serialized?.ApplyModifiedPropertiesWithoutUndo();
                //删掉可能多余的内容
                string[] profiles = XCoreEditor.GetXProfileNames();
                if (mWebVFS_Net_Config.Configs != null && mWebVFS_Net_Config.Configs.Length > 0)
                {
                    List <WebVFSNetworkConfig.NetworkConfig> list_temp = new List <WebVFSNetworkConfig.NetworkConfig>(mWebVFS_Net_Config.Configs);
                    for (var i = list_temp.Count - 1; i >= 0; i--)
                    {
                        if (!profiles.Contains(list_temp[i].ProfileName))
                        {
                            list_temp.RemoveAt(i);
                        }
                    }
                    if (list_temp.Count != mWebVFS_Net_Config.Configs.Length)
                    {
                        mWebVFS_Net_Config.Configs = list_temp.ToArray();
                    }
                }

                AssetDatabase.SaveAssets();
                #endregion
            }

            //重置cache的已记录值
            if (GUILayout.Button(IsChinese ? "重置设置" : "Reset modify", GUILayout.Width(100)))
            {
                assetLocation_cache?.Clear();
                disable_expansionGroup_cache?.Clear();
                addConfiguredValueToCache();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            #endregion
            GUILayout.Space(5);

            GUILayout.EndVertical();
        }
Example #4
0
 private void refreshExtensionGroupDatas()
 {
     ExtensionGroupNames       = VFSManagerEditor.GetExtensionGroupNames();
     flag_refreshExtGroupDatas = true;
     select_extGroup_index     = 0;
 }