diff --git a/src/UI/Panels/LightsManger.cs b/src/UI/Panels/LightsManger.cs index 8e2b365..1c6f942 100644 --- a/src/UI/Panels/LightsManger.cs +++ b/src/UI/Panels/LightsManger.cs @@ -23,7 +23,7 @@ namespace UnityExplorer.UI.Panels public override string Name => "Lights Manager"; public override UIManager.Panels PanelType => UIManager.Panels.LightsManager; - public override int MinWidth => 600; + public override int MinWidth => 650; public override int MinHeight => 500; public override Vector2 DefaultAnchorMin => new(0.4f, 0.4f); public override Vector2 DefaultAnchorMax => new(0.6f, 0.6f); @@ -38,6 +38,7 @@ namespace UnityExplorer.UI.Panels List UIElements = new List(); //Declaring a counter instead of just using the length of the createdLight list in case we delete lights, so we don't end up with two lists with the same name. int lightCounter = 0; + float defaultIntensity = 10; // ~~~~~~~~ UI construction / callbacks ~~~~~~~~ @@ -58,6 +59,8 @@ namespace UnityExplorer.UI.Panels UIFactory.SetLayoutElement(createPointLightButton.GameObject, minWidth: 150, minHeight: 25); createPointLightButton.OnClick += () => CreateLight(LightType.Point); + AddInputField(horiGroup, "Default Itensity", "Default itensity:", $"{10}", DefaultIntensity_OnEndEdit); + //Turn off vanilla lights Toggle vanillaLightsToggle = new Toggle(); GameObject toggleObj = UIFactory.CreateToggle(horiGroup, "Toggle Game Lights", out vanillaLightsToggle, out Text toggleText); @@ -160,20 +163,19 @@ namespace UnityExplorer.UI.Panels lightComponent.type = requestedType; lightComponent.shadows = LightShadows.Soft; lightComponent.shadowBias = 0; + lightComponent.intensity = defaultIntensity; PropertyInfo shadowResolution = typeof(Light).GetProperty("shadowCustomResolution"); shadowResolution.SetValue(lightComponent, 5000, null); switch(requestedType){ case LightType.Spot: - lightComponent.intensity = 200; lightComponent.range = 1000; GameObject arrow = ArrowGenerator.CreateArrow(Vector3.zero, Quaternion.identity, lightComponent.color); arrow.SetActive(false); arrow.transform.SetParent(obj.transform, true); break; case LightType.Point: - lightComponent.intensity = 10; GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); @@ -227,5 +229,28 @@ namespace UnityExplorer.UI.Panels return; } } + + GameObject AddInputField(GameObject parent, string name, string labelText, string placeHolder, Action onInputEndEdit) + { + Text posLabel = UIFactory.CreateLabel(parent, $"{name}_Label", labelText); + UIFactory.SetLayoutElement(posLabel.gameObject, minWidth: 75, minHeight: 25); + + InputFieldRef inputField = UIFactory.CreateInputField(parent, $"{name}_Input", placeHolder); + UIFactory.SetLayoutElement(inputField.GameObject, minWidth: 50, minHeight: 25); + inputField.Component.GetOnEndEdit().AddListener(onInputEndEdit); + + return parent; + } + + void DefaultIntensity_OnEndEdit(string input) + { + if (!ParseUtility.TryParse(input, out int parsed, out Exception parseEx)) + { + ExplorerCore.LogWarning($"Could not parse value: {parseEx.ReflectionExToString()}"); + return; + } + + defaultIntensity = parsed; + } } } diff --git a/src/UI/Panels/MiscPanel.cs b/src/UI/Panels/MiscPanel.cs index 7408c84..76fb70d 100644 --- a/src/UI/Panels/MiscPanel.cs +++ b/src/UI/Panels/MiscPanel.cs @@ -35,8 +35,8 @@ namespace UnityExplorer.UI.Panels public override string Name => "Misc"; public override UIManager.Panels PanelType => UIManager.Panels.Misc; - public override int MinWidth => 275; - public override int MinHeight => 150; + public override int MinWidth => 325; + public override int MinHeight => 200; public override Vector2 DefaultAnchorMin => new(0.4f, 0.4f); public override Vector2 DefaultAnchorMax => new(0.6f, 0.6f); public override bool NavButtonWanted => true; @@ -266,6 +266,17 @@ namespace UnityExplorer.UI.Panels HighLodToggle.isOn = false; HighLodToggleText.text = "High LODs Toggle"; + // Screenshot function + GameObject TakeScreenshotHoriGroup = UIFactory.CreateHorizontalGroup(ContentRoot, "Take screenshot", false, false, true, true, 3, + default, new Color(1, 1, 1, 0), TextAnchor.MiddleLeft); + UIFactory.SetLayoutElement(TakeScreenshotHoriGroup, minHeight: 25, flexibleWidth: 9999); + + ButtonRef takeScreenshot = UIFactory.CreateButton(TakeScreenshotHoriGroup, "TakeScreenshot", "Take screenshot"); + UIFactory.SetLayoutElement(takeScreenshot.GameObject, minWidth: 150, minHeight: 25); + takeScreenshot.OnClick += () => screenshotStatus = ScreenshotState.TurnOffUI; + + AddInputField(TakeScreenshotHoriGroup, "Supersize", "Supersize:", $"{2}", SuperSize_OnEndEdit); + Toggle ShadowMeshesToggle = new Toggle(); GameObject ShadowMeshesObj = UIFactory.CreateToggle(ContentRoot, "ShadowMeshes", out ShadowMeshesToggle, out Text ShadowMeshesText); UIFactory.SetLayoutElement(ShadowMeshesObj, minHeight: 25); @@ -293,17 +304,6 @@ namespace UnityExplorer.UI.Panels HighResShadowsText.text = "High Res Shadows"; AddInputField(HighResShadowsGroup, "Resolution", "Resolution:", $"{5000}", HighResShadowsResolution_OnEndEdit); - - // Screenshot function - GameObject TakeScreenshotHoriGroup = UIFactory.CreateHorizontalGroup(ContentRoot, "Take screenshot", false, false, true, true, 3, - default, new Color(1, 1, 1, 0), TextAnchor.MiddleLeft); - UIFactory.SetLayoutElement(TakeScreenshotHoriGroup, minHeight: 25, flexibleWidth: 9999); - - ButtonRef takeScreenshot = UIFactory.CreateButton(TakeScreenshotHoriGroup, "TakeScreenshot", "Take screenshot"); - UIFactory.SetLayoutElement(takeScreenshot.GameObject, minWidth: 150, minHeight: 25); - takeScreenshot.OnClick += () => screenshotStatus = ScreenshotState.TurnOffUI; - - AddInputField(TakeScreenshotHoriGroup, "Supersize", "Supersize:", $"{2}", SuperSize_OnEndEdit); } GameObject AddInputField(GameObject parent, string name, string labelText, string placeHolder, Action onInputEndEdit)