diff --git a/Assets/Prefabs/King/King.prefab b/Assets/Prefabs/King/King.prefab index 06a9deb..947448e 100644 --- a/Assets/Prefabs/King/King.prefab +++ b/Assets/Prefabs/King/King.prefab @@ -786,10 +786,10 @@ RectTransform: m_Father: {fileID: 3173415395030910393} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_SizeDelta: {x: 350, y: 350} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &3173415396104633696 CanvasRenderer: diff --git a/Assets/Scenes/Demos/KingImpGraybox.unity b/Assets/Scenes/Demos/KingImpGraybox.unity index a8c74ad..40ee3f8 100644 --- a/Assets/Scenes/Demos/KingImpGraybox.unity +++ b/Assets/Scenes/Demos/KingImpGraybox.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.864397, g: 0.82191086, b: 0.78032, a: 1} + m_IndirectSpecularColor: {r: 0.8643677, g: 0.8219142, b: 0.78027064, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -63873,6 +63873,30 @@ PrefabInstance: propertyPath: UItext value: objectReference: {fileID: 1277454841} + - target: {fileID: 3173415396104633699, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3173415396104633699, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3173415396104633699, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3173415396104633699, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3173415396104633699, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_SizeDelta.x + value: 350 + objectReference: {fileID: 0} + - target: {fileID: 3173415396104633699, guid: d23bf55f2a40d494487eb188930f895d, type: 3} + propertyPath: m_SizeDelta.y + value: 350 + objectReference: {fileID: 0} - target: {fileID: 3173415396260468957, guid: d23bf55f2a40d494487eb188930f895d, type: 3} propertyPath: m_AnchorMax.x value: 0 diff --git a/Assets/Scripts/KingScripts/RadialMenu.cs b/Assets/Scripts/KingScripts/RadialMenu.cs index f5639a9..fe19916 100644 --- a/Assets/Scripts/KingScripts/RadialMenu.cs +++ b/Assets/Scripts/KingScripts/RadialMenu.cs @@ -7,6 +7,7 @@ public class RadialMenu : MonoBehaviour { bool UIOn = false; + bool ButtonUp = true; public GameObject King; public Camera cam; @@ -14,28 +15,52 @@ public class RadialMenu : MonoBehaviour [SerializeField] private Text UItext; + + private float xBound = 1920f;//Resolution + private float yBound = 1080f; + + private float xSize; + private float ySize; + + void Start() + { + xSize = GetComponent().sizeDelta.x / 2;//Converts the size of the Panel into the bounds of the screen + ySize = GetComponent().sizeDelta.y / 2; + xBound -= xSize; + yBound -= ySize; + } + // Update is called once per frame void Update() { if (UIOn == false) { screenPoint = Input.mousePosition; screenPoint.z = 120f; + screenPoint.x = Mathf.Clamp(screenPoint.x, xSize, xBound);//Uses the calculated bounds to keep the UI on the screen + screenPoint.y = Mathf.Clamp(screenPoint.y, ySize, yBound); transform.position = cam.ScreenToWorldPoint(screenPoint);//Moved the UI to where the mouse is } - if(Input.GetAxis("RadialMenu") > 0) {//Pressing Q makes the UI appear + if(Input.GetAxis("RadialMenu") > 0 && UIOn == false && ButtonUp == true) {//Pressing Q makes the UI appear, if it is off + ButtonUp = false; if (King.GetComponent().FirstPlacing == true) { King.GetComponent().CancelPlacing(); } MenuOn(); } - if (Input.GetAxis("RadialMenu") < 0) {//Pressing E makes the UI dissapear + else if (Input.GetAxis("RadialMenu") > 0 && UIOn == true && ButtonUp == true) {//Pressing Q makes the UI dissapear, if it is on + ButtonUp = false; MenuOff(); } + + if(Input.GetAxis("RadialMenu") == 0) + { + ButtonUp = true; + } } private void MenuOn() { - UItext.text = "Press E to Close Menu"; + UItext.text = "Press Q to Close Menu"; foreach (Transform child in transform) { //Turns on all of the different buttons attached to this panel and stops it from moving child.gameObject.SetActive(true); UIOn = true;