mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-11 01:48:07 +08:00
Added default intensity input on the LightsManager panel, as the user may use the same intensity for all new lights (and we can't assign a default value ourselves that works in every game). Also did some minor edits to the panel's size and options order on the Misc panel.
This commit is contained in:
1 parent
64f9d9c7ea
commit
bfdeaacf33
2 files changed
+41
-16
No files matched your search
@@ -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<GameObject> UIElements = new List<GameObject>();
|
||||
//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<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -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<string> onInputEndEdit)
|
||||
|
||||
Reference in new issue
Block a user