private void OnGUI_Toolbar(int logCount, int warningLogCount, int errorLogCount)
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            // Left
            if (GUILayout.Button("Clear", EditorStyles.toolbarButton))
            {
                LogItems.GetInstance()._Clear();
                m_FilterModified = true;
            }

            m_FilterModified |= m_FocusLastLog.Set(GUILayout.Toggle(m_FocusLastLog, "Focus", EditorStyles.toolbarButton));

            m_FilterModified |= m_Collapse.Set(GUILayout.Toggle(m_Collapse, "Collapse", EditorStyles.toolbarButton));
            m_FilterModified |= SetFlag(LogType.Log, GUILayout.Toggle(HasFlag(LogType.Log), "L " + logCount, EditorStyles.toolbarButton));
            m_FilterModified |= SetFlag(LogType.Warning, GUILayout.Toggle(HasFlag(LogType.Warning), "W " + warningLogCount, EditorStyles.toolbarButton));
            m_FilterModified |= SetFlag(LogType.Error, GUILayout.Toggle(HasFlag(LogType.Error), "E " + errorLogCount, EditorStyles.toolbarButton));
            GUILayout.FlexibleSpace();

            // Right
            m_FilterModified |= m_LogTagFilter.Set(EditorGUILayout.DelayedTextField(m_LogTagFilter, EditorStyles.toolbarTextField));
            m_FilterModified |= m_LogTextFilter.Set(EditorGUILayout.DelayedTextField(m_LogTextFilter, EditorStyles.toolbarTextField));

            if (GUILayout.Button("Refresh", EditorStyles.toolbarButton))
            {
                m_FilterModified = true;
            }
            EditorGUILayout.EndHorizontal();
        }
        /// <returns>IsChanged</returns>
        private bool SetFlag(LogType logType, bool enable)
        {
            if (logType == LogType.Assert ||
                logType == LogType.Exception)
            {
                logType = LogType.Error;
            }

            if (enable)
            {
                return(m_LogTypeFlagFilter.Set(m_LogTypeFlagFilter | (1 << (int)logType)));
            }
            else
            {
                return(m_LogTypeFlagFilter.Set(m_LogTypeFlagFilter & ~(1 << (int)logType)));
            }
        }
Ejemplo n.º 3
0
 public void DoGUI()
 {
     m_NormalTextColor.Set(EditorGUILayout.ColorField("普通文本", m_NormalTextColor));
     m_ImportantTextColor.Set(EditorGUILayout.ColorField("重要文本", m_ImportantTextColor));
     m_WarningTextColor.Set(EditorGUILayout.ColorField("警告文本", m_WarningTextColor));
     if (GUILayout.Button("应用"))
     {
         UpdateGUIStyle();
     }
 }
Ejemplo n.º 4
0
    static void Startup()
    {
#if UNITY_EDITOR
        if (!s_StartIsGameMode.Get())
        {
            return;
        }
        s_StartIsGameMode.Set(false);
#endif

        _IsGaming = true;

        Leyoutech.GameController.StartUp();

        GetInstance(() => new GameFacade());

        ClockUtil.Instance().Start();
        FightLogToFile.Instance.Initialization();
        BehaviorManager.Instance.Initialize();
        Cursor.lockState = CursorLockMode.Confined;
        Cursor.visible   = false;

        AssetLoaderMode loaderMode;
        string          assetBundlePath;
        int             maxLoadingCount;
#if UNITY_EDITOR
        loaderMode      = (AssetLoaderMode)s_AssetLoaderMode.Get();
        assetBundlePath = loaderMode == AssetLoaderMode.AssetBundle
                        ? s_AssetBundlePath.Get() + "/" + UnityEditor.EditorUserBuildSettings.activeBuildTarget + "/assetbundles"
                        : string.Empty;
        maxLoadingCount = 30;
#else
        loaderMode      = AssetLoaderMode.AssetBundle;
        assetBundlePath = Application.streamingAssetsPath + "/assetbundles";
        maxLoadingCount = 10;
#endif

        AssetBundle.UnloadAllAssetBundles(true);

        AssetManager.GetInstance().InitLoader(loaderMode, AssetPathMode.Address, maxLoadingCount, assetBundlePath,
                                              (isSuccess) =>
        {
            if (isSuccess)
            {
                CRenderer.Shaders.LoadInstanceFromAssetBundle(() =>
                {
                    AssetManager.GetInstance().LoadSceneAsync("Assets/Scenes/GameMain.unity", (address, scene, userData) =>
                    {
                        instance.SendNotification(NotificationName.StartupPreload);
                    }, null);
                });
            }
        });
    }
        private void PopupItem(string label, ref PrefsValue <string> value, string[] strs, ref PrefsValue <string> filter)
        {
            filter.Set(EditorGUILayout.TextField("筛选", filter.Get()));
            if (!string.IsNullOrEmpty(filter))
            {
                m_StringCahce.Clear();
                for (int i = 0; i < strs.Length; i++)
                {
                    if (strs[i].ToLower().Contains(filter.Get().ToLower()))
                    {
                        m_StringCahce.Add(strs[i]);
                    }
                }
                strs = m_StringCahce.ToArray();
            }

            if (strs.Length < 1)
            {
                value.Set("");
            }
            else
            {
                int selectIdx = 0;
                if (value.Get() == null || value.Get().Length < 1 || Array.IndexOf(strs, value.Get()) < 0)
                {
                    selectIdx = EditorGUILayout.Popup(label, 0, strs);
                }
                else
                {
                    selectIdx = EditorGUILayout.Popup(label, Array.IndexOf <string>(strs, value.Get()), strs);
                }

                if (selectIdx >= strs.Length)
                {
                    selectIdx = 0;
                }

                value.Set(strs[selectIdx]);
            }
        }
        private void OnGUI_SearchClass()
        {
            m_SearchClassFoldout.Set(EditorGUILayout.Foldout(m_SearchClassFoldout.Get(), "Search Class"));
            if (!m_SearchClassFoldout.Get())
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();
            m_SearchClass.Set(EditorGUILayout.TextField("ClassName", m_SearchClass));
            if (GUILayout.Button("Search"))
            {
                m_SearchResults.Clear();
                for (int iAssembly = 0; iAssembly < m_AssemblyNames.Length; iAssembly++)
                {
                    Assembly assembly = Assembly.Load(m_AssemblyNames[iAssembly]);
                    if (assembly == null)
                    {
                        continue;
                    }

                    Type[] types = assembly.GetTypes();
                    for (int iType = 0; iType < types.Length; iType++)
                    {
                        if (types[iType].FullName.Contains(m_SearchClass.Get()))
                        {
                            m_SearchResults.Add($"{m_AssemblyNames[iAssembly]}, {types[iType].FullName}");
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            if (m_SearchResults.Count > 0)
            {
                EditorGUILayout.LabelField("Result:");
                for (int iResult = 0; iResult < m_SearchResults.Count; iResult++)
                {
                    EditorGUILayout.TextField(m_SearchResults[iResult]);
                }
            }
        }
        private void OnGUI_CreateAsset()
        {
            PopupItem("程序集", ref m_AssemblyName, m_AssemblyNames, ref m_AssemblyNameFilter);
            EditorGUILayout.Space();

            if (string.IsNullOrEmpty(m_AssemblyName))
            {
                return;
            }

            Assembly assembly = Assembly.Load(m_AssemblyName);

            if (assembly == null)
            {
                return;
            }

            Type[] types = assembly.GetTypes();
            m_ClassNames = new List <string>();
            for (int iType = 0; iType < types.Length; iType++)
            {
                bool isObjectType = string.IsNullOrEmpty(m_ClassNameBaseTypeFilter);
                Type tp           = types[iType];
                while (!isObjectType && tp.BaseType != null)
                {
                    tp = tp.BaseType;
                    if (tp.FullName == m_ClassNameBaseTypeFilter)
                    {
                        isObjectType = true;
                    }
                }
                if (isObjectType)
                {
                    m_ClassNames.Add(types[iType].FullName);
                }
            }

            if (m_ClassNames.Count < 1)
            {
                return;
            }

            m_ClassNameBaseTypeFilter.Set(EditorGUILayout.TextField("父类", m_ClassNameBaseTypeFilter));

            PopupItem("类", ref m_ClassName, m_ClassNames.ToArray(), ref m_ClassNameFilter);
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (string.IsNullOrEmpty(m_ClassName))
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();
            m_AssetDirection.Set(EditorGUILayout.TextField("asset路径", m_AssetDirection));
            if (GUILayout.Button("选择", GUILayout.Width(120)))
            {
                m_AssetDirection.Set(EditorUtility.OpenFolderPanel("asset路径", m_AssetDirection, ""));
            }
            EditorGUILayout.EndHorizontal();

            if (string.IsNullOrEmpty(m_AssetDirection))
            {
                return;
            }
            if (m_AssetDirection.Get().Contains("Assets"))
            {
                m_AssetDirection.Set(m_AssetDirection.Get().Substring(m_AssetDirection.Get().IndexOf("Assets")));
            }

            EditorGUILayout.BeginHorizontal();
            m_AssetFile.Set(EditorGUILayout.TextField("asset文件", m_AssetFile));
            m_AssetCover.Set(EditorGUILayout.Toggle("覆盖文件", m_AssetCover));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (!string.IsNullOrEmpty(m_AssetDirection) &&
                !string.IsNullOrEmpty(m_AssetFile) &&
                m_AssetDirection.Get().Substring(0, 6) == "Assets")
            {
                bool   canCreate = m_AssetCover;
                string assetFile = m_AssetDirection + "/" + m_AssetFile + ".asset";
                if (!canCreate)
                {
                    canCreate = !File.Exists(Application.dataPath.Remove(Application.dataPath.Length - 6) + assetFile);
                }
                if (canCreate && GUILayout.Button("创建"))
                {
                    ScriptableObject obj = CreateInstance(m_ClassName);
                    AssetDatabase.CreateAsset(obj, assetFile);
                    Selection.activeObject = obj;
                }
            }
        }
Ejemplo n.º 8
0
 public void SwitchShowLogId()
 {
     m_ShowLogId.Set(!m_ShowLogId);
     ReformatAllLogSingleLineText();
 }
Ejemplo n.º 9
0
 public void SwitchShowFrameCount()
 {
     m_ShowFrameCount.Set(!m_ShowFrameCount);
     ReformatAllLogSingleLineText();
 }
Ejemplo n.º 10
0
 public void SwitchShowTimestamp()
 {
     m_ShowTimestamp.Set(!m_ShowTimestamp);
     ReformatAllLogSingleLineText();
 }