mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 03:58:49 +00:00
修复对数轴logBase设置为0时会卡死的问题
This commit is contained in:
@@ -66,7 +66,13 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
EditorGUI.PropertyField(drawRect, m_LogBaseE);
|
EditorGUI.PropertyField(drawRect, m_LogBaseE);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
EditorGUI.PropertyField(drawRect, m_LogBase);
|
EditorGUI.PropertyField(drawRect, m_LogBase);
|
||||||
|
if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
|
||||||
|
{
|
||||||
|
m_LogBase.floatValue = 10;
|
||||||
|
}
|
||||||
|
EditorGUI.EndChangeCheck();
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
if (type == Axis.AxisType.Value)
|
if (type == Axis.AxisType.Value)
|
||||||
|
|||||||
@@ -169,7 +169,11 @@ namespace XCharts
|
|||||||
public float logBase
|
public float logBase
|
||||||
{
|
{
|
||||||
get { return m_LogBase; }
|
get { return m_LogBase; }
|
||||||
set { if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty(); }
|
set
|
||||||
|
{
|
||||||
|
if (value <= 0 || value == 1) value = 10;
|
||||||
|
if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// On the log axis, if base e is the natural number, and is true, logBase fails.
|
/// On the log axis, if base e is the natural number, and is true, logBase fails.
|
||||||
@@ -745,7 +749,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public float GetLogValue(float value)
|
public float GetLogValue(float value)
|
||||||
{
|
{
|
||||||
if (value <= 0) return 0;
|
if (value <= 0 || value == 1) return 0;
|
||||||
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
|
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user