public ToggleSet AddToggleSet(string text, System.Action <bool> setter, bool initialValue) { var labelSource = GameObject.Find(LabelSourcePath); var toggleSource = GameObject.Find(ToggleSourcePath); var containingElement = new GameObject().AddComponent <RectTransform>(); containingElement.name = text; containingElement.SetParent(Content.transform); containingElement.transform.localScale = new Vector3(1f, 1f, 1f); containingElement.transform.localPosition = new Vector3(0f, Offset, 0f); var label = Object.Instantiate(labelSource).GetComponent <TextMeshProUGUI>(); label.transform.SetParent(containingElement.transform); label.transform.localScale = new Vector3(1f, 1f, 1f); label.transform.localPosition = new Vector3(4f, 0f, 0f); var toggle = Object.Instantiate(toggleSource).GetComponent <Toggle>(); toggle.transform.SetParent(containingElement.transform); toggle.transform.localScale = new Vector3(1f, 1f, 1f); toggle.transform.localPosition = new Vector3(160f, 0f, 0f); var toggleSet = new ToggleSet(label, toggle, text, setter, initialValue); Toggles.Add(toggleSet); return(toggleSet); }
private void InitStudioUI(Scene s, LoadSceneMode lsm) { if (s.name != "Studio") { return; } SceneManager.sceneLoaded -= InitStudioUI; var CameraLayerDefault = Camera.main.gameObject.layer; var menu = new ScreenEffectMenu(StudioSceneSettingsPlugin.PluginNameInternal); #if KK MapMasking = menu.AddToggleSet("Map Masking", value => Camera.main.gameObject.layer = value ? StudioSceneSettingsCore.CameraMapMaskingLayer : CameraLayerDefault, false); #endif NearClipPlane = menu.AddSliderSet("Near Clip Plane", value => NearClipSetter(value), NearClipDefault, 0.01f, 10f); FarClipPlane = menu.AddSliderSet("Far Clip Plane", value => FarClipSetter(value), FarClipDefault, 1f, 10000f); NearClipPlane.EnforceSliderMaximum = false; FarClipPlane.EnforceSliderMaximum = false; }