Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ColorLoop() {
- TMP_Text scriptWordCash;
- bool quotationDetected = false;
- bool comment_V1_Detected = false;
- bool comment_V2_Detected = false;
- foreach (GameObject _scriptTextObj in scriptTextObj)
- {
- scriptWordCash = _scriptTextObj.GetComponent<TMP_Text>();
- //-- quoation start --//
- if (scriptWordCash.text == "\"")
- {
- quotationDetected = !quotationDetected;
- }
- //-- quoation End --//
- if (quotationDetected)
- {
- ColorScript(scriptWordCash, Color.yellow);
- }
- //-- comment v1 Start --//
- if (scriptWordCash.text == "//")
- {
- comment_V1_Detected = true;
- }
- //-- comment v1 End --//
- if (comment_V1_Detected )
- {
- ColorScript(scriptWordCash, Color.green);
- if (scriptWordCash.text == "\n" || !comment_V2_Detected)
- {
- comment_V1_Detected = false;
- }
- }
- //-- comment v2 Start --//
- if (scriptWordCash.text == "/*")
- {
- comment_V2_Detected = true;
- }
- //-- comment v2 End --//
- if (comment_V2_Detected)
- {
- ColorScript(scriptWordCash, Color.green);
- if (scriptWordCash.text == "*/")
- {
- comment_V2_Detected = false;
- }
- }
- // Give Text a random color
- if (!quotationDetected &&
- !comment_V1_Detected &&
- !comment_V2_Detected)
- {
- ColorScript(scriptWordCash, new Color(Random.value, Random.value, Random.value, 1));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement