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 checkedWords = new List(); private bool bChecked = false;

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;
}

}

Unity C# Script: Modify Score System to Prioritize String Detection Order

原文地址: https://www.cveoy.top/t/topic/plk5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录