Skip to content

Commit

Permalink
Fixed issue with event system handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Orange-Panda committed Feb 20, 2022
1 parent 4340766 commit 453bf36
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 54 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this package are documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.0.4] - 2022-02-20

### Fixed
- Improved handling of event system to fix issue with ui losing focus.

## [1.0.3] - 2022-02-13

### Added
Expand Down
1 change: 1 addition & 0 deletions Runtime/DevConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static void ProcessCommand(string submitText)
// Automatically enable cheats if configured to do so in the config, making quick debugging more convenient when enabled.
if (command.Cheat && !CheatsEnabled && ConsoleSettings.Config.editorAutoEnableCheats)
{
Log("<color=yellow>Cheats have automatically been enabled.</color>");
CheatsEnabled = true;
}
#endif
Expand Down
16 changes: 14 additions & 2 deletions Runtime/DevConsoleRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ public class DevConsoleRunner : MonoBehaviour
{
[Header("Component References")]
[SerializeField] private Canvas canvas;
[SerializeField] private GameObject container;
[SerializeField] private TextMeshProUGUI history;
[SerializeField] private TMP_InputField inputText;

private bool historyDirty;
private bool hasNoEventSystem;
private GameObject previousSelectable;

internal static DevConsoleRunner Instance { get; private set; }

Expand Down Expand Up @@ -83,18 +85,28 @@ private void Update()
public void SetConsoleState(bool value)
{
DevConsole.ConsoleActive = value;
if (container)
{
container.SetActive(value);
}
canvas.enabled = value;
inputText.enabled = value;
inputText.SetTextWithoutNotify(string.Empty);
if (EventSystem.current != null)
{
EventSystem.current.SetSelectedGameObject(value ? inputText.gameObject : null);

if (value)
{
previousSelectable = EventSystem.current.currentSelectedGameObject;
EventSystem.current.SetSelectedGameObject(inputText.gameObject);
inputText.OnPointerClick(new PointerEventData(EventSystem.current));
}
else if (previousSelectable != null && previousSelectable.activeInHierarchy)
{
EventSystem.current.SetSelectedGameObject(previousSelectable);
previousSelectable = null;
}

// Clear no event system warning if present since one is present now.
if (hasNoEventSystem)
{
DevConsole.Clear();
Expand Down
135 changes: 84 additions & 51 deletions Runtime/Resources/VespaIO/Console.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: -6691347217894470595, guid: 910dd77f64379d74ba7fcbdd646b05af,
type: 3}
m_Sprite: {fileID: -6691347217894470595, guid: 910dd77f64379d74ba7fcbdd646b05af, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
Expand Down Expand Up @@ -144,8 +143,7 @@ MonoBehaviour:
m_text: help
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ae522667b03cf5041ac09bb0e96f9bc4, type: 2}
m_sharedMaterial: {fileID: 606252943989992591, guid: ae522667b03cf5041ac09bb0e96f9bc4,
type: 2}
m_sharedMaterial: {fileID: 606252943989992591, guid: ae522667b03cf5041ac09bb0e96f9bc4, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
Expand Down Expand Up @@ -244,7 +242,7 @@ RectTransform:
- {fileID: 3209357464626355142}
- {fileID: 8277032813909211571}
m_Father: {fileID: 3209357464813702814}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
Expand Down Expand Up @@ -455,8 +453,7 @@ MonoBehaviour:
m_text: "\u200B"
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ae522667b03cf5041ac09bb0e96f9bc4, type: 2}
m_sharedMaterial: {fileID: 606252943989992591, guid: ae522667b03cf5041ac09bb0e96f9bc4,
type: 2}
m_sharedMaterial: {fileID: 606252943989992591, guid: ae522667b03cf5041ac09bb0e96f9bc4, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
Expand Down Expand Up @@ -552,7 +549,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3209357464813702814}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
Expand Down Expand Up @@ -590,8 +587,7 @@ MonoBehaviour:
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: ae522667b03cf5041ac09bb0e96f9bc4, type: 2}
m_sharedMaterial: {fileID: 606252943989992591, guid: ae522667b03cf5041ac09bb0e96f9bc4,
type: 2}
m_sharedMaterial: {fileID: 606252943989992591, guid: ae522667b03cf5041ac09bb0e96f9bc4, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
Expand Down Expand Up @@ -718,10 +714,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 3209357464813702814}
- component: {fileID: 3209357464813702812}
- component: {fileID: 3209357464813702815}
m_Layer: 0
m_Name: Background
m_Name: Container
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand All @@ -738,6 +732,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1381218373822591221}
- {fileID: 3209357464157384420}
- {fileID: 3209357464421840033}
m_Father: {fileID: 3209357465723313606}
Expand All @@ -748,44 +743,6 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3209357464813702812
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3209357464813702801}
m_CullTransparentMesh: 0
--- !u!114 &3209357464813702815
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3209357464813702801}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0.7490196}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: f1195a5604bbf1f4cb18a4fc3ee3f975, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &3209357465723313626
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -838,6 +795,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
canvas: {fileID: 3209357465723313625}
container: {fileID: 3209357464813702801}
history: {fileID: 3209357464421840046}
inputText: {fileID: 3209357464157384421}
--- !u!223 &3209357465723313625
Expand Down Expand Up @@ -884,3 +842,78 @@ MonoBehaviour:
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!1 &6534017713887459745
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1381218373822591221}
- component: {fileID: 3575849308845268387}
- component: {fileID: 8933642081361742897}
m_Layer: 0
m_Name: Background
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1381218373822591221
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6534017713887459745}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3209357464813702814}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3575849308845268387
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6534017713887459745}
m_CullTransparentMesh: 1
--- !u!114 &8933642081361742897
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6534017713887459745}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0.7490196}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: f1195a5604bbf1f4cb18a4fc3ee3f975, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.lmirman.vespaio",
"version": "1.0.3",
"version": "1.0.4",
"displayName": "VespaIO",
"description": "A runtime developer console that allows the user to execute commands enabling quick debugging.",
"hideInEditor": true,
Expand Down

0 comments on commit 453bf36

Please sign in to comment.