Ejemplo n.º 1
0
 protected virtual void OnEnable()
 {
     m_Target     = (XChartsMgr)target;
     m_Script     = serializedObject.FindProperty("m_Script");
     m_NowVersion = serializedObject.FindProperty("m_NowVersion");
     m_NewVersion = serializedObject.FindProperty("m_NewVersion");
 }
Ejemplo n.º 2
0
 public static void EnableTextMeshPro()
 {
     if (!XChartsMgr.IsExistTMPAssembly())
     {
         Debug.LogError("TextMeshPro is not in the project, please import TextMeshPro package first.");
         return;
     }
     XChartsMgr.ModifyTMPRefence();
     XChartsMgr.EnableTextMeshPro();
 }
Ejemplo n.º 3
0
        public static bool ModifyTMPRefence(bool removeTMP = false)
        {
            var packagePath = XChartsMgr.GetPackageFullPath();

            if (!ModifyTMPRefence(packagePath + "/Runtime/XCharts.Runtime.asmdef", removeTMP))
            {
                return(false);
            }
            if (!ModifyTMPRefence(packagePath + "/Editor/XCharts.Editor.asmdef", removeTMP))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 4
0
        private void OnGUI()
        {
            if (target == null)
            {
                Close();
                return;
            }
            GUILayout.Space(10);
            GUILayout.Label("Input a new name for theme:");
            m_ChartName = GUILayout.TextField(m_ChartName);

            GUILayout.Space(10);
            GUILayout.Label("Export path:");
            if (string.IsNullOrEmpty(m_ChartName))
            {
                GUILayout.Label("Need input a new name.");
            }
            else
            {
                GUILayout.Label(XChartsMgr.GetThemeAssetPath(m_ChartName));
            }

            GUILayout.Space(20);
            if (GUILayout.Button("Export"))
            {
                if (string.IsNullOrEmpty(m_ChartName))
                {
                    ShowNotification(new GUIContent("ERROR:Need input a new name!"));
                }
                else if (XChartsMgr.ContainsTheme(m_ChartName))
                {
                    ShowNotification(new GUIContent("ERROR:The name you entered is already in use!"));
                }
                else if (IsAssetsExist(XChartsMgr.GetThemeAssetPath(m_ChartName)))
                {
                    ShowNotification(new GUIContent("ERROR:The asset is exist! \npath="
                                                    + XChartsMgr.GetThemeAssetPath(m_ChartName)), 5);
                }
                else
                {
                    XChartsMgr.ExportTheme(target.theme, m_ChartName);
                    ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath="
                                                    + XChartsMgr.GetThemeAssetPath(m_ChartName)), 5);
                }
            }
        }
Ejemplo n.º 5
0
 public static void DisableTextMeshPro()
 {
     XChartsMgr.DisableTextMeshPro();
 }
Ejemplo n.º 6
0
 public static void DisableTextMeshPro()
 {
     XChartsMgr.ModifyTMPRefence(true);
     XChartsMgr.DisableTextMeshPro();
 }
Ejemplo n.º 7
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            if (prop.objectReferenceValue == null)
            {
                EditorGUI.ObjectField(pos, prop, new GUIContent("Theme"));
                return;
            }
            base.OnGUI(pos, prop, label);
            var defaultWidth = pos.width;
            var defaultX     = pos.x;
            var btnWidth     = 45;

            ChartEditorHelper.MakeFoldout(ref m_DrawRect, ref m_ThemeModuleToggle, "Theme");
            m_Heights[m_KeyName] += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            if (m_ThemeModuleToggle)
            {
                m_DrawRect.x     = defaultX + defaultWidth - 2 * btnWidth - 2;
                m_DrawRect.width = btnWidth;
                var chart    = prop.serializedObject.targetObject as BaseChart;
                var lastFont = chart.theme.font;
#if dUI_TextMeshPro
                var lastTMPFont = chart.theme.tmpFont;
#endif
                if (GUI.Button(m_DrawRect, new GUIContent("Reset", "Reset to theme default color")))
                {
                    chart.theme.ResetTheme();
                    chart.RefreshAllComponent();
                }
                m_DrawRect.x     = defaultX + defaultWidth - btnWidth;
                m_DrawRect.width = btnWidth;
                if (GUI.Button(m_DrawRect, new GUIContent("Export", "Export theme to asset for a new theme")))
                {
                    ExportThemeWindow.target = chart;
                    EditorWindow.GetWindow(typeof(ExportThemeWindow));
                }

                var data = (ScriptableObject)prop.objectReferenceValue;
                SerializedObject   serializedObject = new SerializedObject(data);
                SerializedProperty newProp          = serializedObject.GetIterator();
                float y = pos.y + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                ++EditorGUI.indentLevel;

                var chartNameList = XChartsMgr.GetAllThemeNames();
                var lastIndex     = chartNameList.IndexOf(chart.theme.themeName);
                var selectedIndex = EditorGUI.Popup(new Rect(pos.x, y, pos.width, EditorGUIUtility.singleLineHeight),
                                                    "Theme", lastIndex, chartNameList.ToArray());
                m_Heights[m_KeyName] += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                if (lastIndex != selectedIndex)
                {
                    GUI.changed = true;
                    XChartsMgr.SwitchTheme(chart, chartNameList[selectedIndex]);
                }
                if (newProp.NextVisible(true))
                {
                    do
                    {
                        if (newProp.name == "m_Script")
                        {
                            continue;
                        }
                        if (newProp.name == "m_ThemeName")
                        {
                            continue;
                        }
                        if (newProp.name == "m_Theme")
                        {
                            continue;
                        }
                        AddPropertyField(pos, newProp, ref y);
                    } while (newProp.NextVisible(false));
                }
                if (GUI.changed)
                {
                    chart.RefreshAllComponent();
                    serializedObject.ApplyModifiedProperties();
                }
                if (chart.theme.font != lastFont)
                {
                    chart.theme.SyncFontToSubComponent();
                }
#if dUI_TextMeshPro
                if (chart.theme.tmpFont != lastTMPFont)
                {
                    chart.theme.SyncTMPFontToSubComponent();
                }
#endif
                --EditorGUI.indentLevel;
            }
        }
        public void OnGUI()
        {
            m_EssentialResourcesImported         = File.Exists("Assets/XCharts/Resources/XChartsSettings.asset");
            m_ExamplesAndExtrasResourcesImported = Directory.Exists("Assets/XCharts/Examples & Extras");

            GUILayout.BeginVertical();
            {
                GUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    GUILayout.Label("XCharts Essentials", EditorStyles.boldLabel);
                    GUILayout.Label("This appears to be the first time you access XCharts, as such we need to add resources to your project that are essential for using XCharts. These new resources will be placed at the root of your project in the \"XCharts\" folder.", new GUIStyle(EditorStyles.label)
                    {
                        wordWrap = true
                    });
                    GUILayout.Space(5f);

                    GUI.enabled = !m_EssentialResourcesImported;
                    if (GUILayout.Button("Import XCharts Essentials"))
                    {
                        AssetDatabase.importPackageCompleted += ImportCallback;

                        string packageFullPath = GetPackageFullPath();
                        Debug.LogError("packageFullPath:" + packageFullPath);
                        AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/XCharts Essential Resources.unitypackage", false);
                    }
                    GUILayout.Space(5f);
                    GUI.enabled = true;
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            {
                GUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    GUILayout.Label("TextMeshPro", EditorStyles.boldLabel);
#if dUI_TextMeshPro
                    GUILayout.Label("TextMeshPro is now enabled. You can turn it off by clicking the button below.", new GUIStyle(EditorStyles.label)
                    {
                        wordWrap = true
                    });
                    GUILayout.Space(5f);
                    if (GUILayout.Button("Disable TextMeshPro"))
                    {
                        XChartsMgr.DisableTextMeshPro();
                    }
#else
                    GUILayout.Label("TextMeshPro is not active. You can activate it by clicking the button below. Make sure TextMeshPro is already in your project before activating it.", new GUIStyle(EditorStyles.label)
                    {
                        wordWrap = true
                    });
                    GUILayout.Space(5f);
                    if (GUILayout.Button("Enable TextMeshPro"))
                    {
                        XChartsMgr.EnableTextMeshPro();
                    }
#endif
                    GUILayout.Space(5f);
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
            GUILayout.Space(5f);
        }
Ejemplo n.º 9
0
 public static void EnableTextMeshPro()
 {
     XChartsMgr.EnableTextMeshPro();
 }