重构代码,将与绘制相关的Color改为Color32,减少隐式转换

This commit is contained in:
monitor1394
2020-08-23 14:31:26 +08:00
parent 85e8b17171
commit 951c3fe16c
30 changed files with 323 additions and 263 deletions

View File

@@ -32,6 +32,7 @@
[QA 26如何使用背景组件有什么条件限制](#如何使用背景组件?有什么条件限制)
[QA 27Mesh can not have more than 65000 vertices?](#Mesh_cannot_have_more_than_65000_vertices)
[QA 28为什么serie里设置的参数运行后又被重置了?](#为什么serie里设置的参数运行后又被重置了)
[QA 29为什么升级到1.6.0版本后很多自定义颜色丢失了?应该如何升级?](#为什么升级到1.6.0版本后很多自定义颜色丢失了?应该如何升级)
## 如何调整坐标轴与背景的边距
@@ -149,6 +150,16 @@
答:检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。
## 为什么升级到1.6.0版本后很多自定义颜色丢失了?应该如何升级
1.6.0版本为了减少隐式转换,将所有的绘制相关的`Color`都改为了`Color32`,所以会导致一些自定义的颜色的丢失。影响到的主要组件有:`ItemStyle``LineStyle``AreaStyle``Vessel``VisualMap``AxisSplitArea``AxisSplitLine``GaugeAxis``SerieLabel`等。可以用脚本[UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)进行升级。
升级步骤如下:
1. 备份项目。
2. 下载或拷贝脚本[UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)放到旧项目的`Editor`下,将里面编译报错的`color`字段改为`Color.clear`(因为旧版本可能有些字段还不存在)。
3. 编译通过后,通过`菜单栏->XCharts->ExportColorConfig`导出旧版本的颜色配置文件(配置文件默认保存到`Assets`下的`color.config`)。
4. 升级`XCharts`到最新版本。
5. 通过`菜单栏->XCharts->ImportColorConfig``color.config`导入即可恢复自定义的颜色(如果`color.config`不在升级后的项目的`Assets`下的话需要拷贝到此目录下)。
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
[XChartsAPI接口](XChartsAPI.md)
[XCharts配置项手册](XCharts配置项手册.md)

View File

@@ -32,6 +32,7 @@
[QA 26: How do I use the background component? What are the conditions?](#How-do-I-use-the-background-component-What-are-the-conditions)
[QA 27: Mesh can not have more than 65000 vertices?](#Mesh-cannot-have-more-than-65000-vertices)
[QA 28: Why are the parameters set in Serie reset after they run?](#Why-are-the-parameters-set-in-Serie-reset-after-they-run)
[QA 29: Why are many custom colors lost after upgrading to 1.6.0? How should I upgrade?](#Why_are_many_custom_colors_lost_after_upgrading_to_1.6.0_How_should_I_upgrade)
## How-to-adjust-the-margin-between-the-axis-and-the=-background
@@ -145,6 +146,16 @@ A: This is the limit of `UGUI` on the number of vertices for a single `Graphic`.
A: Check whether `RemoveData()` and add new `Serie` in the code. If you want to keep the configuration of `Serie`, you can only `ClearData()` which just clear data and then readd the data to the old serie.
## Why_are_many_custom_colors_lost_after_upgrading_to_1.6.0_How_should_I_upgrade
A: In version `1.6.0`, in order to reduce implicit conversion, all drawing related `Color` was changed to `Color32`, so some custom colors were lost. The main components affected are: `ItemStyle`, `LineStyle`, `AreaStyle`, `Vessel`, `VisualMap`, `AxisSplitArea`, `AxisSplitLine`, `GaugeAxis`,`SerieLabel`, etc. Can use the script [UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) to upgrade.
The upgrade steps are as follows:
1. Back up the project.
2. Download or copy the script [UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) in the old project `Editor`, Change the `color` field inside to `color.clear` (because some fields may not exist in the old version).
3. After compilation, the old version of color configuration file is exported through `menu bar -> XCharts-> ExportColorConfig` (the configuration file is saved by default to `color.config` under `Assets`).
4. Upgrade `XCharts` to the latest version.
5. The custom color can be restored by importing `color.config` through `menu bar -> XCharts-> ImportColorConfig` (if `color.config` is not under `Assets` of the upgraded project, copy it to this directory).
[XCharts Homepage](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts API](xcharts-api-EN.md)
[XCharts Configuration](xcharts-configuration-EN.md)