Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
33356e9
wip: Mobile UI refactor
hammerlerobi Dec 2, 2024
8e026d1
wip: Touch UI working
hammerlerobi Dec 2, 2024
bc7c37a
Merge branch 'develop' into feat/distributed-authority-sample/improve…
hammerlerobi Dec 3, 2024
d8eef1b
wip: Mobile UI improvements
hammerlerobi Dec 4, 2024
cfcc315
feat: Only allow landscape mode
hammerlerobi Dec 4, 2024
72324da
feat: Manage keyboard on Mobile
hammerlerobi Dec 4, 2024
6c35961
Merge branch 'develop' into feat/distributed-authority-sample/improve…
hammerlerobi Dec 4, 2024
1b465f7
feat: make settings ui touchable
hammerlerobi Dec 4, 2024
a3dcb7c
chore: rename
hammerlerobi Dec 5, 2024
a97f76f
chore: extract class
hammerlerobi Dec 5, 2024
8638327
chore: cleanup unnecessary changes
hammerlerobi Dec 5, 2024
b4daf9e
chore: Improve folder structure
hammerlerobi Dec 5, 2024
d533dd7
chore: remove unnecessary icon
hammerlerobi Dec 5, 2024
8ce0f4e
chore: Cleanup Event registration
hammerlerobi Dec 5, 2024
22c3ad1
chore: cleanup
hammerlerobi Dec 5, 2024
3480a4a
feat: Add stylesheet overwrite
hammerlerobi Dec 6, 2024
cafc03f
chore: renaming, restructure etc.
hammerlerobi Dec 6, 2024
58d4cd8
feat: increase audio distance
hammerlerobi Dec 6, 2024
d7602bf
docsL: readd comment
hammerlerobi Dec 6, 2024
58899a2
chore: remove warnings about changed path to textures
hammerlerobi Dec 6, 2024
fcacf29
feat: improve focus states
hammerlerobi Dec 9, 2024
2c96262
feat: align touch input button styles to the rest of the UI
hammerlerobi Dec 10, 2024
542db95
feat: improve colapse button
hammerlerobi Dec 10, 2024
490aa0b
Merge branch 'develop' into feat/distributed-authority-sample/improve…
hammerlerobi Dec 10, 2024
a2f474b
chore: extract constants
hammerlerobi Dec 16, 2024
602aaeb
chore: access modifieres and constants
hammerlerobi Dec 16, 2024
1d7e95d
Merge branch 'develop' into feat/distributed-authority-sample/improve…
hammerlerobi Dec 16, 2024
df87f09
docs: add changelog entry
hammerlerobi Dec 16, 2024
99d5d15
chore: rename variables
hammerlerobi Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 8260601768609746557}
- component: {fileID: 2624134516453966882}
- component: {fileID: 7977430163742817466}
- component: {fileID: 6103793809426782772}
m_Layer: 0
m_Name: WorldspaceUIContainer
m_TagString: Untagged
Expand Down Expand Up @@ -96,6 +97,20 @@ UIRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!114 &6103793809426782772
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3209112381140291289}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c3f1e8062945c4f4d846b5dd47a10b49, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Stylesheet:
- {fileID: 7433441132597879392, guid: ea9efe379dfd4506ad59f7fe609e1c85, type: 3}
--- !u!1 &3760817242580890973
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -227,8 +242,8 @@ Transform:
- {fileID: 2256034313796960807}
- {fileID: 7559383771208540613}
- {fileID: 8481058004063830698}
- {fileID: 6866794867799222920}
- {fileID: 7817311818480281289}
- {fileID: 6866794867799222920}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &5231826839060252271
Expand All @@ -241,6 +256,7 @@ GameObject:
m_Component:
- component: {fileID: 3336661237540986728}
- component: {fileID: 436460152536684898}
- component: {fileID: 7317808533901021140}
m_Layer: 0
m_Name: ScreenspaceUIContainer
m_TagString: Untagged
Expand Down Expand Up @@ -282,6 +298,20 @@ MonoBehaviour:
m_WorldSpaceSizeMode: 1
m_WorldSpaceWidth: 1920
m_WorldSpaceHeight: 1080
--- !u!114 &7317808533901021140
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5231826839060252271}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c3f1e8062945c4f4d846b5dd47a10b49, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Stylesheet:
- {fileID: 7433441132597879392, guid: ea9efe379dfd4506ad59f7fe609e1c85, type: 3}
--- !u!1 &6990578997068127384
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -339,7 +369,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 7817311818480281289}
- component: {fileID: 2936985890301440173}
- component: {fileID: 6707317209091797481}
m_Layer: 0
m_Name: TouchUI
Expand All @@ -363,25 +392,6 @@ Transform:
m_Children: []
m_Father: {fileID: 8617889547341104717}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2936985890301440173
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7432143492640579472}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_PanelSettings: {fileID: 11400000, guid: f87c14ce92c804cf2a078e05e3ee2019, type: 2}
m_ParentUI: {fileID: 0}
sourceAsset: {fileID: 9197481963319205126, guid: ccd45339dc8ff154fbbe578856089eaf, type: 3}
m_SortingOrder: 0
m_WorldSpaceSizeMode: 1
m_WorldSpaceWidth: 1920
m_WorldSpaceHeight: 1080
--- !u!114 &6707317209091797481
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -394,6 +404,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6d7e4e4868ed5df4b928c22423c690a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Document: {fileID: 436460152536684898}
m_TouchscreenUI: {fileID: 9197481963319205126, guid: ccd45339dc8ff154fbbe578856089eaf, type: 3}
--- !u!1 &7898239706649082948
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ GameObject:
- component: {fileID: 378839173}
- component: {fileID: 378839172}
- component: {fileID: 378839174}
- component: {fileID: 378839175}
m_Layer: 0
m_Name: MainMenuUI
m_TagString: Untagged
Expand Down Expand Up @@ -399,6 +400,20 @@ MonoBehaviour:
m_EditorClassIdentifier:
IsModal: 0
m_HomeView: {fileID: 2105351336}
--- !u!114 &378839175
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 378839171}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c3f1e8062945c4f4d846b5dd47a10b49, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Stylesheet:
- {fileID: 7433441132597879392, guid: ea9efe379dfd4506ad59f7fe609e1c85, type: 3}
--- !u!1 &1088131142
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Threading.Tasks;
using Unity.Services.Vivox;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace Unity.Multiplayer.Samples.SocialHub.GameManagement
Expand All @@ -21,6 +22,8 @@ static class GameplayEventHandler
internal static event Action<VivoxParticipant> OnParticipantJoinedVoiceChat;
internal static event Action<VivoxParticipant> OnParticipantLeftVoiceChat;

