增加了messagebox显示的命令和功能,另外为对话暂停做了一些事件准备

This commit is contained in:
2024-08-25 17:08:53 +08:00
parent 768064fb6f
commit a2bc181a11
7 changed files with 385 additions and 17 deletions
@@ -3572,6 +3572,96 @@ Transform:
m_Children: []
m_Father: {fileID: 1434691330}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &322688756
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 322688757}
- component: {fileID: 322688759}
- component: {fileID: 322688758}
- component: {fileID: 322688760}
m_Layer: 5
m_Name: MessageBox
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &322688757
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322688756}
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: 770829336}
m_Father: {fileID: 1141076862}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 6.46, y: 1.23}
m_SizeDelta: {x: 4, y: 1}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &322688758
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322688756}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 0.55154467, b: 0, a: 0}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &322688759
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322688756}
m_CullTransparentMesh: 1
--- !u!114 &322688760
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 322688756}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b8075ce97e8dbfd48b3f4b3ac09b1ded, type: 3}
m_Name:
m_EditorClassIdentifier:
messageText: {fileID: 770829337}
--- !u!1 &325563563
GameObject:
m_ObjectHideFlags: 0
@@ -6798,7 +6888,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -2.7600098, y: -0.65}
m_AnchoredPosition: {x: -1.54, y: -1.81}
m_SizeDelta: {x: 4.49, y: 5.582}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &687630260
@@ -7200,6 +7290,140 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 738287074}
m_CullTransparentMesh: 1
--- !u!1 &770829335
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 770829336}
- component: {fileID: 770829338}
- component: {fileID: 770829337}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &770829336
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 770829335}
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: 322688757}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.36, y: 0.26}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &770829337
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 770829335}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 0.25
m_fontSizeBase: 0.25
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &770829338
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 770829335}
m_CullTransparentMesh: 1
--- !u!1 &783911286
GameObject:
m_ObjectHideFlags: 0
@@ -9845,12 +10069,13 @@ RectTransform:
- {fileID: 490939724}
- {fileID: 1770562627}
- {fileID: 1838403776}
- {fileID: 322688757}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 16, y: 9}
m_SizeDelta: {x: 18.019, y: 10.0375}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1141896085
GameObject:
@@ -10986,6 +11211,10 @@ PrefabInstance:
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: -7730622810778493264, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_LocalPosition.y
value: 7.45
objectReference: {fileID: 0}
- target: {fileID: -7663647160766384332, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_IsActive
value: 0
@@ -11086,10 +11315,26 @@ PrefabInstance:
propertyPath: m_SortingLayerID
value: 1607245853
objectReference: {fileID: 0}
- target: {fileID: -1163256127662291836, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_LocalPosition.x
value: 7.2
objectReference: {fileID: 0}
- target: {fileID: -1163256127662291836, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_LocalPosition.y
value: 3.38
objectReference: {fileID: 0}
- target: {fileID: 449361851162706709, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1413787943111285250, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1413787943111285250, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_SortingOrder
value: 14
objectReference: {fileID: 0}
- target: {fileID: 1645952258796297141, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_IsActive
value: 0
@@ -11114,6 +11359,10 @@ PrefabInstance:
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2803954246097182257, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4013501807958012848, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_SortingLayer
value: 4
@@ -1,10 +1,10 @@
// title: Start
// title: Start
// tags:
// position: 48,-412
// ---
title: Start
tags:
position: 58,-1212
position: 55,-1208
---
//<<CharacterInit>>
@@ -13,21 +13,23 @@ position: 58,-1212
title: TV
position: 63,-958
---
<<switch_tv 黑屏>>
电视: 新闻1内容
<<switch_tv 新闻>>
电视: 新闻2内容
<<switch_tv 销售冠军>>
电视: 新闻3内容
我: 销售大赛…给机器人销售罐头?为什么呢……
// <<switch_tv 黑屏>>
// 电视: 新闻1内容
// <<switch_tv 新闻>>
// 电视: 新闻2内容
// <<switch_tv 销售冠军>>
// 电视: 新闻3内容
// 我: 销售大赛…给机器人销售罐头?为什么呢……
<<declare $EyeMemory = false>>
///表示UF模块在当前维修阶段是否已经进入过了
<<declare $EyeUF = false>>
//<<jump LineTest>>
<<indoor>>
<<load_scene 佩佩视觉模块>>
<<jump Test2>>
<<jump OutDoorTalk>>
===
title: LineTest
title: Test
position: 537,-1196
---
<<indoor>>
@@ -44,6 +46,25 @@ position: 537,-1196
我::这个剪不断噢
<<jump LineTest>>
===
title: Test2
position: 537,-1196
---
[command name=activate_socket_choice /]
[options /]
-> UFView
<<messagebox MessageBox "warning" "UFModule has error">>
我::插入UFview
<<jump Test2>>
-> EyeView
<<messagebox MessageBox "warning" "EyeModule has error">>
我::插入Eyeview
<<jump Test2>>
-> MemoryView
<<messagebox MessageBox "normal" "MemoryModule is normal">>
我::插入Memoryview
<<jump Test2>>
===
title: OutDoorTalk
position: 72,-688
@@ -265,7 +286,7 @@ position: 361,-243
===
title: UFtest
position: -324,10
position: -324,9
---
///确保是在主视角下进行UF模块的操作
<<start_transition ViewManager "MainView">>
@@ -14,12 +14,17 @@ namespace AibisDream
private Dictionary<string, Action<YarnOption[]>> commandMap = new();
public static event Action OnDialogueStart;
public static event Action OnDialogueComplete;
public bool quickRunMode;
private void Start()
{
dialogueRunner = GetComponentInChildren<DialogueRunner>();
_variableStorage = GetComponentInChildren<InMemoryVariableStorage>();
dialogueRunner.onDialogueStart.AddListener(() => OnDialogueStart?.Invoke());
dialogueRunner.onDialogueComplete.AddListener(() => OnDialogueComplete?.Invoke());
}
#region
+35 -3
View File
@@ -4,6 +4,7 @@ using UnityEngine.EventSystems;
using UnityEngine.UI;
using System.Linq;
using DG.Tweening;
using AibisDream;
public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUpHandler
{
@@ -16,6 +17,7 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
private Quaternion pickupRotationOffset = Quaternion.Euler(0, 0, 30);
public Socket initialSocket; // new variable
public Image plugSprite; // new variable
public bool IsInDialogue { get; set; } = false;
private void Awake()
{
@@ -27,16 +29,38 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
startPosition = initialSocket.GetPosition();
transform.position = startPosition;
//startRotation = initialSocket.GetRotation();
// Insert the plug into the initial socket and make the sprite disappear.
initialSocket.InsertPlug(this);
plugSprite.enabled = false;
DialogController.OnDialogueStart += HandleDialogueStart;
DialogController.OnDialogueComplete += HandleDialogueComplete;
}
void OnDestroy()
{
// Unsubscribe from dialogue events
DialogController.OnDialogueStart -= HandleDialogueStart;
DialogController.OnDialogueComplete -= HandleDialogueComplete;
}
void HandleDialogueStart()
{
// Dialogue has started, disable plug interactions
IsInDialogue = true;
Debug.Log("in dialogue");
}
void HandleDialogueComplete()
{
// Dialogue has completed, enable plug interactions
IsInDialogue = false;
Debug.Log("dialoguecompleted");
}
public void OnPointerDown(PointerEventData eventData)
{
if (IsInDialogue)
{
return;
}
isDragging = true;
image.raycastTarget = false;
currentSocket?.RemovePlug(this);
@@ -49,6 +73,10 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
public void OnDrag(PointerEventData eventData)
{
if (IsInDialogue)
{
return;
}
if (isDragging)
{
Vector3 screenPosition = new Vector3(eventData.position.x, eventData.position.y,
@@ -61,6 +89,10 @@ public class Plug : MonoBehaviour, IDragHandler, IPointerDownHandler, IPointerUp
public void OnPointerUp(PointerEventData eventData)
{
if (IsInDialogue)
{
return;
}
isDragging = false;
image.raycastTarget = true;
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 96c710ec3df0efb4da61a5dc0401c01b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Yarn.Unity;
public class MessageBox : MonoBehaviour
{
public TMP_Text messageText; // Unity UI Text component
public void SetWarning(string message)
{
messageText.color = Color.red; // Set text color to red for warnings
messageText.text = message;
}
public void SetNormal(string message)
{
messageText.color = Color.black; // Set text color to black for normal messages
messageText.text = message;
}
[YarnCommand("messagebox")]
public void HandleMessageBoxCommand(string type,string text)
{
// 根据消息类型调用相应的方法
if (type == "warning")
{
SetWarning(text);
}
else if (type == "normal")
{
SetNormal(text);
}
else
{
Debug.LogError("Invalid message type for messagebox command: " + type);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b8075ce97e8dbfd48b3f4b3ac09b1ded
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: