mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
compatibility
This commit is contained in:
@@ -46,7 +46,7 @@ namespace XCharts.Editor
|
||||
[SettingsProviderGroup]
|
||||
static SettingsProvider[] CreateXCSettingsProvider()
|
||||
{
|
||||
var providers = new List<SettingsProvider> { new XCResourceImporterProvider() };
|
||||
var providers = new System.Collections.Generic.List<SettingsProvider> { new XCResourceImporterProvider() };
|
||||
|
||||
if (GetSettings() != null)
|
||||
{
|
||||
|
||||
@@ -766,7 +766,7 @@ namespace XCharts
|
||||
var fields = typeof(Serie).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
foreach (var field in fields)
|
||||
{
|
||||
if (field.IsDefined(typeof(SerializeField)))
|
||||
if (field.IsDefined(typeof(SerializeField), false))
|
||||
{
|
||||
field.SetValue(newSerie, field.GetValue(oldSerie));
|
||||
}
|
||||
|
||||
@@ -92,11 +92,11 @@ namespace XCharts
|
||||
}
|
||||
|
||||
public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
|
||||
float zebraGap, Color32 color, Color32 toColor, bool clip, GridCoord grid)
|
||||
float zebraGap, Color32 color, Color32 toColor, bool clip, GridCoord grid, float maxDistance)
|
||||
{
|
||||
ClampInChart(ref p1);
|
||||
ClampInChart(ref p2);
|
||||
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor);
|
||||
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor, maxDistance);
|
||||
}
|
||||
|
||||
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize,
|
||||
|
||||
@@ -611,10 +611,11 @@ namespace XCharts
|
||||
list.AddRange(fileds2);
|
||||
foreach (var field in list)
|
||||
{
|
||||
var attribute1 = field.GetCustomAttribute<ListForSerie>();
|
||||
var attribute1 = field.GetAttribute<ListForSerie>(false);
|
||||
if (attribute1 != null)
|
||||
m_TypeListForSerie.Add(attribute1.type, field);
|
||||
var attribute2 = field.GetCustomAttribute<ListForComponent>();
|
||||
|
||||
var attribute2 = field.GetAttribute<ListForComponent>(false);
|
||||
if (attribute2 != null)
|
||||
m_TypeListForComponent.Add(attribute2.type, field);
|
||||
}
|
||||
|
||||
@@ -418,14 +418,14 @@ namespace XCharts
|
||||
plt = (plb + plt) / 2;
|
||||
prt = (prt + prb) / 2;
|
||||
chart.DrawClipZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
barColor, barToColor, serie.clip, grid);
|
||||
barColor, barToColor, serie.clip, grid, grid.context.width);
|
||||
}
|
||||
else
|
||||
{
|
||||
plb = (prb + plb) / 2;
|
||||
plt = (plt + prt) / 2;
|
||||
chart.DrawClipZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
barColor, barToColor, serie.clip, grid);
|
||||
barColor, barToColor, serie.clip, grid, grid.context.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -897,7 +897,7 @@ namespace XCharts
|
||||
if (emphasis != null)
|
||||
emphasis.ClearVerticesDirty();
|
||||
if (lineArrow != null)
|
||||
lineArrow?.ClearVerticesDirty();
|
||||
lineArrow.ClearVerticesDirty();
|
||||
}
|
||||
|
||||
public override void ClearComponentDirty()
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace XCharts
|
||||
public static int InvokeListCount(object obj, FieldInfo field)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
return (int)list.GetType().GetProperty("Count").GetValue(list);
|
||||
return (int)list.GetType().GetProperty("Count").GetValue(list, null);
|
||||
}
|
||||
|
||||
public static void InvokeListAdd(object obj, FieldInfo field, object item)
|
||||
@@ -37,7 +37,7 @@ namespace XCharts
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
var listType = list.GetType();
|
||||
var count = Convert.ToInt32(listType.GetProperty("Count").GetValue(list));
|
||||
var count = Convert.ToInt32(listType.GetProperty("Count").GetValue(list, null));
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var item = listType.GetProperty("Item").GetValue(list, new object[] { i });
|
||||
|
||||
@@ -59,10 +59,27 @@ namespace XCharts
|
||||
return m_AssemblyTypes;
|
||||
}
|
||||
|
||||
public static T GetAttribute<T>(this Type type) where T : Attribute
|
||||
public static T GetAttribute<T>(this Type type, bool check = true) where T : Attribute
|
||||
{
|
||||
Assert.IsTrue(type.IsDefined(typeof(T), false), "Attribute not found:" + type.Name);
|
||||
return (T)type.GetCustomAttributes(typeof(T), false)[0];
|
||||
if (type.IsDefined(typeof(T), false))
|
||||
return (T)type.GetCustomAttributes(typeof(T), false)[0];
|
||||
else
|
||||
{
|
||||
if (check)
|
||||
Assert.IsTrue(false, "Attribute not found:" + type.Name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static T GetAttribute<T>(this MemberInfo type, bool check = true) where T : Attribute
|
||||
{
|
||||
if (type.IsDefined(typeof(T), false))
|
||||
return (T)type.GetCustomAttributes(typeof(T), false)[0];
|
||||
else
|
||||
{
|
||||
if (check)
|
||||
Assert.IsTrue(false, "Attribute not found:" + type.Name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CopyFolder(string sourPath, string destPath)
|
||||
|
||||
@@ -373,9 +373,25 @@ namespace XUGL
|
||||
/// <param name="color">起始颜色</param>
|
||||
/// <param name="toColor">结束颜色</param>
|
||||
public static void DrawZebraLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
|
||||
float zebraWidth, float zebraGap, Color32 color, Color32 toColor)
|
||||
float zebraWidth, float zebraGap, Color32 color, Color32 toColor, float maxDistance)
|
||||
{
|
||||
DrawDotLine(vh, startPoint, endPoint, width, color, toColor, zebraWidth, zebraGap);
|
||||
var dist = Vector3.Distance(startPoint, endPoint);
|
||||
if (dist < 0.1f) return;
|
||||
if (zebraWidth == 0) zebraWidth = 3 * width;
|
||||
if (zebraGap == 0) zebraGap = 3 * width;
|
||||
var allSegment = Mathf.CeilToInt(maxDistance / (zebraWidth + zebraGap));
|
||||
var segment = Mathf.CeilToInt(dist / maxDistance * allSegment);
|
||||
var dir = (endPoint - startPoint).normalized;
|
||||
var sp = startPoint;
|
||||
var np = Vector3.zero;
|
||||
var isGradient = !color.Equals(toColor);
|
||||
zebraWidth = (maxDistance - zebraGap * (allSegment - 1)) / allSegment;
|
||||
for (int i = 1; i <= segment; i++)
|
||||
{
|
||||
np = sp + dir * zebraWidth;
|
||||
DrawLine(vh, sp, np, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / allSegment) : color);
|
||||
sp = np + dir * zebraGap;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user