internal static event Action<PickupState, Transform> OnPickupStateChanged;

internal static void NetworkObjectDespawned(NetworkObject networkObject)
{
OnNetworkObjectDespawned?.Invoke(networkObject);
Expand Down Expand Up @@ -90,5 +93,17 @@ public static void ParticipantLeftVoiceChat(VivoxParticipant vivoxParticipant)
{
OnParticipantLeftVoiceChat?.Invoke(vivoxParticipant);
}

internal static void SetAvatarPickupState(PickupState state, Transform pickup)
{
OnPickupStateChanged?.Invoke(state, pickup);
}
}

internal enum PickupState
{
Inactive,
PickupInRange,
Carry
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class AvatarInteractions : NetworkBehaviour, INetworkUpdateSystem

TransferableObject m_TransferableObject;

PickUpIndicator m_PickUpIndicator;

CarryBoxIndicator m_CarryBoxIndicator;

const float k_MinDurationHeld = 0f;
const float k_MaxDurationHeld = 2f;

Expand Down Expand Up @@ -92,9 +88,6 @@ public override void OnNetworkSpawn()

this.RegisterNetworkUpdate(updateStage: NetworkUpdateStage.FixedUpdate);

m_PickUpIndicator = FindFirstObjectByType<PickUpIndicator>();
m_CarryBoxIndicator = FindFirstObjectByType<CarryBoxIndicator>();

GameInput.Actions.Player.Interact.performed += OnInteractPerformed;
GameInput.Actions.Player.Interact.canceled += OnInteractCanceled;

Expand Down Expand Up @@ -284,8 +277,7 @@ void StartPickup(TransferableObject other)
// Rotate the player to face the item smoothly
StartCoroutine(SmoothLookAt(other.transform));
m_AvatarNetworkAnimator.SetTrigger(k_PickupId);
m_PickUpIndicator.ClearPickup();
m_CarryBoxIndicator.ShowCarry(m_TransferableObject.transform);
GameplayEventHandler.SetAvatarPickupState(PickupState.Carry, m_TransferableObject.transform);
}

IEnumerator SmoothLookAt(Transform target)
Expand Down Expand Up @@ -383,7 +375,7 @@ void DropAction()
SetTransferableObjectAsTransferableDistributable();
OnDropAction();
m_CurrentTransferableObject.Value = new NetworkBehaviourReference();
m_CarryBoxIndicator.HideCarry();
GameplayEventHandler.SetAvatarPickupState(PickupState.Inactive, null);
}

// invoked on all clients
Expand Down Expand Up @@ -419,7 +411,7 @@ void ThrowAction(double holdDuration)

OnThrowAction();
m_CurrentTransferableObject.Value = new NetworkBehaviourReference();
m_CarryBoxIndicator.HideCarry();
GameplayEventHandler.SetAvatarPickupState(PickupState.Inactive, null);
}

// invoked on all clients
Expand Down Expand Up @@ -493,13 +485,12 @@ void CheckForPickupsInRange()
m_PotentialPickupCollider = resultCollider;
}
}

