浏览代码

was able to fix edge case #1

/main
kgc00 4 年前
当前提交
280989a8
共有 5 个文件被更改,包括 104 次插入160 次删除
  1. 208
      UOP1_Project/Assets/Prefabs/Menu/DebugMenu.prefab
  2. 2
      UOP1_Project/Assets/Scripts/Input/InputReader.cs
  3. 14
      UOP1_Project/Assets/Scripts/Menu/MenuInput.cs
  4. 37
      UOP1_Project/Assets/Scripts/Menu/CC_Button.cs
  5. 3
      UOP1_Project/Assets/Scripts/Menu/CC_Button.cs.meta

208
UOP1_Project/Assets/Prefabs/Menu/DebugMenu.prefab


- component: {fileID: 3306839452006928020}
- component: {fileID: 2236986951312501638}
- component: {fileID: 4019022335893339527}
- component: {fileID: 1619296191322118748}
- component: {fileID: 621613995356252344}
- component: {fileID: 4373029644707992511}
m_Layer: 5
m_Name: Button (3)
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &1619296191322118748
--- !u!114 &4373029644707992511
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &621613995356252344
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 792865649319356801}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!1 &1425999354015979985
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 5787547316080151453}
- component: {fileID: 4034736882852530935}
- component: {fileID: 3702422837081646566}
- component: {fileID: 8768096626548565149}
- component: {fileID: 7070358658825862807}
- component: {fileID: 2245571053524376027}
m_Layer: 5
m_Name: Button
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &8768096626548565149
--- !u!114 &2245571053524376027
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &7070358658825862807
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1769078323045988640}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!1 &1927410817915059708
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 4045572467555519787}
- component: {fileID: 218592765038036019}
- component: {fileID: 3512590359760928635}
- component: {fileID: 2056477919673662971}
- component: {fileID: 7346758966151412111}
- component: {fileID: 8085040847575021571}
m_Layer: 5
m_Name: Button (1)
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &2056477919673662971
--- !u!114 &8085040847575021571
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &7346758966151412111
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4554724757286240653}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!1 &6067668323749145543
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 7922152970772631817}
- component: {fileID: 4535641487261068012}
- component: {fileID: 4074839849160678977}
- component: {fileID: 7870813273070393017}
- component: {fileID: 5690382054100097946}
- component: {fileID: 5995593661625392535}
m_Layer: 5
m_Name: Button (2)
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &7870813273070393017
--- !u!114 &5995593661625392535
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &5690382054100097946
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6067668323749145543}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!1 &7859374052461343585
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 9071686868378766864}
- component: {fileID: 9071686868378766867}
- component: {fileID: 9071686868378766866}
- component: {fileID: 9071686868378766865}
- component: {fileID: 1407401529385676863}
- component: {fileID: 2202589235359239235}
m_Layer: 5
m_Name: Button (1)
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &9071686868378766865
--- !u!114 &2202589235359239235
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1407401529385676863
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9071686868378766895}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!1 &9071686868638868090
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 9071686869080746988}
- component: {fileID: 9071686869080746991}
- component: {fileID: 9071686869080746990}
- component: {fileID: 9071686869080746989}
- component: {fileID: 2694421509025819227}
- component: {fileID: 5360079875535612190}
m_Layer: 5
m_Name: Button (2)
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &9071686869080746989
--- !u!114 &5360079875535612190
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &2694421509025819227
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9071686869080746987}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!1 &9071686869219419063
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 9071686869219419064}
- component: {fileID: 9071686869219419067}
- component: {fileID: 9071686869219419066}
- component: {fileID: 9071686869219419065}
- component: {fileID: 7748229612521929411}
- component: {fileID: 2848064704926626897}
m_Layer: 5
m_Name: Button
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &9071686869219419065
--- !u!114 &2848064704926626897
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &7748229612521929411
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9071686869219419063}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}
--- !u!1 &9071686869232270378
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 9071686869821295453}
- component: {fileID: 9071686869821295424}
- component: {fileID: 9071686869821295455}
- component: {fileID: 9071686869821295454}
- component: {fileID: 7727443263718404068}
- component: {fileID: 7123054415157016972}
m_Layer: 5
m_Name: Button (3)
m_TagString: Untagged

m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &9071686869821295454
--- !u!114 &7123054415157016972
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_Name:
m_EditorClassIdentifier:
m_Navigation:

m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.539231, g: 0.9622642, b: 0.6264099, a: 1}
m_PressedColor: {r: 1, g: 0.717669, b: 0.47547168, a: 1}
m_SelectedColor: {r: 0.51199716, g: 0.67577535, b: 0.9622642, a: 1}
m_HighlightedColor: {r: 0.5096556, g: 1, b: 0.39999998, a: 1}
m_PressedColor: {r: 0.8584906, g: 0.41226837, b: 0.23891956, a: 1}
m_SelectedColor: {r: 0.40000004, g: 0.67058825, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1

m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &7727443263718404068
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9071686869821295452}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 83c0f9e51d2b4ff7bc0b46c5ed82b408, type: 3}
m_Name:
m_EditorClassIdentifier:
_inputReader: {fileID: 11400000, guid: 945ec0365077176418488737deed54be, type: 2}

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


gameInput.Gameplay.Disable();
gameInput.Menus.Enable();
}
public bool LeftMouseDown() => Mouse.current.leftButton.isPressed;
}

14
UOP1_Project/Assets/Scripts/Menu/MenuInput.cs


using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
public class MenuInput : MonoBehaviour
{

// deselect UI element if mouse moves away from it
_mouseSelection = null;
EventSystem.current.SetSelectedGameObject(null);
}
/// <summary>
/// Method interactable UI elements should call on Submit interaction to determine whether to continue or not.
/// </summary>
/// <param name="o"></param>
/// <returns></returns>
public bool AllowsSubmitOccurance(GameObject o)
{
// if LMB is not down, there is no edge case to handle, allow the event to continue
return !_inputReader.LeftMouseDown()
// if we know mouse & keyboard are on different elements, do not allow interaction to continue
|| _mouseSelection != null && _mouseSelection == _currentSelection;
}
/// <summary>

37
UOP1_Project/Assets/Scripts/Menu/CC_Button.cs


using UnityEngine.EventSystems;
using UnityEngine.UI;
// Chop Chop button
public class CC_Button : Button
{
private MenuInput _menuInput;
private void Awake()
{
_menuInput = transform.root.gameObject.GetComponentInChildren<MenuInput>();
}
public override void OnPointerEnter(PointerEventData eventData)
{
_menuInput.HandleMouseEnter(gameObject);
base.OnPointerEnter(eventData);
}
public override void OnPointerExit(PointerEventData eventData)
{
_menuInput.HandleMouseExit(gameObject);
base.OnPointerExit(eventData);
}
public override void OnSelect(BaseEventData eventData)
{
_menuInput.UpdateSelection(gameObject);
base.OnSelect(eventData);
}
public override void OnSubmit(BaseEventData eventData)
{
if (_menuInput.AllowsSubmitOccurance(gameObject))
base.OnSubmit(eventData);
}
}

3
UOP1_Project/Assets/Scripts/Menu/CC_Button.cs.meta


fileFormatVersion: 2
guid: 77b26c7a54d143a7b78bcba222262814
timeCreated: 1605334203
正在加载...
取消
保存