Unity C# Script: Modify Score System to Prioritize String Detection Order
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class jiFen : MonoBehaviour
{
public Text point;
private string[] checkStrings = { 'a', 'b', 'c' };
private int score = 0;
private List
private void Start()
{
Application.logMessageReceived += OnLogMessageReceived;
}
private void OnLogMessageReceived(string logString, string stackTrace, LogType logType)
{
if (!bChecked)
{
foreach (string word in checkStrings)
{
if (logString.Contains(word) && !checkedWords.Contains(word))
{
if (word == 'b')
{
bChecked = true;
}
score += 5;
checkedWords.Add(word);
point.text = score.ToString();
break;
}
}
}
else
{
if (logString.Contains('c') && !checkedWords.Contains('c'))
{
score += 5;
checkedWords.Add('c');
point.text = score.ToString();
}
}
}
private void OnDestroy()
{
Application.logMessageReceived -= OnLogMessageReceived;
}
}
原文地址: https://www.cveoy.top/t/topic/plk5 著作权归作者所有。请勿转载和采集!