mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
feat: added list of buttons to select recently placed props
This commit is contained in:
parent
c126f52123
commit
87c61f4189
@ -19,6 +19,9 @@ namespace NewHorizons.Utility
|
|||||||
DebugPropPlacer _dpp;
|
DebugPropPlacer _dpp;
|
||||||
DebugRaycaster _drc;
|
DebugRaycaster _drc;
|
||||||
|
|
||||||
|
// menu params
|
||||||
|
private Vector2 recentPropsScrollPosition = Vector2.zero;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_dpp = this.GetRequiredComponent<DebugPropPlacer>();
|
_dpp = this.GetRequiredComponent<DebugPropPlacer>();
|
||||||
@ -47,9 +50,31 @@ namespace NewHorizons.Utility
|
|||||||
// https://docs.unity3d.com/ScriptReference/GUI.TextField.html
|
// https://docs.unity3d.com/ScriptReference/GUI.TextField.html
|
||||||
|
|
||||||
GUILayout.BeginArea(new Rect(menuPosition.x, menuPosition.y, EditorMenuSize.x, EditorMenuSize.y), _editorMenuStyle);
|
GUILayout.BeginArea(new Rect(menuPosition.x, menuPosition.y, EditorMenuSize.x, EditorMenuSize.y), _editorMenuStyle);
|
||||||
_dpp.currentObject = GUILayout.TextArea(_dpp.currentObject);
|
|
||||||
|
//
|
||||||
|
// DebugPropPlacer
|
||||||
|
//
|
||||||
|
GUILayout.Label("Recently placed objects");
|
||||||
|
_dpp.SetCurrentObject(GUILayout.TextArea(_dpp.currentObject));
|
||||||
|
|
||||||
|
GUILayout.Space(5);
|
||||||
|
|
||||||
// TODO: maintain list of objects here
|
// List of recently placed objects
|
||||||
|
GUILayout.Label("Recently placed objects");
|
||||||
|
recentPropsScrollPosition = GUILayout.BeginScrollView(recentPropsScrollPosition, GUILayout.Width(EditorMenuSize.x), GUILayout.Height(100));
|
||||||
|
foreach (string propPath in _dpp.RecentlyPlacedProps)
|
||||||
|
{
|
||||||
|
var propPathElements = propPath.Split('/');
|
||||||
|
if (GUILayout.Button(propPathElements[propPathElements.Length-1]))
|
||||||
|
{
|
||||||
|
_dpp.SetCurrentObject(propPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUILayout.EndScrollView();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: maintain list of recently placed objects here
|
||||||
// TODO: field to provide name of mod to load configs from, plus button to load those into the PropPlaecr (make sure not to load more than once, once the button has been pushed, disable it)
|
// TODO: field to provide name of mod to load configs from, plus button to load those into the PropPlaecr (make sure not to load more than once, once the button has been pushed, disable it)
|
||||||
// TODO: add a warning that the button cannot be pushed more than once
|
// TODO: add a warning that the button cannot be pushed more than once
|
||||||
|
|
||||||
|
|||||||
@ -24,16 +24,21 @@ namespace NewHorizons.Utility
|
|||||||
public Vector3 rotation { get { return gameObject.transform.localEulerAngles; } }
|
public Vector3 rotation { get { return gameObject.transform.localEulerAngles; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DreamWorld_Body/Sector_DreamWorld/Sector_DreamZone_1/Props_DreamZone_1/OtherComponentsGroup/Trees_Z1/DreamHouseIsland/Tree_DW_M_Var
|
||||||
public static readonly string DEFAULT_OBJECT = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District1/Props_HangingCity_District1/OtherComponentsGroup/Props_HangingCity_Building_10/Prefab_NOM_VaseThin";
|
public static readonly string DEFAULT_OBJECT = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District1/Props_HangingCity_District1/OtherComponentsGroup/Props_HangingCity_Building_10/Prefab_NOM_VaseThin";
|
||||||
|
|
||||||
public string currentObject = DEFAULT_OBJECT;
|
public string currentObject { get; private set; }
|
||||||
|
private bool hasAddedCurrentObjectToRecentsList = false;
|
||||||
private List<PropPlacementData> props = new List<PropPlacementData>();
|
private List<PropPlacementData> props = new List<PropPlacementData>();
|
||||||
private List<PropPlacementData> deletedProps = new List<PropPlacementData>();
|
private List<PropPlacementData> deletedProps = new List<PropPlacementData>();
|
||||||
private DebugRaycaster _rc;
|
private DebugRaycaster _rc;
|
||||||
|
|
||||||
|
public List<string> RecentlyPlacedProps = new List<string>();
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_rc = this.GetRequiredComponent<DebugRaycaster>();
|
_rc = this.GetRequiredComponent<DebugRaycaster>();
|
||||||
|
currentObject = DEFAULT_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@ -61,10 +66,26 @@ namespace NewHorizons.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetCurrentObject(string s)
|
||||||
|
{
|
||||||
|
currentObject = s;
|
||||||
|
hasAddedCurrentObjectToRecentsList = false;
|
||||||
|
}
|
||||||
|
|
||||||
internal void PlaceObject()
|
internal void PlaceObject()
|
||||||
{
|
{
|
||||||
DebugRaycastData data = _rc.Raycast();
|
DebugRaycastData data = _rc.Raycast();
|
||||||
PlaceObject(data, this.gameObject.transform.position);
|
PlaceObject(data, this.gameObject.transform.position);
|
||||||
|
|
||||||
|
if (!hasAddedCurrentObjectToRecentsList)
|
||||||
|
{
|
||||||
|
hasAddedCurrentObjectToRecentsList = true;
|
||||||
|
|
||||||
|
if (!RecentlyPlacedProps.Contains(currentObject))
|
||||||
|
{
|
||||||
|
RecentlyPlacedProps.Add(currentObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlaceObject(DebugRaycastData data, Vector3 playerAbsolutePosition)
|
public void PlaceObject(DebugRaycastData data, Vector3 playerAbsolutePosition)
|
||||||
@ -80,7 +101,7 @@ namespace NewHorizons.Utility
|
|||||||
|
|
||||||
if (currentObject == "" || currentObject == null)
|
if (currentObject == "" || currentObject == null)
|
||||||
{
|
{
|
||||||
currentObject = DEFAULT_OBJECT;
|
SetCurrentObject(DEFAULT_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject prop = DetailBuilder.MakeDetail(data.hitObject, data.hitObject.GetComponentInChildren<Sector>(), currentObject, data.pos, data.norm, 1, false);
|
GameObject prop = DetailBuilder.MakeDetail(data.hitObject, data.hitObject.GetComponentInChildren<Sector>(), currentObject, data.pos, data.norm, 1, false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user