private static void GetOrCreateRectTransformList(ref Dictionary <string, RectTransform> rectTransforms) { if (rectTransforms == null) { rectTransforms = new Dictionary <string, RectTransform>(); foreach (var item in SceneInfoGrabber <RectTransform> .GetUIComponentsOnScene()) { rectTransforms[item.name] = item; } } }
#pragma warning restore 0649 void Awake() { Instance = this; //get my components audioSource = GetComponent <AudioSource>(); //clear static lists StaticViews.Clear(); BackStack.Clear(); FullScreenFadeStack.Clear(); //init other objects dragger = new Dragger(); soundsManager = new SoundsManager(BackgroundSoundPrefab, FadeVolume, VolumeChangeSpeed); //find all views var views = SceneInfoGrabber <BaseView> .GetUIComponentsOnScene(scene : gameObject.scene); //grab components for views foreach (var view in views) { view.GrabComponents(); StaticViews[view.GetType().Name] = view; } //grab views for views foreach (var view in views) { view.GrabViews(StaticViews); } //init views foreach (var view in views) { view.Init(); } //subscribe views foreach (var view in views) { view.AutoSubscribe(); } //show views foreach (var view in views.Where(v => v.ShowAtStart)) { Show(view, null, noAnimation: true); } //init gestures InitGestures(); }
public static void TranslateScene() { foreach (var text in SceneInfoGrabber <Text> .GetUIComponentsOnScene()) { text.text = text.text.Translate(); } foreach (var text in SceneInfoGrabber <TMPro.TextMeshProUGUI> .GetUIComponentsOnScene()) { text.text = text.text.Translate(); } foreach (var dd in SceneInfoGrabber <Dropdown> .GetUIComponentsOnScene()) { foreach (var opt in dd.options) { opt.text = opt.text.Translate(); } } }
static IEnumerable <string> GrabAllTextsOnScene() { foreach (var text in SceneInfoGrabber <Text> .GetUIComponentsOnScene()) { yield return(text.text); } foreach (var text in SceneInfoGrabber <TMPro.TextMeshProUGUI> .GetUIComponentsOnScene()) { yield return(text.text); } foreach (var dd in SceneInfoGrabber <Dropdown> .GetUIComponentsOnScene()) { foreach (var opt in dd.options) { yield return(opt.text); } } }