增加弹出提示功能

This commit is contained in:
terric 2023-11-15 01:01:48 +08:00
parent 8f6478aab5
commit 38f9b07b07
15 changed files with 451 additions and 158 deletions

66
Assets/HudUI.cs Normal file
View File

@ -0,0 +1,66 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HudUI : UIHudBase
{
private static Queue<Msg> _msgHintQueue = new Queue<Msg>();
private NotificationPopupUI _hintPannel;
private bool _isHintShowing = false;
private void Awake()
{
_hintPannel = transform.Find("PopupNotification").GetComponent<NotificationPopupUI>();
_hintPannel.GetComponent<CanvasGroup>().alpha = 0;
_msgHintQueue.Clear();
}
private void OnEnable()
{
EventManager.Instance.AddEventListener(YogaEventType.ShowHint, PushHint);
}
private void OnDisable()
{
EventManager.Instance.RemoveEventListener(YogaEventType.ShowHint, PushHint);
}
private void PushHint(object[] args)
{
var msg = new Msg();
if (args.Length < 2)
throw new Exception("²ÎÊý´íÎó");
msg.Title = args[0].ToString();
msg.Content = args[1].ToString();
_msgHintQueue.Enqueue(msg);
}
public override void Init(object[] pageData)
{
base.Init(pageData);
}
private void Update()
{
if (_msgHintQueue.Count > 0 && !_isHintShowing)
{
var msg = _msgHintQueue.Dequeue();
StartCoroutine(ShowHint(msg));
}
}
private IEnumerator ShowHint(Msg msg)
{
_isHintShowing = true;
yield return _hintPannel.Show(msg.Title, msg.Content);
_isHintShowing = false;
}
}
internal class Msg
{
public string Title { get; set; }
public string Content { get; set; }
}

11
Assets/HudUI.cs.meta Normal file
View File

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

View File

@ -0,0 +1,122 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Popup Wait
serializedVersion: 7
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Alpha
path:
classID: 225
script: {fileID: 0}
flags: 0
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 1574349066
script: {fileID: 0}
typeID: 225
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 1
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Alpha
path:
classID: 225
script: {fileID: 0}
flags: 0
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0123030b699cc2f4cadff610e9bc51f5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -90,7 +90,7 @@ AnimatorState:
m_MirrorParameterActive: 0 m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0 m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0 m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: e6f95ed20d7d0454587557ad08f762c5, type: 2} m_Motion: {fileID: 7400000, guid: 0123030b699cc2f4cadff610e9bc51f5, type: 2}
m_Tag: m_Tag:
m_SpeedParameter: m_SpeedParameter:
m_MirrorParameter: m_MirrorParameter:

View File

@ -0,0 +1,173 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &591297386902869668
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7882980980823895129}
- component: {fileID: 44101575073041383}
m_Layer: 5
m_Name: HUDRoot
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7882980980823895129
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 591297386902869668}
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:
- {fileID: 1252863757881792527}
m_Father: {fileID: 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!114 &44101575073041383
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 591297386902869668}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 685773266ab8a444e9ff5131cde3c8ae, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1332753061905480905
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 7882980980823895129}
m_Modifications:
- target: {fileID: 1350301964240770, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_Name
value: PopupNotification
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_SizeDelta.x
value: 400
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.x
value: 230
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.y
value: -100
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
--- !u!224 &1252863757881792527 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
m_PrefabInstance: {fileID: 1332753061905480905}
m_PrefabAsset: {fileID: 0}

View File

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

View File

@ -281,8 +281,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3be22eabbf04710439f8c8d016bd725c, type: 3} m_Script: {fileID: 11500000, guid: 3be22eabbf04710439f8c8d016bd725c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
Title: {fileID: 0}
Description: {fileID: 0}
--- !u!1 &1517711807492522 --- !u!1 &1517711807492522
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -459,128 +459,6 @@ MonoBehaviour:
mipBias: 0 mipBias: 0
varianceClampScale: 0.9 varianceClampScale: 0.9
contrastAdaptiveSharpening: 0 contrastAdaptiveSharpening: 0
--- !u!1001 &1076621316
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1763781738}
m_Modifications:
- target: {fileID: 1350301964240770, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_Name
value: PopupNotification
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224140982003034070, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchorMin.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_SizeDelta.x
value: 400
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.x
value: 230
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_AnchoredPosition.y
value: -100
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
--- !u!224 &1076621317 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 224602918499771590, guid: a5c1511e3af132c44b6f11542f709726, type: 3}
m_PrefabInstance: {fileID: 1076621316}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1190353382 --- !u!1 &1190353382
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1332,8 +1210,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 1
m_Children: m_Children: []
- {fileID: 1076621317}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 5, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 5, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}

