浏览代码

Default Button improvement

/main
uChema 4 年前
当前提交
66b47933
共有 18 个文件被更改,包括 96 次插入75 次删除
  1. 2
      UOP1_Project/Assets/Prefabs/UI/ButtonChoice.prefab
  2. 23
      UOP1_Project/Assets/Prefabs/UI/Popup/PopupButton.prefab
  3. 25
      UOP1_Project/Assets/Prefabs/UI/PopupButtons.prefab
  4. 5
      UOP1_Project/Assets/Scenes/Managers/Gameplay.unity
  5. 2
      UOP1_Project/Assets/Scripts/Input/InputReader.cs
  6. 17
      UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs
  7. 10
      UOP1_Project/Assets/Scripts/Menu/MultiInputButton.cs
  8. 11
      UOP1_Project/Assets/Scripts/UI/UIButtonSetter.cs
  9. 12
      UOP1_Project/Assets/Scripts/UI/UIDialogueChoiceFiller.cs
  10. 2
      UOP1_Project/Assets/Scripts/UI/UIDialogueChoicesManager.cs
  11. 18
      UOP1_Project/Assets/Scripts/UI/UIManager.cs
  12. 2
      UOP1_Project/Assets/Scripts/UI/UIMenuManager.cs
  13. 9
      UOP1_Project/Assets/Scripts/UI/UIPauseScreenSetter.cs
  14. 13
      UOP1_Project/Assets/Scripts/UI/UIPopupButtonSetter.cs
  15. 16
      UOP1_Project/Assets/Scripts/UI/UIPopupSetter.cs
  16. 4
      UOP1_Project/UserSettings/EditorUserSettings.asset
  17. 0
      /UOP1_Project/Assets/Prefabs/UI/PopupButtons.prefab.meta
  18. 0
      /UOP1_Project/Assets/Prefabs/UI/PopupButtons.prefab

2
UOP1_Project/Assets/Prefabs/UI/ButtonChoice.prefab


m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_Interactable: 0
m_TargetGraphic: {fileID: 3600158999093101197}
m_OnClick:
m_PersistentCalls:

23
UOP1_Project/Assets/Prefabs/UI/Popup/PopupButton.prefab


- component: {fileID: 252969180845692043}
- component: {fileID: 252969180845692040}
- component: {fileID: 3635794304859248890}
- component: {fileID: 252969180845692042}
- component: {fileID: 6602095586343775202}
- component: {fileID: 7373103914063609958}
m_Layer: 5
m_Name: ButtonToClick
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &252969180845692042
--- !u!114 &7373103914063609958
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Script: {fileID: 11500000, guid: 77b26c7a54d143a7b78bcba222262814, type: 3}
m_Mode: 4
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}

m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &6602095586343775202
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 252969180845692044}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &297632141197697312
GameObject:
m_ObjectHideFlags: 0

m_Name:
m_EditorClassIdentifier:
_buttonText: {fileID: 297632142728442599}
_button: {fileID: 252969180845692042}
_button: {fileID: 7373103914063609958}
_buttonClickedEvent: {fileID: 11400000, guid: eac31df6531974a71ae9be0774b27ae2,
type: 2}
--- !u!1 &297632142728442617

25
UOP1_Project/Assets/Prefabs/UI/PopupButtons.prefab


- component: {fileID: 4107745345308144948}
- component: {fileID: 6966040858402298430}
m_Layer: 5
m_Name: UnpauseButton
m_Name: PopupButtons
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_Name:
m_EditorClassIdentifier:
_buttonText: {fileID: 4107745346167891708}
_button: {fileID: 4513302106742259857}
_button: {fileID: 4441567588691658121}
--- !u!1 &4107745346167891682
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 4513302106742259856}
- component: {fileID: 4513302106742259859}
- component: {fileID: 1104558195131469025}
- component: {fileID: 4513302106742259857}
- component: {fileID: 2680095201307940933}
- component: {fileID: 4441567588691658121}
m_Layer: 5
m_Name: ButtonToClick
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &4513302106742259857
--- !u!114 &4441567588691658121
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Script: {fileID: 11500000, guid: 77b26c7a54d143a7b78bcba222262814, type: 3}
m_Mode: 4
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}

m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &2680095201307940933
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4513302106742259863}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:

5
UOP1_Project/Assets/Scenes/Managers/Gameplay.unity


objectReference: {fileID: 6822594372875662427}
- target: {fileID: 8313085416397863411, guid: 2af68f4e6b94140cfbcdee05fcc28ce3,
type: 3}
propertyPath: _selectionHandler
value:
objectReference: {fileID: 1869732382}
- target: {fileID: 8313085416397863411, guid: 2af68f4e6b94140cfbcdee05fcc28ce3,
type: 3}
propertyPath: _dialogueController
value:
objectReference: {fileID: 1540519756}

2
UOP1_Project/Assets/Scripts/Input/InputReader.cs


public void EnableDialogueInput()
{
gameInput.Menus.Disable();
gameInput.Menus.Enable();
gameInput.Gameplay.Disable();
gameInput.Dialogues.Enable();

17
UOP1_Project/Assets/Scripts/Menu/MenuSelectionHandler.cs


_inputReader.menuMouseMoveEvent -= HandleMoveCursor;
_inputReader.moveSelectionEvent -= HandleMoveSelection;
}
public void UpdateDefault(GameObject newDefault)
{
_defaultSelection = newDefault;
}
/// <summary>
/// Highlights the default element
/// </summary>

EventSystem.current.SetSelectedGameObject(_defaultSelection);
}
public void Unselect()
{
currentSelection = null;
EventSystem.current.SetSelectedGameObject(null);
}
/// <summary>
/// Fired by keyboard and gamepad inputs. Current selected UI element will be the ui Element that was selected
/// when the event was fired. The _currentSelection is updated later on, after the EventSystem moves to the

public void UpdateSelection(GameObject UIElement)
{
if (UIElement.GetComponent<MultiInputSelectableElement>() != null)
if ((UIElement.GetComponent<MultiInputSelectableElement>() != null)|| (UIElement.GetComponent<MultiInputButton>() != null))
{
mouseSelection = UIElement;
currentSelection = UIElement;

// }
private void Update()
{
if ((EventSystem.current!=null)&& (currentSelection != null)&&(EventSystem.current.currentSelectedGameObject!=currentSelection) )
if ((EventSystem.current!=null)&& (EventSystem.current.currentSelectedGameObject == null)&& (currentSelection != null))
}
}

10
UOP1_Project/Assets/Scripts/Menu/MultiInputButton.cs


public override void OnSelect(BaseEventData eventData)
{
}
public void UpdateDefault()
{
Debug.Log("Select");
if(_menuSelectionHandler==null)
_menuSelectionHandler = transform.root.gameObject.GetComponentInChildren<MenuSelectionHandler>();
_menuSelectionHandler.UpdateSelection(gameObject);
}
public override void OnSubmit(BaseEventData eventData)

11
UOP1_Project/Assets/Scripts/UI/UIButtonSetter.cs


public class UIButtonSetter : MonoBehaviour
{
[SerializeField] private LocalizeStringEvent _buttonText = default;
[SerializeField] private Button _button = default;
[SerializeField] private MultiInputButton _button = default;
if(select)
_button.Select();
if (select)
_button.UpdateDefault();
}
public void SelectButton()
{
_button.UpdateDefault();
public void Click()
{
_buttonClickedEvent.RaiseEvent();

12
UOP1_Project/Assets/Scripts/UI/UIDialogueChoiceFiller.cs


{
currentChoice = choiceToFill;
_choiceText.StringReference = choiceToFill.Response;
if(isSelected)
_actionButton.interactable = true;
if (isSelected)
_actionButton.Select();
Debug.Log("Select");
_actionButton.UpdateDefault();
}
else
{
Debug.Log("Not selected");
}
}

2
UOP1_Project/Assets/Scripts/UI/UIDialogueChoicesManager.cs


{
if (i < choices.Count)
{
listChoiceButtons[i].FillChoice(choices[i], i==0);
listChoiceButtons[i].FillChoice(choices[i], i == 0);
listChoiceButtons[i].gameObject.SetActive(true);
}

18
UOP1_Project/Assets/Scripts/UI/UIManager.cs


public class UIManager : MonoBehaviour
{
[Header("Scene UI")]
[SerializeField]
private MenuSelectionHandler _selectionHandler = default;
[SerializeField] private UIPopupSetter _popupPanel = default;
[SerializeField]private UIDialogueManager _dialogueController = default;

}
void CloseUIDialogue()
{
_selectionHandler.Unselect();
_dialogueController.gameObject.SetActive(false);
}

_pauseScreen.gameObject.SetActive(true);
_pauseScreen.SetPauseScreen();
_inputReader.EnableMenuInput();
_gameState.UpdateGameState(GameState.Pause);

_clickUnpauseEvent.OnEventRaised -= CloseUIPause;
_pauseScreen.gameObject.SetActive(false);
_selectionHandler.Unselect();
_gameState.ResetToPreviousGameState();
}

_closeSettingScreenEvent.OnEventRaised += CloseSettingScreen; // sub to close setting event with event
_pauseScreen.gameObject.SetActive(false); // Set pause screen to inactive
_settingScreen.gameObject.SetActive(true);// set pause screen to active
_settingScreen.gameObject.SetActive(true);// set Setting screen to active
// time is still set to 0 and Input is still set to menuInput

//unsub from close setting events
_inputReader.menuCloseEvent -= CloseSettingScreen;
_closeSettingScreenEvent.OnEventRaised -= CloseSettingScreen;
_selectionHandler.Unselect();
_pauseScreen.gameObject.SetActive(true); // Set pause screen to inactive
_clickUnpauseEvent.OnEventRaised += CloseUIPause; // unsub from clause pause popup since it's inactive

{
_inputReader.menuCloseEvent -= HideBackToMenuConfirmationPopup;
_closePopupEvent.OnEventRaised -= HideBackToMenuConfirmationPopup;
_pauseScreen.gameObject.SetActive(true); // Set pause screen to inactive
_clickUnpauseEvent.OnEventRaised += CloseUIPause; // unsub from clause pause popup since it's inactive

_onInteractionEndedEvent.RaiseEvent();
}
_selectionHandler.Unselect();
_inputReader.EnableGameplayInput();
_gameState.ResetToPreviousGameState();
}

{
if (isOpenEvent)
{
_interactionPanel.FillInteractionPanel(interactionType);
_interactionPanel.FillInteractionPanel(interactionType);
}
_interactionPanel.gameObject.SetActive(isOpenEvent);

2
UOP1_Project/Assets/Scripts/UI/UIMenuManager.cs


}
else
{
_NewGameButton.Select();
_NewGameButton.Select();
}

9
UOP1_Project/Assets/Scripts/UI/UIPauseScreenSetter.cs


[SerializeField] private InputReader _inputReader = default;
private void OnEnable()
private void Start()
SetPauseScreen();
}
private void OnEnable()
{
_unpauseButton.SelectButton();
}
public void SetPauseScreen()
{

13
UOP1_Project/Assets/Scripts/UI/UIPopupButtonSetter.cs


public class UIPopupButtonSetter : MonoBehaviour
{
[SerializeField] private LocalizeStringEvent _buttonText = default;
[SerializeField] private Button _button = default;
[SerializeField] private MultiInputButton _button = default;
PopupButtonType _currentType = default;

public void SetButton(PopupButtonType _type, PopupType popupType)
public void SetButton(PopupButtonType _type, PopupType popupType, bool isSelected)
if(isSelected)
SelectButton();
public void SelectButton()
void SelectButton()
_button.Select();
_button.UpdateDefault();
}
public void ButtonClicked()

16
UOP1_Project/Assets/Scripts/UI/UIPopupSetter.cs


{
case PopupType.NewGame:
isConfirmation = true;
_popupButton1.SetButton(PopupButtonType.Confirm, actualType);
_popupButton2.SetButton(PopupButtonType.Cancel, actualType);
_popupButton1.SetButton(PopupButtonType.Confirm, actualType, true);
_popupButton2.SetButton(PopupButtonType.Cancel, actualType, false);
_popupButton1.SetButton(PopupButtonType.Confirm, actualType);
_popupButton2.SetButton(PopupButtonType.Cancel, actualType);
_popupButton1.SetButton(PopupButtonType.Confirm, actualType, true);
_popupButton2.SetButton(PopupButtonType.Cancel, actualType, false);
_popupButton1.SetButton(PopupButtonType.Confirm, actualType);
_popupButton2.SetButton(PopupButtonType.Cancel, actualType);
_popupButton1.SetButton(PopupButtonType.Confirm, actualType, true);
_popupButton2.SetButton(PopupButtonType.Cancel, actualType, false);
hasExitButton = false;
break;
default:

{
_popupButton1.gameObject.SetActive(true);
_popupButton2.gameObject.SetActive(true);
_popupButton1.SelectButton();
_popupButton2.gameObject.SetActive(false);
_popupButton1.SelectButton();
_popupButton2.gameObject.SetActive(false);
}

4
UOP1_Project/UserSettings/EditorUserSettings.asset


value: 22424703114646680e0b0227036c683926582c2f3f3c2f3e2a0e0f3cf7ee3007d1ea37e5eb742a323016f6
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c683926582c2f3f3c2f3e2a0e0f3cf7ee3076f7e93ffdfe
value: 22424703114646680e0b0227036c721518020b6501292f3e002c1326acf53a31f6fe
value: 22424703114646680e0b0227036c721518020b6501292f3e002c1326acf53a31f6fe
value: 22424703114646680e0b0227036c683926582c2f3f3c2f3e2a0e0f3cf7ee3076f7e93ffdfe
flags: 0
UnityEditor.ShaderGraph.Blackboard:
value: 18135939215a0a5004000b0e15254b524c030a3f2964643d120d1230e9e93a3fd6e826abbd3c3e302a07a37e0901373ae01e0008f707250d171df81a53a5485d41895ac825e0100ec20313c0d91cddccd3d0c7efcca9bd80908fecb0f9cfddf1eff4e7a1b1eae482f0fdaee1e1928b86d888ed909c968797a7cf

/UOP1_Project/Assets/Prefabs/UI/UnpauseButton.prefab.meta → /UOP1_Project/Assets/Prefabs/UI/PopupButtons.prefab.meta

/UOP1_Project/Assets/Prefabs/UI/UnpauseButton.prefab → /UOP1_Project/Assets/Prefabs/UI/PopupButtons.prefab

正在加载...
取消
保存