mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
added controls for rotating prop around its local up direction
This commit is contained in:
parent
7b40287412
commit
1d8b2feade
@ -27,8 +27,11 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
// menu params
|
||||
private Vector2 recentPropsScrollPosition = Vector2.zero;
|
||||
private bool propsCollapsed = false;
|
||||
private bool propPositioningCollapsed = false;
|
||||
private Vector3 propPosDelta = new Vector3(0.1f, 0.1f, 0.1f);
|
||||
private Vector3 propRotDelta = new Vector3(0.1f, 0.1f, 0.1f);
|
||||
private Vector3 propSphericalPosDelta = new Vector3(0.1f, 0.1f, 0.1f);
|
||||
private float propRotationAboutLocalUpDelta = 0.1f;
|
||||
|
||||
internal override string SubmenuName()
|
||||
{
|
||||
@ -101,7 +104,14 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
|
||||
if (_dpp.mostRecentlyPlacedPropGO != null)
|
||||
{
|
||||
arrow = propPositioningCollapsed ? " > " : " v ";
|
||||
if (GUILayout.Button(arrow + "Position last placed prop", menu._tabBarStyle)) propPositioningCollapsed = !propPositioningCollapsed;
|
||||
if (!propPositioningCollapsed) DrawPropsAdustmentControls(menu);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPropsAdustmentControls(DebugMenu menu)
|
||||
{
|
||||
var propPath = _dpp.mostRecentlyPlacedPropPath;
|
||||
var propPathElements = propPath[propPath.Length-1] == '/'
|
||||
? propPath.Substring(0, propPath.Length-1).Split('/')
|
||||
@ -109,10 +119,16 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
string propName = propPathElements[propPathElements.Length - 1];
|
||||
GUILayout.Label($"Reposition {propName}: ");
|
||||
|
||||
|
||||
Vector3 latestPropPosDelta = VectorInput(_dpp.mostRecentlyPlacedPropGO.transform.localPosition, propPosDelta, out propPosDelta, "x", "y", "z");
|
||||
_dpp.mostRecentlyPlacedPropGO.transform.localPosition += latestPropPosDelta;
|
||||
if (latestPropPosDelta != Vector3.zero) mostRecentlyPlacedPropSphericalPos = DeltaSphericalPosition(mostRecentlyPlacedProp, Vector3.zero);
|
||||
|
||||
//GUILayout.Space(5);
|
||||
//Vector3 latestPropRotDelta = VectorInput(_dpp.mostRecentlyPlacedPropGO.transform.localEulerAngles, propRotDelta, out propRotDelta, "x", "y", "z");
|
||||
//_dpp.mostRecentlyPlacedPropGO.transform.localEulerAngles += latestPropRotDelta;
|
||||
|
||||
GUILayout.Space(5);
|
||||
GUILayout.Space(5);
|
||||
|
||||
|
||||
@ -128,9 +144,25 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
DeltaSphericalPosition(mostRecentlyPlacedProp, latestPropSphericalPosDelta);
|
||||
mostRecentlyPlacedPropSphericalPos = mostRecentlyPlacedPropSphericalPos+latestPropSphericalPosDelta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(5);
|
||||
GUILayout.Space(5);
|
||||
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Rotate about up: ", GUILayout.Width(50));
|
||||
float deltaRot = 0;
|
||||
if (GUILayout.Button("+", GUILayout.ExpandWidth(false))) deltaRot += propRotationAboutLocalUpDelta;
|
||||
if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) deltaRot -= propRotationAboutLocalUpDelta;
|
||||
propRotationAboutLocalUpDelta = float.Parse(GUILayout.TextField(propRotationAboutLocalUpDelta+"", GUILayout.Width(100)));
|
||||
|
||||
if (deltaRot != 0)
|
||||
{
|
||||
Transform astroObject = mostRecentlyPlacedProp.transform.parent.parent;
|
||||
mostRecentlyPlacedProp.transform.RotateAround(mostRecentlyPlacedProp.transform.position, mostRecentlyPlacedProp.transform.up, deltaRot);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
private Vector3 DeltaSphericalPosition(GameObject prop, Vector3 deltaSpherical)
|
||||
{
|
||||
Transform astroObject = prop.transform.parent.parent;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user