View File

@ -82,4 +82,6 @@ public enum YogaEventType
ActionFailed, ActionFailed,
PlayAnimation, PlayAnimation,
UpdateProgress, UpdateProgress,
ShowHint,
ShowMessage,
} }

View File

@ -218,6 +218,8 @@ namespace Yoga
} }
AvatarAction actionType = (AvatarAction)args.FirstOrDefault(); AvatarAction actionType = (AvatarAction)args.FirstOrDefault();
UIManager.Instance.ShowHint(actionType.ToString(), "Follow the robot!");
//检测动作 //检测动作
var startTime = DateTime.Now; var startTime = DateTime.Now;

View File

@ -1,30 +1,34 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
public class NotificationPopupUI : UIPopupBase public class NotificationPopupUI : MonoBehaviour
{ {
public TMP_Text Title; private TextMeshProUGUI _title;
public TMP_Text Description; private TextMeshProUGUI _description;
private Animator _animator;
private void Awake() private void Awake()
{ {
Title = transform.Find("Title").GetComponent<TMP_Text>(); _title = transform.Find("Title").GetComponent<TextMeshProUGUI>();
Description = transform.Find("Description").GetComponent<TMP_Text>(); _description = transform.Find("Description").GetComponent<TextMeshProUGUI>();
_animator = GetComponent<Animator>();
transform.gameObject.SetActive(true);
transform.GetComponent<CanvasGroup>().alpha = 0;
} }
public override void Init(object[] pageData) public IEnumerator Show(string title, string content)
{ {
base.Init(pageData); if (!transform.gameObject.activeSelf)
//args[0] = title, args[1] = description transform.gameObject.SetActive(true);
Title.text = pageData[0].ToString(); transform.GetComponent<CanvasGroup>().alpha = 0;
Description.text = pageData[1].ToString();
}
public override void OnEnter()
{
base.OnEnter();
_title.text = title;
_description.text = content;
_animator.Play("In");
yield return new WaitForSeconds(3f);
_animator.Play("Out");
} }
} }

View File

@ -13,6 +13,7 @@ public static class UILoadConfig
{ "ActionGuideVideoPanel" , "UI/ActionGuideVideoPanel" }, { "ActionGuideVideoPanel" , "UI/ActionGuideVideoPanel" },
{ "GuideUI" , "UI/GuideUI" }, { "GuideUI" , "UI/GuideUI" },
{ "ClearingSettlementUI" , "UI/ClearingSettlementUI" }, { "ClearingSettlementUI" , "UI/ClearingSettlementUI" },
{ "HudUI" , "UI/HUDRoot" },
}; };
public static string GetPath(string typeName) public static string GetPath(string typeName)

View File

