using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using TMPro; using UnityEngine; using UnityEngine.UI; public class Set : MonoBehaviour { public static void alpha(GameObject O, bool TF) { if (O == null) { Debug.Log("No object passed"); return; } float a = 0; if (TF) a = 1; O.GetComponent().alpha = a; O.GetComponent().interactable = TF; O.GetComponent().blocksRaycasts = TF; } public static void alphaAllChild(GameObject PARENT, bool TF) { float a = 0; foreach (Transform O in PARENT.transform) { a = 0; if (TF) a = 1; O.gameObject.GetComponent().alpha = a; O.gameObject.GetComponent().interactable = TF; O.gameObject.GetComponent().blocksRaycasts = TF; } } public static void AlphaAllChildwithValue(GameObject PARENT, bool TF,float value) { float a = 0; foreach (Transform O in PARENT.transform) { a = value; if (TF) a = 1; O.gameObject.GetComponent().alpha = a; O.gameObject.GetComponent().interactable = TF; O.gameObject.GetComponent().blocksRaycasts = TF; } } public static void GlobalColorAndTranslate() { TRANS.go(); //BTN_Hide.ShowBTNS(); COLORSET.On(); //ColorSet.Do(); } public static void Layer(GameObject obj, int newLayer) { if (obj == null || obj.name.Length <= 4) return; List Category = new() { "wind", "pati", "door", "open" }; if (!Category.Contains(obj.name[..4])) { obj.layer = newLayer; foreach (Transform child in obj.transform) { if (child != null) { if(child.gameObject.layer != 20) { Layer(child.gameObject, newLayer); } } } } } public static string AsString(string[] StringArray) { string NewString = ""; for (int i = 0; i < StringArray.Length; i++) { NewString += StringArray[i]; if (i < StringArray.Length - 1) NewString += ","; } return NewString; } public static void ToggleGroupToAllChild(string path) { ToggleGroup TG; if (!GameObject.Find("Tog_" + path)) { TG = Instantiate(Get.o2("TOOGLEGROUP", "toggleForAll")).GetComponent(); TG.name = "Tog_" + path; } else { TG = GameObject.Find("Tog_" + path).GetComponent(); } GameObject O = Get.o1(path); for (int i = 0; i < O.transform.childCount; i++) { O.transform.GetChild(i).GetComponent().group = TG; } } public static string NewValueCode(string Code, string NewValue, int position, string Divider) { string[] CodeSplit = Code.Split(Divider); string NewCode = ""; for (int i = 0; i < CodeSplit.Length; i++) { if (i != position) { NewCode += CodeSplit[i]; } else { NewCode += NewValue; } if (i < CodeSplit.Length - 1) NewCode += Divider; } return NewCode; } public static string Chars(string s) { return Regex.Replace(s, @"[^\x20-\x7F]", ""); } }