m_PickUpIndicator.ShowPickup(m_PotentialPickupCollider.transform);
GameplayEventHandler.SetAvatarPickupState(PickupState.PickupInRange, m_PotentialPickupCollider.transform);
}
else
{
m_PotentialPickupCollider = null;
m_PickUpIndicator.ClearPickup();
GameplayEventHandler.SetAvatarPickupState(PickupState.Inactive, null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ namespace Unity.Multiplayer.Samples.SocialHub.Services
{
class VivoxManager : MonoBehaviour
{
const int k_AudibleDistance = 20;
const int k_ConventionalDistance = 1;
const float k_AudioFadeByDistance = 1f;

string m_TextChannelName;
string m_VoiceChannelName;

#if UNITY_STANDALONE_OSX || UNITY_IOS
bool m_MicPermissionChecked;

#endif

internal static VivoxManager Instance { get; private set; }
Expand Down Expand Up @@ -76,7 +81,7 @@ async void OnLoggedInVivox()

async Task JoinChannels()
{
var positionalChannelProperties = new Channel3DProperties(10, 1, 1f, AudioFadeModel.InverseByDistance);
var positionalChannelProperties = new Channel3DProperties(k_AudibleDistance, k_ConventionalDistance, k_AudioFadeByDistance, AudioFadeModel.InverseByDistance);
BindChannelEvents(true);
await VivoxService.Instance.JoinPositionalChannelAsync(m_VoiceChannelName, ChatCapability.AudioOnly, positionalChannelProperties);
await VivoxService.Instance.JoinGroupChannelAsync(m_TextChannelName, ChatCapability.TextOnly);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections;
using Unity.Multiplayer.Samples.SocialHub.GameManagement;
using UnityEngine;
using UnityEngine.UIElements;

Expand Down Expand Up @@ -42,9 +43,21 @@ void OnEnable()
m_CarryUI.Q<Label>("call-to-action").text = "tap - drop \nhold - throw";
m_CarryUI.AddToClassList("carrybox");
m_CarryUI.AddToClassList(UIUtils.s_InactiveUSSClass);

GameplayEventHandler.OnPickupStateChanged += OnPickupStateChanged;
}

internal void ShowCarry(Transform t)
void OnPickupStateChanged(PickupState state, Transform pickupTransform)
{
if (state == PickupState.Carry)
{
ShowCarry(pickupTransform);
return;
}
HideCarry();
}

void ShowCarry(Transform t)
{
if (m_IsShown)
return;
Expand All @@ -57,7 +70,7 @@ internal void ShowCarry(Transform t)
m_IsShown = true;
}

internal void HideCarry()
void HideCarry()
{
if(m_IsShown == false)
return;
Expand All @@ -84,5 +97,10 @@ void Update()
var mappedScale = Mathf.Lerp(m_PanelMaxSize, m_PanelMinSize, Mathf.InverseLerp(5, 20, distance));
m_CarryUI.style.scale = new StyleScale(new Vector2(mappedScale, mappedScale));
}

void OnDisable()
{
GameplayEventHandler.OnPickupStateChanged -= OnPickupStateChanged;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class IngameMenu : MonoBehaviour

VisualElement m_Root;
VisualElement m_Menu;
VisualElement m_SceenOverlay;
VisualElement m_ScreenOverlay;

Button m_BurgerButton;
Button m_ExitButton;
Expand All @@ -41,7 +41,7 @@ void OnEnable()
m_Root = m_UIDocument.rootVisualElement.Q<VisualElement>("ingame-menu-container");
m_Root.Add(m_IngameMenuAsset.CloneTree().GetFirstChild());

m_SceenOverlay = m_Root.Q<VisualElement>("sceen-overlay");
m_ScreenOverlay = m_Root.Q<VisualElement>("screen-overlay");

m_BurgerButton = m_Root.Q<Button>("burger-button");
m_BurgerButton.clicked += ShowMenu;
Expand Down Expand Up @@ -117,14 +117,14 @@ void ShowMenu()
InputSystemManager.Instance.EnableUIInputs();
m_Menu.RemoveFromClassList(UIUtils.s_InactiveUSSClass);
m_Menu.AddToClassList(UIUtils.s_ActiveUSSClass);
m_SceenOverlay.style.display = DisplayStyle.Flex;
m_ScreenOverlay.style.display = DisplayStyle.Flex;
m_Menu.SetEnabled(true);
}

void HideMenu()
{
InputSystemManager.Instance.EnableGameplayInputs();
m_SceenOverlay.style.display = DisplayStyle.None;
m_ScreenOverlay.style.display = DisplayStyle.None;
m_Menu.RemoveFromClassList(UIUtils.s_ActiveUSSClass);
m_Menu.AddToClassList(UIUtils.s_InactiveUSSClass);
m_Menu.SetEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Unity.Multiplayer.Samples.SocialHub.Input;
using UnityEngine;
using UnityEngine.UIElements;

namespace Unity.Multiplayer.Samples.SocialHub.UI
{
[RequireComponent(typeof(UIDocument))]
class MobileStylesheetAdder : MonoBehaviour
{
[SerializeField]
StyleSheet[] m_Stylesheet;

async void Awake()
{
var isMobile = await InputSystemManager.IsMobile;
if (!isMobile)
{
return;
}

var uiDocument = GetComponent<UIDocument>();
foreach (var styleSheet in m_Stylesheet)
{
uiDocument.rootVisualElement.styleSheets.Add(styleSheet);
}
}
}
}

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

Loading