优化性能,降低GC

This commit is contained in:
monitor1394
2019-07-23 21:43:01 +08:00
parent d0b51d9297
commit cb6d0765ca
12 changed files with 276 additions and 161 deletions

View File

@@ -1,4 +1,5 @@

using System.Collections.Generic;
using UnityEngine;
using System;
@@ -62,6 +63,22 @@ namespace XCharts
return m_ColorPalette[index];
}
Dictionary<int, string> _colorDic = new Dictionary<int, string>();
public string GetColorStr(int index)
{
if (index < 0)
{
index = 0;
}
index = index % m_ColorPalette.Length;
if (_colorDic.ContainsKey(index)) return _colorDic[index];
else
{
_colorDic[index] = ColorUtility.ToHtmlStringRGBA(GetColor(index));
return _colorDic[index];
}
}
public void Copy(ThemeInfo theme)
{
m_Font = theme.m_Font;