public static void SetStyle(CText text, int styleIdx = 0) { //if (text.colorIdx >= colors.Length) // text.colorIdx = colors.Length - 1; //string[] styleStr = colors[text.colorIdx].Split(';'); //text.color = GetColor(styleStr[0]); //if (!text.shadowEff) // text.shadowEff = text.gameObject.AddComponent<UnityEngine.UI.Shadow>(); //if (!text.outlineEff) // text.outlineEff = text.gameObject.AddComponent<Outline>(); //text.shadowEff.enabled = false; //text.outlineEff.enabled = false; //if (styleStr.Length > 1) //{ // for (int i = 1; i < styleStr.Length; i++) // { // string[] osStr = styleStr[i].Split(':'); // if (osStr[0] == "s") // { // text.shadowEff.enabled = true; // text.shadowEff.effectColor = GetColor(osStr[1]); // } // else if (osStr[0] == "o") // { // text.outlineEff.enabled = true; // text.outlineEff.effectColor = GetColor(osStr[1]); // } // } //} if (!text) { return; } UnityEngine.UI.Shadow[] shadows = text.GetComponentsInChildren <UnityEngine.UI.Shadow>(); for (int i = 0; i < shadows.Length; i++) { DestroyImmediate(shadows[i]); } if (styleIdx == 1) { UnityEngine.UI.Shadow sd = text.gameObject.AddComponent <UnityEngine.UI.Shadow>(); sd.effectColor = GetColor(sdColor); } else if (styleIdx == 2) { UnityEngine.UI.Outline ol = text.gameObject.AddComponent <UnityEngine.UI.Outline>(); ol.effectColor = GetColor(olColor); } }