forked from zxl/LaboratoryProtection
完善功能
parent
d34228cff5
commit
405954d123
|
@ -59991,11 +59991,11 @@ MonoBehaviour:
|
|||
uiObjectData:
|
||||
- uiType: 0
|
||||
ui: {fileID: 1352941224}
|
||||
- uiType: 0
|
||||
- uiType: 1
|
||||
ui: {fileID: 1448946252}
|
||||
- uiType: 0
|
||||
- uiType: 2
|
||||
ui: {fileID: 1248219822}
|
||||
- uiType: 0
|
||||
- uiType: 3
|
||||
ui: {fileID: 834112896}
|
||||
--- !u!1 &1866609136
|
||||
GameObject:
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace UnityTest.ZXL
|
|||
{
|
||||
var highlightEffect = self.GetOrAddComponent<HighlightEffect>();
|
||||
highlightEffect.highlighted = true;
|
||||
self.GetComponent<ObjectComponent>().isCanClick = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace UnityTest.ZXL
|
|||
/// </summary>
|
||||
public string desc;
|
||||
|
||||
public bool isCanClick;
|
||||
|
||||
public void Clicked()
|
||||
{
|
||||
Debug.Log($"点击了{objectName}");
|
||||
|
@ -34,6 +36,8 @@ namespace UnityTest.ZXL
|
|||
#endif
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (!isCanClick) return;
|
||||
isCanClick = false;
|
||||
Clicked();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,25 @@ using UnityEngine;
|
|||
|
||||
namespace UnityTest.ZXL
|
||||
{
|
||||
public class ObjectDataComponent : SerializedMonoBehaviour
|
||||
public class ObjectDataComponent : BaseAutoMono<ObjectDataComponent>
|
||||
{
|
||||
public List<ObjectData> objectData = new List<ObjectData>();
|
||||
|
||||
|
||||
public List<ObjectData> highlightObjectData = new List<ObjectData>();
|
||||
|
||||
public Dictionary<string, ObjectComponent> objectComponents = new Dictionary<string, ObjectComponent>();
|
||||
|
||||
public GameObject GetObject(HighlightObjectType objectType)
|
||||
{
|
||||
var key = objectType.ToString();
|
||||
if (objectComponents.TryGetValue(key, out ObjectComponent component))
|
||||
{
|
||||
return component.gameObject;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
@ -17,7 +32,7 @@ namespace UnityTest.ZXL
|
|||
public GameObject go;
|
||||
}
|
||||
|
||||
public enum HighlightObject
|
||||
public enum HighlightObjectType
|
||||
{
|
||||
乙炔气瓶开关,
|
||||
电脑屏幕,
|
||||
|
|
|
@ -14,6 +14,14 @@ namespace UnityTest.ZXL
|
|||
base.OnInit();
|
||||
playable.Stop();
|
||||
EventManager.Instance.Subscribe(TimelineEventArgs.EventId, TimelineEvent);
|
||||
EventManager.Instance.Subscribe(ClickObjectEventArgs.EventId, TimelineEvent);
|
||||
}
|
||||
|
||||
protected override void OnLevel()
|
||||
{
|
||||
base.OnLevel();
|
||||
EventManager.Instance.Unsubscribe(TimelineEventArgs.EventId, TimelineEvent);
|
||||
EventManager.Instance.Unsubscribe(ClickObjectEventArgs.EventId, TimelineEvent);
|
||||
}
|
||||
|
||||
private void TimelineEvent(object sender, GameEventArgs e)
|
||||
|
@ -30,8 +38,14 @@ namespace UnityTest.ZXL
|
|||
playable.Play();
|
||||
|
||||
yield return isNext;
|
||||
playable.Pause();
|
||||
|
||||
AnimatorManager.Instance().Get("2-1");
|
||||
// 等待点击
|
||||
ObjectDataComponent.Instance().GetObject(HighlightObjectType.乙炔气瓶开关).HighlightOpen();
|
||||
isNext = false;
|
||||
|
||||
yield return isNext;
|
||||
playable.Resume();
|
||||
}
|
||||
|
||||
// 1-2
|
||||
|
|
|
@ -11,10 +11,32 @@ namespace UnityTest.ZXL
|
|||
|
||||
public void ShowUI(UIType uiType)
|
||||
{
|
||||
foreach (var objectData in uiObjectData)
|
||||
{
|
||||
if (objectData.uiType == uiType)
|
||||
{
|
||||
objectData.ui.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HideUI(UIType uiType)
|
||||
{
|
||||
foreach (var objectData in uiObjectData)
|
||||
{
|
||||
if (objectData.uiType == uiType)
|
||||
{
|
||||
objectData.ui.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HideAllUI()
|
||||
{
|
||||
foreach (var objectData in uiObjectData)
|
||||
{
|
||||
objectData.ui.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
|
Loading…
Reference in New Issue