@ -6,6 +6,7 @@ using System.Linq;
using OpenCVForUnity.CoreModule; using OpenCVForUnity.CoreModule;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using Yoga; using Yoga;
using OpenCVForUnityExample;
public class UIManager : MonoSingleton<UIManager> public class UIManager : MonoSingleton<UIManager>
{ {
@ -16,10 +17,14 @@ public class UIManager : MonoSingleton<UIManager>
private RectTransform _uiPanelRoot; private RectTransform _uiPanelRoot;
private RectTransform _uiPopRoot; private RectTransform _uiPopRoot;
private RectTransform _hudRoot;
private HudUI _hud;
private Transform _uiRootTrans; private Transform _uiRootTrans;
//hud 页面
private NotificationPopupUI _hintPannel;
public override void Init() public override void Init()
{ {
//查找当前scene的摄像机 //查找当前scene的摄像机
@ -79,17 +84,21 @@ public class UIManager : MonoSingleton<UIManager>
//hud 挂载节点 //hud 挂载节点
if (transform.Find("HUDRoot") == null) if (transform.Find("HUDRoot") == null)
{ {
_hudRoot = new GameObject("HUDRoot").AddComponent<RectTransform>(); _hud = GetPanel<HudUI>();
_hudRoot.SetParent(_uiRootTrans); _hud.transform.SetParent(_uiRootTrans);
_hudRoot.anchoredPosition = Vector2.zero; var rect = _hud.transform.GetComponent<RectTransform>();
_hudRoot.anchorMin = Vector2.zero; rect.anchorMin = Vector2.zero;
_hudRoot.anchorMax = Vector2.one; rect.anchorMax = Vector2.one;
_hudRoot.offsetMin = Vector2.zero; rect.pivot = new Vector2(0.5f, 0.5f);
_hudRoot.offsetMax = Vector2.zero; rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width);
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Screen.height);
rect.offsetMin = Vector2.zero;
rect.offsetMax = Vector2.zero;
_hud.Init(null);
} }
else else
_hudRoot = transform.Find("HUDRoot").GetComponent<RectTransform>(); _hud = transform.Find("HUDRoot").GetComponent<HudUI>();
_hudRoot.SetSiblingIndex(3); _hud.transform.SetSiblingIndex(3);
} }
private T GetPanel<T>() where T : UIBase private T GetPanel<T>() where T : UIBase
@ -111,9 +120,13 @@ public class UIManager : MonoSingleton<UIManager>
else if (panel is UIPopupBase) else if (panel is UIPopupBase)
panelGo.transform.SetParent(_uiPopRoot); panelGo.transform.SetParent(_uiPopRoot);
else if (panel is UIHudBase) else if (panel is UIHudBase)
panelGo.transform.SetParent(_hudRoot); {
panelGo.transform.localPosition = Vector3.zero;
//hud页面不需要缓存
return panel as T;
}
else else
throw new Exception("UIManager.GetPanel() : panel is not a type of UIPanelBase, UIPopupBase or UIHudBase"); throw new Exception("UIManager.GetPanel() : panel is not a type of UIPanelBase, UIPopupBase");
panelGo.transform.localPosition = Vector3.zero; panelGo.transform.localPosition = Vector3.zero;
@ -227,4 +240,16 @@ public class UIManager : MonoSingleton<UIManager>
nextPanel.OnResume(); nextPanel.OnResume();
} }
} }
//hud 页面
public void ShowHint(string title, string content)
{
EventManager.Instance.Dispatch(YogaEventType.ShowHint, title, content);
}
public void ShowMsgBox(string title, string content)
{
EventManager.Instance.Dispatch(YogaEventType.ShowMessage, title, content);
}
} }

View File

@ -136,10 +136,7 @@ PlayerSettings:
vulkanEnableCommandBufferRecycling: 1 vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0 loadStoreDebugModeEnabled: 0
bundleVersion: 0.13 bundleVersion: 0.13
preloadedAssets: preloadedAssets: []
- {fileID: 11400000, guid: e909ead19248db448b564bc342b7c221, type: 2}
- {fileID: 11400000, guid: 9bb62c82f36383440a845a9a59025c6f, type: 2}
- {fileID: 2671796653090180050, guid: b1802c783fe98e94a9bd4fd13519cef8, type: 2}
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1 m_HolographicPauseOnTrackingLoss: 1