Skip to content

Commit

Permalink
Bug fix on UIPanel - sometimes a panel could be shown multiple times …
Browse files Browse the repository at this point in the history
…while hiding
  • Loading branch information
Douglas Rachevsky committed Sep 9, 2022
0 parents commit b8dd7c9
Show file tree
Hide file tree
Showing 23 changed files with 561 additions and 0 deletions.
Binary file added .icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions GameWorkstore.ProtocolUI.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "GameWorkstore.ProtocolUI",
"references": [
"GUID:c32d36751e998d74999be5c29b033d6e"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions GameWorkstore.ProtocolUI.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MIT License

Copyright (c) 2015, Unity Technologies

Copyright (c) 2020 Game Workstore

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions LICENSE.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Game Workstore Protocol UI

Protocol UI is a small framework to work with multiple screens on a easy and organized way and manage layered panels on Unity.
Use it your own risk!

# How to install

At package.json, add these lines of code:
```json
"com.gameworkstore.protocolui": "https://github.com/GameWorkstore/protocolui.git#1.1.4"
"com.gameworkstore.patterns": "https://github.com/GameWorkstore/patterns.git#1.2.0"
```

And wait for unity to download and compile the package.

you can upgrade your version by including the release version at end of the link:
```json
"com.gameworkstore.protocolui": "https://github.com/GameWorkstore/protocolui.git#1.1.5"
```

# Contributions

If you are using this library and want to submit a change, go ahead! Overall, this project accepts contributions if:
- Is a bug fix;
- Or, is a generalization of a well-known issue;
- Or is performance improvement;
- Or is an improvement to already supported feature.

Also, you can donate to allow us to drink coffee while we improve it for you!
7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Listeners.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Runtime/Listeners/UIActiveStateButtonListener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using GameWorkstore.Patterns;
using UnityEngine;
using UnityEngine.UI;

namespace GameWorkstore.ProtocolUI
{
public class UIActiveStateButtonListener : MonoBehaviour
{
public UIStateScriptable State;
private UIStateService _uistateservice;

// Start is called before the first frame update
private void Awake()
{
_uistateservice = ServiceProvider.GetService<UIStateService>();
GetComponent<Button>().onClick.AddListener(OnClick);
}

private void OnClick()
{
_uistateservice.SetState(State, true);
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Listeners/UIActiveStateButtonListener.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Runtime/Listeners/UIDisableStateButtonListener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using GameWorkstore.Patterns;
using UnityEngine;
using UnityEngine.UI;

namespace GameWorkstore.ProtocolUI
{
public class UIDisableStateButtonListener : MonoBehaviour
{
public UIStateScriptable State;
private UIStateService _uistateservice;

// Start is called before the first frame update
private void Awake()
{
_uistateservice = ServiceProvider.GetService<UIStateService>();
GetComponent<Button>().onClick.AddListener(OnClick);
}

private void OnClick()
{
_uistateservice.SetState(State, false);
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Listeners/UIDisableStateButtonListener.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions Runtime/UICanvas.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;
using GameWorkstore.Patterns;

namespace GameWorkstore.ProtocolUI
{
public class UICanvas : MonoBehaviour
{
public StatePreview[] LayeredStates;
public UIStateScriptable[] ActiveStates;
public UIStateScriptable[] EditorActiveStates;
[SerializeField] private Transform _uiPanelComponentsParent;
private readonly HighSpeedArray<UIPanel> _panels = new HighSpeedArray<UIPanel>(128);

private void Awake()
{
if(_uiPanelComponentsParent != null)
{
var UIpanels = _uiPanelComponentsParent.GetComponentsInChildren<UIPanel>(true).ToList();

foreach(var panel in UIpanels)
{
_panels.Add(panel);
panel.Register();
}
}
else //find all UI Panels on scene
{
for(int i = 0; i < SceneManager.sceneCount; i++)
{
foreach (var panels in SceneManager.GetSceneAt(i).GetRootGameObjects().Select(t => t.GetComponentsInChildren<UIPanel>(true)))
{
foreach(var panel in panels)
{
_panels.Add(panel);
panel.Register();
}
}
}
}

var _stateService = ServiceProvider.GetService<UIStateService>();
for (int i = 0; i < LayeredStates.Length; i++)
{
for (var j = 0; j < LayeredStates[i].States.Length; j++)
{
var state = LayeredStates[i].States[j];
_stateService.RegisterState(state, LayeredStates[i].Layer);
}
}
#if UNITY_EDITOR
for (int i = 0; i < EditorActiveStates.Length; i++)
{
_stateService.SetState(EditorActiveStates[i], true);
}
#else
for(int i=0;i < ActiveStates.Length; i++)
{
_stateService.SetState(ActiveStates[i], true);
}
#endif
}

private void OnDestroy()
{
_panels.ForEach(t => t.Unregister());
}
}
}
11 changes: 11 additions & 0 deletions Runtime/UICanvas.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b8dd7c9

Please sign in to comment.