House Menu position adjustment
This commit is contained in:
parent
127ff101d8
commit
a457924b6d
2 changed files with 36 additions and 19 deletions
|
|
@ -2846,12 +2846,12 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 2055507137}
|
||||
m_Father: {fileID: 1395531171}
|
||||
m_RootOrder: 1
|
||||
m_Father: {fileID: 1040033584}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -290.4, y: -112.7}
|
||||
m_AnchoredPosition: {x: 0, y: 20}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &880320858
|
||||
|
|
@ -3329,7 +3329,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 1609015287}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_RootOrder: 8
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -3373,12 +3373,12 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1894722677}
|
||||
m_Father: {fileID: 1395531171}
|
||||
m_RootOrder: 2
|
||||
m_Father: {fileID: 1040033584}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -290.4, y: -152.1}
|
||||
m_AnchoredPosition: {x: 0, y: -20}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1014076883
|
||||
|
|
@ -3504,13 +3504,15 @@ RectTransform:
|
|||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Children:
|
||||
- {fileID: 880320857}
|
||||
- {fileID: 1014076882}
|
||||
m_Father: {fileID: 1395531171}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 150, y: -350}
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
m_AnchoredPosition: {x: -290, y: -350}
|
||||
m_SizeDelta: {x: 250, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1040033585
|
||||
|
|
@ -3651,7 +3653,7 @@ RectTransform:
|
|||
- {fileID: 1070476668}
|
||||
- {fileID: 1649897726}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 8
|
||||
m_RootOrder: 9
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -4804,6 +4806,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
menu: {fileID: 1395531174}
|
||||
dayCountTextMeshProUGUI: {fileID: 1089918735}
|
||||
menuPanel: {fileID: 1040033583}
|
||||
--- !u!212 &1278234715
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -4864,12 +4867,12 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1278234712}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -5.57, y: -2.97, z: -1}
|
||||
m_LocalPosition: {x: -7.27, y: -0.75, z: -1}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 7
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!224 &1285197323 stripped
|
||||
RectTransform:
|
||||
|
|
@ -5404,10 +5407,8 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1040033584}
|
||||
- {fileID: 880320857}
|
||||
- {fileID: 1014076882}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 9
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -6298,7 +6299,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 1671356617}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -8085,7 +8086,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 590987454}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public class HouseController : MonoBehaviour {
|
|||
|
||||
public Canvas menu;
|
||||
public TextMeshProUGUI dayCountTextMeshProUGUI;
|
||||
public GameObject menuPanel;
|
||||
|
||||
private void OnMouseDown() {
|
||||
ToggleMenu();
|
||||
|
|
@ -30,5 +31,20 @@ public class HouseController : MonoBehaviour {
|
|||
|
||||
public void ToggleMenu() {
|
||||
menu.gameObject.SetActive(!menu.gameObject.activeSelf);
|
||||
float newPosY;
|
||||
if (Camera.main != null) {
|
||||
|
||||
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
|
||||
|
||||
if (pos.y - 50 - ((RectTransform)menuPanel.transform).rect.height >= 0) { //check if bottom of panel is in screen
|
||||
newPosY = pos.y - ((RectTransform)menuPanel.transform).rect.height;
|
||||
} else {
|
||||
newPosY = pos.y + ((RectTransform)menuPanel.transform).rect.height;
|
||||
}
|
||||
|
||||
menuPanel.transform.position = new Vector3(pos.x, newPosY);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue