Ejemplo n.º 1
0
        /// <summary>
        /// 通过name转换颜色
        /// </summary>
        /// <param name="chartName"></param>
        public void SwapColors(string chartName)
        {
            if (string.IsNullOrEmpty(chartName) || mainTexture == null || srcChart == null || swapCharts == null)
            {
                return;
            }

            // 如果是源颜色组的name,清除颜色,否则转换
            if (chartName == srcChart.name)
            {
                ClearSwapColors();
            }
            else
            {
                ColorChart chart = swapCharts.Find(c => c.name == chartName);
                if (chart != null)
                {
                    Texture2D swapTexture;
                    if (chart.TryGetSwapTexture(mainTexture, srcChart, out swapTexture))
                    {
                        SetMaterialPropertyBlockTexture(swapTexture);
                    }
                }
            }
        }