In Game Input Screen
Implemented saving/loading of custom input settings Incorporated Input Screen in game Organized UI scripts into folders Deleted some unused UI scripts Reimplemented Fog Blur (by copying modified DoF to assets)
This commit is contained in:
parent
d47c32dfcf
commit
81acaf2a47
173 changed files with 8236 additions and 7329 deletions
|
|
@ -1,110 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FlatButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||||
{
|
||||
public event Action OnClick;
|
||||
public float StateDamping;
|
||||
// public RectTransform Tab;
|
||||
public Image Fill;
|
||||
public Image Outline;
|
||||
public VerticalLayoutGroup LabelLayout;
|
||||
public FlatButtonState CurrentState = FlatButtonState.Unselected;
|
||||
public bool DisableClickWhenSelected = true;
|
||||
|
||||
public FlatButtonAppearance UnselectedAppearance;
|
||||
public FlatButtonAppearance SelectedAppearance;
|
||||
public FlatButtonAppearance HoverAppearance;
|
||||
public FlatButtonAppearance ClickAppearance;
|
||||
public FlatButtonAppearance DisabledAppearance;
|
||||
|
||||
private RectOffset _defaultPadding;
|
||||
private float _currentPadding;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_defaultPadding = LabelLayout.padding;
|
||||
_currentPadding = _defaultPadding.left;
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState == FlatButtonState.Unselected)
|
||||
CurrentState = FlatButtonState.Hover;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState == FlatButtonState.Hover)
|
||||
CurrentState = FlatButtonState.Unselected;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState != FlatButtonState.Disabled && (!DisableClickWhenSelected || CurrentState != FlatButtonState.Selected))
|
||||
{
|
||||
Fill.color = ClickAppearance.FillColor;
|
||||
Outline.color = ClickAppearance.OutlineColor;
|
||||
OnClick?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
FlatButtonAppearance appearance;
|
||||
switch (CurrentState)
|
||||
{
|
||||
case FlatButtonState.Unselected:
|
||||
appearance = UnselectedAppearance;
|
||||
break;
|
||||
case FlatButtonState.Selected:
|
||||
appearance = SelectedAppearance;
|
||||
break;
|
||||
case FlatButtonState.Hover:
|
||||
appearance = HoverAppearance;
|
||||
break;
|
||||
case FlatButtonState.Disabled:
|
||||
appearance = DisabledAppearance;
|
||||
break;
|
||||
default:
|
||||
appearance = new FlatButtonAppearance();
|
||||
break;
|
||||
}
|
||||
|
||||
Fill.color = Color.Lerp(Fill.color, appearance.FillColor, StateDamping * Time.deltaTime);
|
||||
Outline.color = Color.Lerp(Outline.color, appearance.OutlineColor, StateDamping * Time.deltaTime);
|
||||
_currentPadding = Mathf.Lerp(_currentPadding, appearance.LayoutPadding, StateDamping * Time.deltaTime);
|
||||
LabelLayout.padding = new RectOffset
|
||||
{
|
||||
bottom = _defaultPadding.bottom,
|
||||
top = _defaultPadding.top,
|
||||
left = (int) _currentPadding,
|
||||
right = (int) _currentPadding
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum FlatButtonState
|
||||
{
|
||||
Unselected,
|
||||
Selected,
|
||||
Hover,
|
||||
Disabled
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct FlatButtonAppearance
|
||||
{
|
||||
public Color FillColor;
|
||||
public Color OutlineColor;
|
||||
public int LayoutPadding;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9ec664fdf25c943478e0ca99c935c2fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FlatFlatButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public event Action<PointerEventData> OnClick;
|
||||
public float StateDamping;
|
||||
// public RectTransform Tab;
|
||||
public Image Fill;
|
||||
public TextMeshProUGUI Label;
|
||||
public FlatButtonState CurrentState = FlatButtonState.Unselected;
|
||||
public bool DisableClickWhenSelected = true;
|
||||
public RectTransform DragObject;
|
||||
|
||||
public Color UnselectedColor;
|
||||
public Color SelectedColor;
|
||||
public Color HoverColor;
|
||||
public Color ClickColor;
|
||||
public Color DisabledColor;
|
||||
public Color EnabledTextColor;
|
||||
public Color DisabledTextColor;
|
||||
|
||||
public Func<PointerEventData, bool> DragSuccess;
|
||||
private int _siblingIndex;
|
||||
private Transform _dragParent;
|
||||
private Vector3 _dragPositionOffset;
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (OnClick != null && CurrentState == FlatButtonState.Unselected)
|
||||
CurrentState = FlatButtonState.Hover;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState == FlatButtonState.Hover)
|
||||
CurrentState = FlatButtonState.Unselected;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (CurrentState != FlatButtonState.Disabled && (!DisableClickWhenSelected || CurrentState != FlatButtonState.Selected))
|
||||
{
|
||||
if (OnClick != null)
|
||||
{
|
||||
Fill.color = ClickColor;
|
||||
OnClick(eventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if (DragSuccess == null || DragObject == null)
|
||||
{
|
||||
eventData.pointerDrag = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var canvas = gameObject.FindInParents<Canvas>();
|
||||
if (canvas == null)
|
||||
return;
|
||||
|
||||
_siblingIndex = DragObject.GetSiblingIndex();
|
||||
_dragParent = DragObject.parent;
|
||||
|
||||
DragObject.SetParent(canvas.transform, true);
|
||||
_dragPositionOffset = DragObject.position - (Vector3)eventData.position;
|
||||
DragObject.SetAsLastSibling();
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
var targetPosition = (Vector3)eventData.position + _dragPositionOffset;
|
||||
//Debug.Log($"Moving drag object to {targetPosition}");
|
||||
DragObject.position = targetPosition;
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
if(DragSuccess(eventData))
|
||||
Destroy(DragObject.gameObject);
|
||||
else
|
||||
{
|
||||
DragObject.parent = _dragParent;
|
||||
DragObject.SetSiblingIndex(_siblingIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Color appearance;
|
||||
switch (CurrentState)
|
||||
{
|
||||
case FlatButtonState.Unselected:
|
||||
appearance = UnselectedColor;
|
||||
break;
|
||||
case FlatButtonState.Selected:
|
||||
appearance = SelectedColor;
|
||||
break;
|
||||
case FlatButtonState.Hover:
|
||||
appearance = HoverColor;
|
||||
break;
|
||||
case FlatButtonState.Disabled:
|
||||
appearance = DisabledColor;
|
||||
break;
|
||||
default:
|
||||
appearance = Color.white;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Label != null)
|
||||
Label.color = Color.Lerp(Label.color,
|
||||
CurrentState == FlatButtonState.Disabled ? DisabledTextColor : EnabledTextColor, StateDamping * Time.deltaTime);
|
||||
Fill.color = Color.Lerp(Fill.color, appearance, StateDamping * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fafbcd26aa8d175448880b37b7a41b2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/UI/HUD.meta
Normal file
8
Assets/Scripts/UI/HUD.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a72db0c93905d9c46bd021fe8d9f5dac
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "Icons", menuName = "Aetheria/Icons")]
|
||||
public class Icons : ScriptableObject
|
||||
{
|
||||
public Texture2D plus;
|
||||
public Texture2D minus;
|
||||
|
||||
private const string AssetPath = "Icons";
|
||||
private static Icons _instance;
|
||||
public static Icons Instance {
|
||||
get { return _instance ?? (_instance = Resources.Load<Icons>(AssetPath)); }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 32eff58a98b2e4c43a9a375c7db56e25
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -53,6 +53,8 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
private ButtonMapping _previewButton;
|
||||
private ActionMapping _previewOriginalAction;
|
||||
private bool _previewOriginallyActionBar;
|
||||
|
||||
public InputActionAsset Input { get; set; }
|
||||
|
||||
private class ButtonMapping
|
||||
{
|
||||
|
|
@ -83,11 +85,12 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
void Start()
|
||||
{
|
||||
_canvas = transform.root.GetComponent<Canvas>();
|
||||
var path = Path.Combine(ActionGameManager.GameDataDirectory.CreateSubdirectory("KeyboardLayouts").FullName, $"{LayoutFile.name}.json");
|
||||
var path = Path.Combine(ActionGameManager.GameDataDirectory.CreateSubdirectory("KeyboardLayouts").FullName, $"{LayoutFile.name}.msgpack");
|
||||
// _inputLayout = ParseJson(LayoutFile.text);
|
||||
//RegisterResolver.Register();
|
||||
//_inputLayout = MessagePackSerializer.Deserialize<InputLayout>(File.ReadAllBytes(path));
|
||||
_inputLayout = JsonConvert.DeserializeObject<InputLayout>(File.ReadAllText(path));
|
||||
RegisterResolver.Register();
|
||||
_inputLayout = MessagePackSerializer.Deserialize<InputLayout>(File.ReadAllBytes(path));
|
||||
// _inputLayout = JsonConvert.DeserializeObject<InputLayout>(File.ReadAllText(path));
|
||||
// SaveLayout();
|
||||
DisplayLayout(_inputLayout);
|
||||
|
||||
_buttonMappings.Add(MapMouseButton(MouseLeft, "<Mouse>/leftButton"));
|
||||
|
|
@ -97,33 +100,6 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
_buttonMappings.Add(MapMouseButton(MouseBack, "<Mouse>/backButton"));
|
||||
|
||||
Canvas.ForceUpdateCanvases();
|
||||
|
||||
void EndDrag(PointerEventData _)
|
||||
{
|
||||
if (_previewButton == null)
|
||||
{
|
||||
if(_originalButton!=null)
|
||||
{
|
||||
_originalButton.ActionMapping = _dragAction;
|
||||
_dragAction.ButtonMappings.Add(_originalButton);
|
||||
AssignColor(_originalButton);
|
||||
}
|
||||
PlaceLabel(_dragAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dragAction.Binding.overridePath = _previewButton.Button.InputSystemPath;
|
||||
_dragAction.Action.ApplyBindingOverride(_dragAction.Binding);
|
||||
// TODO: Assign New Binding
|
||||
}
|
||||
|
||||
foreach(var action in _actionMappings)
|
||||
action.Label.Label.raycastTarget = true;
|
||||
_dragAction = null;
|
||||
_originalButton = null;
|
||||
_previewButton = null;
|
||||
_previewOriginalAction = null;
|
||||
}
|
||||
|
||||
foreach (var buttonMapping in _buttonMappings)
|
||||
{
|
||||
|
|
@ -141,89 +117,6 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
};
|
||||
buttonMapping.TestAction.canceled += context => AssignColor(buttonMapping);
|
||||
buttonMapping.TestAction.Enable();
|
||||
|
||||
// On click: when a specific action is not assigned, toggle its availability on the action bar
|
||||
buttonMapping.DisplayButton.ClickTrigger.OnPointerClickAsObservable()
|
||||
.Where(_=>buttonMapping.ActionMapping==null)
|
||||
.Subscribe(data =>
|
||||
{
|
||||
buttonMapping.IsActionBarButton = !buttonMapping.IsActionBarButton;
|
||||
if (buttonMapping.IsActionBarButton)
|
||||
{
|
||||
ActionGameManager.PlayerSettings.InputSettings.ActionBarInputs.Add(buttonMapping.Button.InputSystemPath);
|
||||
foreach(var overlap in OverlappingLabels(buttonMapping.ButtonRect))
|
||||
PlaceLabel(overlap);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionGameManager.PlayerSettings.InputSettings.ActionBarInputs.Remove(buttonMapping.Button.InputSystemPath);
|
||||
}
|
||||
AssignColor(buttonMapping);
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.BeginDragTrigger.OnBeginDragAsObservable()
|
||||
.Where(_ => buttonMapping.ActionMapping != null)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
_originalButton = buttonMapping;
|
||||
buttonMapping.LabelLine.Points = new Vector2[0];
|
||||
_dragAction = buttonMapping.ActionMapping;
|
||||
foreach(var action in _actionMappings)
|
||||
action.Label.Label.raycastTarget = false;
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.EnterTrigger.OnPointerEnterAsObservable()
|
||||
.Where(_ => _dragAction != null)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
_previewButton = buttonMapping;
|
||||
_previewOriginalAction = buttonMapping.ActionMapping;
|
||||
_previewOriginallyActionBar = buttonMapping.IsActionBarButton;
|
||||
buttonMapping.IsActionBarButton = false;
|
||||
|
||||
buttonMapping.ActionMapping?.ButtonMappings.Remove(buttonMapping);
|
||||
buttonMapping.ActionMapping = _dragAction;
|
||||
_dragAction.ButtonMappings.Add(buttonMapping);
|
||||
if(_previewOriginalAction!=null)
|
||||
PlaceLabel(_previewOriginalAction);
|
||||
PlaceLabel(_dragAction);
|
||||
AssignColor(buttonMapping);
|
||||
foreach(var overlap in OverlappingLabels(buttonMapping.ButtonRect))
|
||||
PlaceLabel(overlap);
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.ExitTrigger.OnPointerExitAsObservable()
|
||||
.Where(_ => _dragAction != null)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
_dragAction.ButtonMappings.Remove(buttonMapping);
|
||||
if (buttonMapping == _originalButton)
|
||||
{
|
||||
buttonMapping.ActionMapping = null;
|
||||
}
|
||||
else if(buttonMapping == _previewButton)
|
||||
{
|
||||
buttonMapping.IsActionBarButton = _previewOriginallyActionBar;
|
||||
buttonMapping.ActionMapping = _previewOriginalAction;
|
||||
if (!_previewOriginallyActionBar)
|
||||
{
|
||||
if(_previewOriginalAction != null)
|
||||
{
|
||||
_previewOriginalAction.ButtonMappings.Add(buttonMapping);
|
||||
PlaceLabel(_previewOriginalAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConnectButtonToLabel(buttonMapping);
|
||||
AssignColor(buttonMapping);
|
||||
_previewButton = null;
|
||||
_previewOriginalAction = null;
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.EndDragTrigger.OnEndDragAsObservable()
|
||||
.Where(_ => _dragAction != null)
|
||||
.Subscribe(EndDrag);
|
||||
}
|
||||
|
||||
foreach(var actionBarInput in ActionGameManager.PlayerSettings.InputSettings.ActionBarInputs)
|
||||
|
|
@ -236,34 +129,25 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
var input = new AetheriaInput();
|
||||
ProcessActions(input.asset);
|
||||
input.Enable();
|
||||
input.Global.Interact.performed += context => Debug.Log($"Interact Performed! Time = {((int) (Time.time * 1000)).ToString()}ms");
|
||||
|
||||
foreach (var actionMapping in _actionMappings)
|
||||
if(Input==null)
|
||||
{
|
||||
actionMapping.Label = CreateLabel(actionMapping);
|
||||
actionMapping.Label.BeginDragTrigger.OnBeginDragAsObservable().Subscribe(_ =>
|
||||
{
|
||||
_dragAction = actionMapping;
|
||||
actionMapping.Label.transform.parent = AssignedBindingsGroup;
|
||||
foreach(var action in _actionMappings)
|
||||
action.Label.Label.raycastTarget = false;
|
||||
if (actionMapping.ButtonMappings.Count == 1)
|
||||
{
|
||||
var buttonMapping = actionMapping.ButtonMappings[0];
|
||||
_originalButton = buttonMapping;
|
||||
buttonMapping.LabelLine.Points = new Vector2[0];
|
||||
buttonMapping.ActionMapping = null;
|
||||
actionMapping.ButtonMappings.Clear();
|
||||
ConnectButtonToLabel(buttonMapping);
|
||||
AssignColor(buttonMapping);
|
||||
}
|
||||
});
|
||||
actionMapping.Label.EndDragTrigger.OnEndDragAsObservable().Subscribe(EndDrag);
|
||||
PlaceLabel(actionMapping);
|
||||
var input = new AetheriaInput();
|
||||
Input = input.asset;
|
||||
}
|
||||
ProcessActions(Input);
|
||||
// input.Enable();
|
||||
// input.Global.Interact.performed += context => Debug.Log($"Interact Performed! Time = {((int) (Time.time * 1000)).ToString()}ms");
|
||||
|
||||
Observable.NextFrame().Subscribe(_ =>
|
||||
{
|
||||
foreach (var actionMapping in _actionMappings)
|
||||
{
|
||||
actionMapping.Label = CreateLabel(actionMapping);
|
||||
PlaceLabel(actionMapping);
|
||||
}
|
||||
|
||||
RegisterMouseCallbacks();
|
||||
});
|
||||
|
||||
//StartCoroutine(AssociateInputKeys(_inputLayout));
|
||||
}
|
||||
|
|
@ -287,7 +171,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
var action = bindableActions[i];
|
||||
foreach (var binding in action.bindings)
|
||||
{
|
||||
if (_bindButtons.ContainsKey(binding.path))
|
||||
if (_bindButtons.ContainsKey(binding.effectivePath))
|
||||
{
|
||||
var name = action.name.Replace(' ', '\n');
|
||||
if (binding.isPartOfComposite) name = $"{name} {binding.name}";
|
||||
|
|
@ -302,7 +186,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
};
|
||||
_actionMappings.Add(actionMapping);
|
||||
|
||||
var buttonMapping = _bindButtons[binding.path];
|
||||
var buttonMapping = _bindButtons[binding.effectivePath];
|
||||
buttonMapping.ActionMapping = actionMapping;
|
||||
AssignColor(buttonMapping);
|
||||
actionMapping.ButtonMappings.Add(buttonMapping);
|
||||
|
|
@ -605,12 +489,170 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
}
|
||||
keyPress.Disable();
|
||||
|
||||
SaveLayout();
|
||||
}
|
||||
|
||||
private void SaveLayout()
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
File.WriteAllBytes(
|
||||
Path.Combine(ActionGameManager.GameDataDirectory.CreateSubdirectory("KeyboardLayouts").FullName, $"{LayoutFile.name}.msgpack"),
|
||||
MessagePackSerializer.Serialize(_inputLayout));
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
foreach(var buttonMapping in _buttonMappings)
|
||||
buttonMapping.TestAction.Enable();
|
||||
RegisterMouseCallbacks();
|
||||
}
|
||||
|
||||
private void RegisterMouseCallbacks()
|
||||
{
|
||||
void EndDrag(PointerEventData _)
|
||||
{
|
||||
if (_previewButton == null)
|
||||
{
|
||||
if(_originalButton!=null)
|
||||
{
|
||||
_originalButton.ActionMapping = _dragAction;
|
||||
_dragAction.ButtonMappings.Add(_originalButton);
|
||||
AssignColor(_originalButton);
|
||||
}
|
||||
PlaceLabel(_dragAction);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dragAction.Binding.overridePath = _previewButton.Button.InputSystemPath;
|
||||
_dragAction.Action.ApplyBindingOverride(_dragAction.Binding);
|
||||
ActionGameManager.PlayerSettings.InputSettings.InputActionMap[(_dragAction.Action.name,
|
||||
_dragAction.Action.GetBindingIndex(_dragAction.Binding))] = _previewButton.Button.InputSystemPath;
|
||||
// TODO: Assign New Binding
|
||||
}
|
||||
|
||||
foreach(var action in _actionMappings)
|
||||
action.Label.Label.raycastTarget = true;
|
||||
_dragAction = null;
|
||||
_originalButton = null;
|
||||
_previewButton = null;
|
||||
_previewOriginalAction = null;
|
||||
}
|
||||
|
||||
foreach (var buttonMapping in _buttonMappings)
|
||||
{
|
||||
// On click: when a specific action is not assigned, toggle its availability on the action bar
|
||||
buttonMapping.DisplayButton.ClickTrigger.OnPointerClickAsObservable()
|
||||
.Where(_=>buttonMapping.ActionMapping==null)
|
||||
.Subscribe(data =>
|
||||
{
|
||||
buttonMapping.IsActionBarButton = !buttonMapping.IsActionBarButton;
|
||||
if (buttonMapping.IsActionBarButton)
|
||||
{
|
||||
ActionGameManager.PlayerSettings.InputSettings.ActionBarInputs.Add(buttonMapping.Button.InputSystemPath);
|
||||
foreach(var overlap in OverlappingLabels(buttonMapping.ButtonRect))
|
||||
PlaceLabel(overlap);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionGameManager.PlayerSettings.InputSettings.ActionBarInputs.Remove(buttonMapping.Button.InputSystemPath);
|
||||
}
|
||||
AssignColor(buttonMapping);
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.BeginDragTrigger.OnBeginDragAsObservable()
|
||||
.Where(_ => buttonMapping.ActionMapping != null)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
_originalButton = buttonMapping;
|
||||
buttonMapping.LabelLine.Points = new Vector2[0];
|
||||
_dragAction = buttonMapping.ActionMapping;
|
||||
foreach(var action in _actionMappings)
|
||||
action.Label.Label.raycastTarget = false;
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.EnterTrigger.OnPointerEnterAsObservable()
|
||||
.Where(_ => _dragAction != null)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
_previewButton = buttonMapping;
|
||||
_previewOriginalAction = buttonMapping.ActionMapping;
|
||||
_previewOriginallyActionBar = buttonMapping.IsActionBarButton;
|
||||
buttonMapping.IsActionBarButton = false;
|
||||
|
||||
buttonMapping.ActionMapping?.ButtonMappings.Remove(buttonMapping);
|
||||
buttonMapping.ActionMapping = _dragAction;
|
||||
_dragAction.ButtonMappings.Add(buttonMapping);
|
||||
if(_previewOriginalAction!=null)
|
||||
PlaceLabel(_previewOriginalAction);
|
||||
PlaceLabel(_dragAction);
|
||||
AssignColor(buttonMapping);
|
||||
foreach(var overlap in OverlappingLabels(buttonMapping.ButtonRect))
|
||||
PlaceLabel(overlap);
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.ExitTrigger.OnPointerExitAsObservable()
|
||||
.Where(_ => _dragAction != null)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
_dragAction.ButtonMappings.Remove(buttonMapping);
|
||||
if (buttonMapping == _originalButton)
|
||||
{
|
||||
buttonMapping.ActionMapping = null;
|
||||
}
|
||||
else if(buttonMapping == _previewButton)
|
||||
{
|
||||
buttonMapping.IsActionBarButton = _previewOriginallyActionBar;
|
||||
buttonMapping.ActionMapping = _previewOriginalAction;
|
||||
if (!_previewOriginallyActionBar)
|
||||
{
|
||||
if(_previewOriginalAction != null)
|
||||
{
|
||||
_previewOriginalAction.ButtonMappings.Add(buttonMapping);
|
||||
PlaceLabel(_previewOriginalAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConnectButtonToLabel(buttonMapping);
|
||||
AssignColor(buttonMapping);
|
||||
_previewButton = null;
|
||||
_previewOriginalAction = null;
|
||||
});
|
||||
|
||||
buttonMapping.DisplayButton.EndDragTrigger.OnEndDragAsObservable()
|
||||
.Where(_ => _dragAction != null)
|
||||
.Subscribe(EndDrag);
|
||||
}
|
||||
|
||||
foreach (var actionMapping in _actionMappings)
|
||||
{
|
||||
actionMapping.Label.BeginDragTrigger.OnBeginDragAsObservable().Subscribe(_ =>
|
||||
{
|
||||
_dragAction = actionMapping;
|
||||
actionMapping.Label.transform.parent = AssignedBindingsGroup;
|
||||
foreach (var action in _actionMappings)
|
||||
action.Label.Label.raycastTarget = false;
|
||||
if (actionMapping.ButtonMappings.Count == 1)
|
||||
{
|
||||
var buttonMapping = actionMapping.ButtonMappings[0];
|
||||
_originalButton = buttonMapping;
|
||||
buttonMapping.LabelLine.Points = new Vector2[0];
|
||||
buttonMapping.ActionMapping = null;
|
||||
actionMapping.ButtonMappings.Clear();
|
||||
ConnectButtonToLabel(buttonMapping);
|
||||
AssignColor(buttonMapping);
|
||||
}
|
||||
});
|
||||
actionMapping.Label.EndDragTrigger.OnEndDragAsObservable().Subscribe(EndDrag);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
foreach(var buttonMapping in _buttonMappings)
|
||||
buttonMapping.TestAction.Disable();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_dragAction != null && _previewButton == null)
|
||||
|
|
|
|||
|
|
@ -1,89 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class LoginScreen : MonoBehaviour
|
||||
{
|
||||
public FlatButton LoginButton;
|
||||
public FlatButton RegisterButton;
|
||||
public TMP_InputField Server;
|
||||
public TMP_InputField EmailUsername;
|
||||
public TMP_InputField Email;
|
||||
public TMP_InputField Username;
|
||||
public TMP_InputField Password;
|
||||
public TextMeshProUGUI Error;
|
||||
|
||||
private bool _registering;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Error.text = " ";
|
||||
LoginButton.CurrentState = FlatButtonState.Selected;
|
||||
CultClient.AddMessageListener<LoginSuccessMessage>(success => SceneManager.LoadScene("Main"));
|
||||
CultClient.OnError += s => Error.text = s;
|
||||
RegisterButton.OnClick += () =>
|
||||
{
|
||||
if(!CultClient.Connected)
|
||||
CultClient.Connect(Server.text);
|
||||
if (_registering)
|
||||
{
|
||||
CultClient.Register(Email.text, Username.text, Password.text);
|
||||
}
|
||||
else
|
||||
{
|
||||
_registering = true;
|
||||
EmailUsername.gameObject.SetActive(false);
|
||||
Email.gameObject.SetActive(true);
|
||||
Username.gameObject.SetActive(true);
|
||||
LoginButton.CurrentState = FlatButtonState.Unselected;
|
||||
RegisterButton.CurrentState = FlatButtonState.Selected;
|
||||
}
|
||||
};
|
||||
LoginButton.OnClick += () =>
|
||||
{
|
||||
if(!CultClient.Connected)
|
||||
CultClient.Connect(Server.text);
|
||||
if (_registering)
|
||||
{
|
||||
_registering = false;
|
||||
EmailUsername.gameObject.SetActive(true);
|
||||
Email.gameObject.SetActive(false);
|
||||
Username.gameObject.SetActive(false);
|
||||
LoginButton.CurrentState = FlatButtonState.Selected;
|
||||
RegisterButton.CurrentState = FlatButtonState.Unselected;
|
||||
}
|
||||
else
|
||||
{
|
||||
CultClient.Login(EmailUsername.text, Password.text);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
if (Server.isFocused)
|
||||
{
|
||||
if(_registering)
|
||||
Email.Select();
|
||||
else EmailUsername.Select();
|
||||
}
|
||||
else if (EmailUsername.isFocused)
|
||||
Password.Select();
|
||||
else if (Email.isFocused)
|
||||
Username.Select();
|
||||
else if (Username.isFocused)
|
||||
Password.Select();
|
||||
else if (Password.isFocused && Input.GetKeyDown(KeyCode.Return))
|
||||
(_registering ? RegisterButton : LoginButton).OnPointerClick(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a16898360275ccb489eef6245639fb56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/UI/Menu.meta
Normal file
8
Assets/Scripts/UI/Menu.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e572a37b7883b9a4e9ad03f39589b1be
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/UI/Properties Panel.meta
Normal file
8
Assets/Scripts/UI/Properties Panel.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3460afaee84d9f64283d4908724d82b4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -40,11 +40,9 @@ public class PropertiesPanel : MonoBehaviour
|
|||
public RectTransform Content;
|
||||
public RectTransform DragParent;
|
||||
|
||||
[HideInInspector] public FlatFlatButton SelectedChild;
|
||||
[HideInInspector] public ActionGameManager GameManager;
|
||||
|
||||
protected List<GameObject> Properties = new List<GameObject>();
|
||||
protected List<FlatFlatButton> Buttons = new List<FlatFlatButton>();
|
||||
protected event Action RefreshPropertyValues;
|
||||
protected bool RadioSelection = false;
|
||||
|
||||
|
|
@ -54,7 +52,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
protected event Action<GameObject> OnPropertyAdded;
|
||||
protected Action OnPropertiesChanged;
|
||||
|
||||
public int Children => Properties.Count + Buttons.Count;
|
||||
public int Children => Properties.Count;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
|
|
@ -82,19 +80,10 @@ public class PropertiesPanel : MonoBehaviour
|
|||
Destroy(property);
|
||||
Title.text = "Properties";
|
||||
Properties.Clear();
|
||||
Buttons.Clear();
|
||||
SelectedChild = null;
|
||||
RefreshPropertyValues = null;
|
||||
RadioSelection = false;
|
||||
}
|
||||
|
||||
public void Deselect()
|
||||
{
|
||||
if (SelectedChild != null)
|
||||
SelectedChild.CurrentState = FlatButtonState.Unselected;
|
||||
SelectedChild = null;
|
||||
}
|
||||
|
||||
public RectTransform AddSpacer()
|
||||
{
|
||||
var spacer = Instantiate(Spacer, Content ?? transform);
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TabActivator : MonoBehaviour
|
||||
{
|
||||
public TabGroup TabGroup;
|
||||
public TabButton TabButton;
|
||||
|
||||
void Start()
|
||||
{
|
||||
TabGroup.OnTabChange += button => gameObject.SetActive(button == TabButton);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5f60c7818169f95468915fbca3ef4773
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -50
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue