Create UI manager and Hand Menu

This commit is contained in:
2024-08-31 16:16:46 +02:00
parent c9ee891dc6
commit fb7da37a5a
11 changed files with 4836 additions and 18 deletions

View File

@@ -47,4 +47,4 @@ MonoBehaviour:
soloRig: {fileID: 0}
multiplayerRig: {fileID: 0}
networkManager: {fileID: 0}
autoConnectOrHost: 1
autoConnectOrHost: 0

View File

@@ -0,0 +1,67 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6955995418921915169
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4618056563571998380}
- component: {fileID: 410967918817466985}
- component: {fileID: 8817541215649024317}
m_Layer: 0
m_Name: UIManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4618056563571998380
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6955995418921915169}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &410967918817466985
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6955995418921915169}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!114 &8817541215649024317
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6955995418921915169}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cd4d8cf91bea2654aae40de6c5eed10c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
MaxDistance: 5
PressButton: 1
UICanvases: []
AngleDragThreshold: 1

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 828553405a21e8f43af8c6d97bed99fb
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f871c3b28fd786d4f820bea343f67979
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -265,6 +265,10 @@ PrefabInstance:
type: 3}
insertIndex: 0
addedObject: {fileID: 6067009970240072242}
- targetCorrespondingSourceObject: {fileID: 3924027509722682573, guid: 6974999791dc8804fafee05e319aa932,
type: 3}
insertIndex: -1
addedObject: {fileID: 4248594590894639701}
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 3924027509722682562, guid: 6974999791dc8804fafee05e319aa932,
type: 3}
@@ -274,10 +278,6 @@ PrefabInstance:
type: 3}
insertIndex: -1
addedObject: {fileID: -510423355628046216}
- targetCorrespondingSourceObject: {fileID: 3924027509722682562, guid: 6974999791dc8804fafee05e319aa932,
type: 3}
insertIndex: -1
addedObject: {fileID: -5770860015128552594}
- targetCorrespondingSourceObject: {fileID: 3924027509007222379, guid: 6974999791dc8804fafee05e319aa932,
type: 3}
insertIndex: -1
@@ -319,7 +319,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
m_Name:
m_EditorClassIdentifier:
GlobalObjectIdHash: 918221477
GlobalObjectIdHash: 3394388680
InScenePlacedSourceGlobalObjectIdHash: 0
AlwaysReplicateAsRoot: 0
SynchronizeTransform: 1
@@ -346,18 +346,6 @@ MonoBehaviour:
characterController: {fileID: 75161257133195802}
audioListener: {fileID: 177002782121805273}
fadeDuration: 2
--- !u!114 &-5770860015128552594
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 75161255762383020}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2e5b279a1a044cee9d64e0ca5d85f175, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &75161257133195781 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 3924027509007222379, guid: 6974999791dc8804fafee05e319aa932,
@@ -499,6 +487,12 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 3999184345544213614}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1752414549260446689 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 3399697951127400335, guid: 6974999791dc8804fafee05e319aa932,
type: 3}
m_PrefabInstance: {fileID: 3999184345544213614}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1769633659522639271 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 3454529842381103561, guid: 6974999791dc8804fafee05e319aa932,
@@ -713,6 +707,234 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 3999184345544213614}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &4965874786959955690
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 75161255762383011}
m_Modifications:
- target: {fileID: 1167109536727088238, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1167109536727088238, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1984791675178650107, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2047327049452706315, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_Name
value: HandMenu
objectReference: {fileID: 0}
- target: {fileID: 2047327049452706315, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4006177985381625789, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4006177985381625789, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4006177985381625789, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4902439573492140877, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6716222852013934799, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6716222852013934799, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8229289315410888834, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8229289315410888834, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8229289315410888834, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMax.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMin.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_SizeDelta.x
value: 1542.9
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_SizeDelta.y
value: 376.2
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalScale.x
value: 0.0008759591
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalScale.y
value: 0.0008759591
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalScale.z
value: 0.0008759591
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 2047327049452706315, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
insertIndex: -1
addedObject: {fileID: 1789717162071776571}
m_SourcePrefab: {fileID: 100100000, guid: f871c3b28fd786d4f820bea343f67979, type: 3}
--- !u!224 &4248594590894639701 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 9087242102629915839, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
m_PrefabInstance: {fileID: 4965874786959955690}
m_PrefabAsset: {fileID: 0}
--- !u!1 &6378159012725935329 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2047327049452706315, guid: f871c3b28fd786d4f820bea343f67979,
type: 3}
m_PrefabInstance: {fileID: 4965874786959955690}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1789717162071776571
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6378159012725935329}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 889a6708f6f028c4e96df3407816950a, type: 3}
m_Name:
m_EditorClassIdentifier:
anchor: {fileID: 1752414549260446689}
forwardOffset: 1
--- !u!1001 &7547917675261119406
PrefabInstance:
m_ObjectHideFlags: 0

View File

@@ -86,3 +86,5 @@ MonoBehaviour:
type: 3}
playerPrefab: {fileID: 75161255762383020, guid: 1ef3259331ddc1f4d94b628323ec45f3,
type: 3}
uiManagerPrefab: {fileID: 6955995418921915169, guid: 828553405a21e8f43af8c6d97bed99fb,
type: 3}

View File

@@ -71,6 +71,7 @@ public class PlayerComponent : NetworkBehaviour
audioListener.enabled = true;
StartCoroutine(DestroySoloComponents());
DontDestroyOnLoad(gameObject);
}
private IEnumerator DestroyMultiplayerComponents()

View File

@@ -1,5 +1,6 @@
using HurricaneVR.Framework.Core;
using HurricaneVR.Framework.Core.Player;
using HurricaneVR.Framework.Core.UI;
using HurricaneVR.Framework.Core.Utils;
using System.Collections;
using Unity.Netcode;
@@ -26,6 +27,9 @@ public class GlobalInstaller : MonoInstaller
[SerializeField]
private GameObject playerPrefab;
[SerializeField]
private GameObject uiManagerPrefab;
public override void Start()
{
base.Start();
@@ -83,5 +87,14 @@ public class GlobalInstaller : MonoInstaller
Container.BindInstance(playerComponent)
.AsSingle();
Container.Bind<HVRInputModule>()
.FromComponentInNewPrefab(uiManagerPrefab)
.AsSingle()
.OnInstantiated<HVRInputModule>((ctx, obj) =>
{
obj.name = uiManagerPrefab.name;
})
.NonLazy();
}
}

View File

@@ -0,0 +1,59 @@
using HurricaneVR.Framework.ControllerInput;
using HurricaneVR.Framework.Core.UI;
using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using Zenject;
public class HandMenuUI : MonoBehaviour
{
[Inject]
[ReadOnly]
private HVRInputModule uiInput;
[SerializeField]
private GameObject anchor;
[SerializeField]
[ReadOnly]
private float forwardOffset = 0.1f;
[SerializeField]
[ReadOnly]
private Canvas canvas;
private float smoothTime = 0.3F;
private Vector3 velocity = Vector3.zero;
private void Start()
{
canvas = GetComponent<Canvas>();
uiInput.AddCanvas(canvas);
}
private void Update()
{
UpdatePosition();
CheckInput();
}
private void UpdatePosition()
{
var rotation = Quaternion.Euler(0, anchor.transform.eulerAngles.y - 180, 0);
var targetPosition = anchor.transform.position - anchor.transform.forward * forwardOffset;
var smoothPosition = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
transform.SetPositionAndRotation(smoothPosition, rotation);
}
private void CheckInput()
{
if (HVRInputManager.Instance.LeftController.PrimaryButtonState.JustActivated)
{
canvas.enabled = !canvas.enabled;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 889a6708f6f028c4e96df3407816950a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: