养成基本完毕,新UI,修bug,装备初步,
This commit is contained in:
@@ -5,14 +5,15 @@ using UnityEngine;
|
||||
|
||||
public class URadarChartController : MonoBehaviour
|
||||
{
|
||||
private const int AxisCount = 6;
|
||||
|
||||
[Header("Chart")]
|
||||
public UGUIChartBridge chartBridge;
|
||||
public bool rebuildOnEnable = true;
|
||||
public bool showReferenceSeries = false;
|
||||
public int enforcedSortOrder = 0;
|
||||
|
||||
[Header("Axis Count")]
|
||||
[Min(3)] public int axisCount = 6;
|
||||
|
||||
[Header("Series Names")]
|
||||
public string mainSeriesName = "Player";
|
||||
public string referenceSeriesName = "Reference";
|
||||
@@ -47,6 +48,18 @@ public class URadarChartController : MonoBehaviour
|
||||
public Color axisLabelColor = Color.white;
|
||||
public Vector2 axisLabelOffset = Vector2.zero;
|
||||
|
||||
[Header("Tooltip")]
|
||||
public bool overrideTooltipStyle = false;
|
||||
public bool overrideTooltipFont = false;
|
||||
public Font tooltipFont;
|
||||
public int tooltipFontSize = 18;
|
||||
public Color tooltipTextColor = Color.white;
|
||||
public Color tooltipBackgroundColor = new Color(0f, 0f, 0f, 0.85f);
|
||||
public Color tooltipBorderColor = new Color(1f, 1f, 1f, 0f);
|
||||
[Min(0f)] public float tooltipBorderWidth = 0f;
|
||||
[Min(0f)] public float tooltipCornerRadius = 4f;
|
||||
public Vector4 tooltipPadding = new Vector4(8f, 8f, 4f, 4f);
|
||||
|
||||
[Header("Style")]
|
||||
public bool overrideSeriesStyle = true;
|
||||
public Color mainStrokeColor = new Color32(82, 126, 255, 255);
|
||||
@@ -56,6 +69,8 @@ public class URadarChartController : MonoBehaviour
|
||||
public Color referenceFillColor = new Color(72f / 255f, 229f / 255f, 229f / 255f, 0.22f);
|
||||
public Color referencePointColor = Color.white;
|
||||
public float radarPlotPadding = 8f;
|
||||
[Min(0f)] public float radarInnerRadius = 0f;
|
||||
[Min(0f)] public float radarLabelRadialOffset = 0f;
|
||||
|
||||
private ChartProfile sourceProfile;
|
||||
private ChartProfile runtimeProfile;
|
||||
@@ -92,7 +107,13 @@ public class URadarChartController : MonoBehaviour
|
||||
showReferenceSeries = false;
|
||||
NormalizeAxes();
|
||||
axisLabelFontSize = Mathf.Max(1, axisLabelFontSize);
|
||||
tooltipFontSize = Mathf.Max(1, tooltipFontSize);
|
||||
gridLineWidth = Mathf.Max(0.1f, gridLineWidth);
|
||||
radarInnerRadius = Mathf.Max(0f, radarInnerRadius);
|
||||
radarLabelRadialOffset = Mathf.Max(0f, radarLabelRadialOffset);
|
||||
tooltipBorderWidth = Mathf.Max(0f, tooltipBorderWidth);
|
||||
tooltipCornerRadius = Mathf.Max(0f, tooltipCornerRadius);
|
||||
axisCount = Mathf.Max(3, axisCount);
|
||||
QueueRebuild();
|
||||
}
|
||||
|
||||
@@ -156,6 +177,32 @@ public class URadarChartController : MonoBehaviour
|
||||
QueueRebuild();
|
||||
}
|
||||
|
||||
public void SetAxisData(int index, string label, float value, float referenceValueToSet)
|
||||
{
|
||||
NormalizeAxes();
|
||||
if (index < 0 || index >= axes.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
URadarAxisEntry axis = axes[index];
|
||||
if (axis == null)
|
||||
{
|
||||
axis = new URadarAxisEntry();
|
||||
axes[index] = axis;
|
||||
}
|
||||
|
||||
axis.label = string.IsNullOrWhiteSpace(label) ? $"Axis {index + 1}" : label.Trim();
|
||||
axis.value = Mathf.Clamp(value, minValue, maxValue);
|
||||
axis.referenceValue = Mathf.Clamp(referenceValueToSet, minValue, maxValue);
|
||||
QueueRebuild();
|
||||
}
|
||||
|
||||
public void NormalizeAxesForExternalUse()
|
||||
{
|
||||
NormalizeAxes();
|
||||
}
|
||||
|
||||
private bool TryGetAxis(int index, out URadarAxisEntry axis)
|
||||
{
|
||||
NormalizeAxes();
|
||||
@@ -299,7 +346,11 @@ public class URadarChartController : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
if (!overrideLabelFont || axisLabelFont == null)
|
||||
bool useTooltipStyle = overrideTooltipStyle;
|
||||
bool useTooltipFont = overrideTooltipFont && tooltipFont != null;
|
||||
bool useLabelFont = overrideLabelFont && axisLabelFont != null;
|
||||
|
||||
if (!useLabelFont && !useTooltipFont && !useTooltipStyle)
|
||||
{
|
||||
chartBridge.ChartElement.Theme = null;
|
||||
return;
|
||||
@@ -312,9 +363,21 @@ public class URadarChartController : MonoBehaviour
|
||||
runtimeTheme.hideFlags = HideFlags.DontSave;
|
||||
}
|
||||
|
||||
runtimeTheme.primaryFont = axisLabelFont;
|
||||
runtimeTheme.axisFontSize = axisLabelFontSize;
|
||||
runtimeTheme.primaryFont = useLabelFont ? axisLabelFont : null;
|
||||
runtimeTheme.axisFontSize = useLabelFont ? axisLabelFontSize : -1f;
|
||||
runtimeTheme.tooltipFont = useTooltipFont ? tooltipFont : null;
|
||||
runtimeTheme.tooltipFontSize = (useTooltipFont || useTooltipStyle) ? tooltipFontSize : -1f;
|
||||
runtimeTheme.tooltipTextColor = useTooltipStyle ? tooltipTextColor : Color.white;
|
||||
runtimeTheme.tooltipBackgroundColor = useTooltipStyle ? tooltipBackgroundColor : new Color(0f, 0f, 0f, 0.8f);
|
||||
runtimeTheme.tooltipBorderColor = useTooltipStyle ? tooltipBorderColor : new Color(0f, 0f, 0f, 0f);
|
||||
runtimeTheme.tooltipBorderWidth = useTooltipStyle ? tooltipBorderWidth : 0f;
|
||||
runtimeTheme.tooltipCornerRadius = useTooltipStyle ? tooltipCornerRadius : 4f;
|
||||
runtimeTheme.tooltipPadding = useTooltipStyle ? tooltipPadding : new Vector4(8f, 8f, 4f, 4f);
|
||||
|
||||
// Force ChartElement.Theme setter to re-apply tooltip visuals even when reusing the same runtime theme instance.
|
||||
chartBridge.ChartElement.Theme = null;
|
||||
chartBridge.ChartElement.Theme = runtimeTheme;
|
||||
|
||||
}
|
||||
|
||||
private void ConfigureSeries(Serie serie, string serieName, bool isMainSeries)
|
||||
@@ -337,9 +400,10 @@ public class URadarChartController : MonoBehaviour
|
||||
serie.settings = radarSettings;
|
||||
}
|
||||
|
||||
radarSettings.radar.innerRadius = 0f;
|
||||
radarSettings.radar.innerRadius = radarInnerRadius;
|
||||
radarSettings.radar.outerRadius = 0f;
|
||||
radarSettings.radar.plot.padding = radarPlotPadding;
|
||||
radarSettings.radar.plot.labelRadialOffset = radarLabelRadialOffset;
|
||||
|
||||
radarSettings.area.show = true;
|
||||
radarSettings.point.show = true;
|
||||
@@ -367,7 +431,7 @@ public class URadarChartController : MonoBehaviour
|
||||
serie.seriesData.Clear();
|
||||
}
|
||||
|
||||
for (int i = 0; i < AxisCount; i++)
|
||||
for (int i = 0; i < axisCount; i++)
|
||||
{
|
||||
URadarAxisEntry axis = axes[i];
|
||||
float value = isMainSeries ? axis.value : axis.referenceValue;
|
||||
@@ -383,8 +447,8 @@ public class URadarChartController : MonoBehaviour
|
||||
|
||||
private List<string> BuildLabels()
|
||||
{
|
||||
List<string> labels = new List<string>(AxisCount);
|
||||
for (int i = 0; i < AxisCount; i++)
|
||||
List<string> labels = new List<string>(axisCount);
|
||||
for (int i = 0; i < axisCount; i++)
|
||||
{
|
||||
string label = axes[i] != null ? axes[i].label : null;
|
||||
labels.Add(string.IsNullOrWhiteSpace(label) ? $"Axis {i + 1}" : label.Trim());
|
||||
@@ -400,7 +464,9 @@ public class URadarChartController : MonoBehaviour
|
||||
axes = new List<URadarAxisEntry>();
|
||||
}
|
||||
|
||||
while (axes.Count < AxisCount)
|
||||
axisCount = Mathf.Max(3, axisCount);
|
||||
|
||||
while (axes.Count < axisCount)
|
||||
{
|
||||
axes.Add(new URadarAxisEntry
|
||||
{
|
||||
@@ -410,9 +476,9 @@ public class URadarChartController : MonoBehaviour
|
||||
});
|
||||
}
|
||||
|
||||
if (axes.Count > AxisCount)
|
||||
if (axes.Count > axisCount)
|
||||
{
|
||||
axes.RemoveRange(AxisCount, axes.Count - AxisCount);
|
||||
axes.RemoveRange(axisCount, axes.Count - axisCount);
|
||||
}
|
||||
|
||||
for (int i = 0; i < axes.Count; i++)
|
||||
|
||||
@@ -43,7 +43,7 @@ public class uBehaviourRaderController : MonoBehaviour
|
||||
public float normalizedSpreadPenalty = 0.30f;
|
||||
|
||||
private Coroutine loadRoutine;
|
||||
private bool settingsSubscribed;
|
||||
private bool overlaySubscribed;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -52,7 +52,8 @@ public class uBehaviourRaderController : MonoBehaviour
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
BindSettingsVisibility();
|
||||
BindOverlayVisibility();
|
||||
ApplyOverlayVisibility(btmandtopController.CurrentOverlayPanelsVisible);
|
||||
if (reloadOnEnable && Application.isPlaying)
|
||||
{
|
||||
BeginLoad();
|
||||
@@ -61,7 +62,7 @@ public class uBehaviourRaderController : MonoBehaviour
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
UnsubscribeSettingsVisibility();
|
||||
UnsubscribeOverlayVisibility();
|
||||
if (loadRoutine != null)
|
||||
{
|
||||
StopCoroutine(loadRoutine);
|
||||
@@ -100,7 +101,7 @@ public class uBehaviourRaderController : MonoBehaviour
|
||||
chartBridge != null &&
|
||||
chartBridge.Profile != null)
|
||||
{
|
||||
ApplySettingsVisibility(btmandtopController.CurrentSettingsVisible);
|
||||
ApplyOverlayVisibility(btmandtopController.CurrentOverlayPanelsVisible);
|
||||
ApplySummary(BuildSummary(RecentPlayHistoryStore.GetRecords()));
|
||||
loadRoutine = null;
|
||||
yield break;
|
||||
@@ -153,35 +154,35 @@ public class uBehaviourRaderController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void BindSettingsVisibility()
|
||||
private void BindOverlayVisibility()
|
||||
{
|
||||
if (settingsSubscribed)
|
||||
if (overlaySubscribed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
btmandtopController.GlobalSettingsVisibilityChanged += HandleSettingsVisibilityChanged;
|
||||
settingsSubscribed = true;
|
||||
btmandtopController.GlobalOverlayPanelVisibilityChanged += HandleOverlayPanelsVisibilityChanged;
|
||||
overlaySubscribed = true;
|
||||
}
|
||||
|
||||
private void UnsubscribeSettingsVisibility()
|
||||
private void UnsubscribeOverlayVisibility()
|
||||
{
|
||||
if (!settingsSubscribed)
|
||||
if (!overlaySubscribed)
|
||||
{
|
||||
settingsSubscribed = false;
|
||||
overlaySubscribed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
btmandtopController.GlobalSettingsVisibilityChanged -= HandleSettingsVisibilityChanged;
|
||||
settingsSubscribed = false;
|
||||
btmandtopController.GlobalOverlayPanelVisibilityChanged -= HandleOverlayPanelsVisibilityChanged;
|
||||
overlaySubscribed = false;
|
||||
}
|
||||
|
||||
private void HandleSettingsVisibilityChanged(bool visible)
|
||||
private void HandleOverlayPanelsVisibilityChanged(bool visible)
|
||||
{
|
||||
ApplySettingsVisibility(visible);
|
||||
ApplyOverlayVisibility(visible);
|
||||
}
|
||||
|
||||
private void ApplySettingsVisibility(bool settingsVisible)
|
||||
private void ApplyOverlayVisibility(bool overlayVisible)
|
||||
{
|
||||
if (uRaderObj == null)
|
||||
{
|
||||
@@ -194,7 +195,7 @@ public class uBehaviourRaderController : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
uRaderObj.SetActive(!settingsVisible);
|
||||
uRaderObj.SetActive(!overlayVisible);
|
||||
}
|
||||
|
||||
private void ApplySummary(BehaviourRadarSummary summary)
|
||||
|
||||
Reference in New Issue
Block a user