added speaker icon support to message system, refactored related classes

This commit is contained in:
Данил Ярош 2025-12-11 17:05:24 +03:00
parent 6b4d1d8923
commit dafd317242
11 changed files with 635 additions and 1611 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -19,7 +19,7 @@ GameObject:
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_StaticEditorFlags: 2147483647
m_IsActive: 1
--- !u!224 &5386693198774451858
RectTransform:
@ -28,9 +28,9 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 230978959095769727}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
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_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
@ -49,7 +49,7 @@ Canvas:
m_GameObject: {fileID: 230978959095769727}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 2
m_RenderMode: 1
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
@ -85,7 +85,7 @@ MonoBehaviour:
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 1
m_PresetInfoIsWorld: 0
--- !u!114 &3904946843679158469
MonoBehaviour:
m_ObjectHideFlags: 0
@ -116,16 +116,16 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.GridLayoutGroup
m_Padding:
m_Left: 0
m_Left: 30
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 7
m_StartCorner: 0
m_StartAxis: 1
m_CellSize: {x: 2, y: 1}
m_Spacing: {x: 0, y: 0.05}
m_Constraint: 1
m_Bottom: 50
m_ChildAlignment: 6
m_StartCorner: 3
m_StartAxis: 0
m_CellSize: {x: 600, y: 200}
m_Spacing: {x: 25, y: 0}
m_Constraint: 2
m_ConstraintCount: 1
--- !u!114 &956586932604822154
MonoBehaviour:

View File

@ -1,5 +1,117 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &260616728848365051
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7204825194549240432}
m_Layer: 5
m_Name: Icon Bubble
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7204825194549240432
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 260616728848365051}
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: 1810435659140100882}
- {fileID: 3022874467997197475}
m_Father: {fileID: 2735431105283990082}
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: -200, y: 0}
m_SizeDelta: {x: 200, y: 200}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1853645629924273664
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1810435659140100882}
- component: {fileID: 2131016761528680104}
- component: {fileID: 6883091002347481165}
m_Layer: 5
m_Name: Backround
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1810435659140100882
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1853645629924273664}
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: 7204825194549240432}
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!222 &2131016761528680104
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1853645629924273664}
m_CullTransparentMesh: 1
--- !u!114 &6883091002347481165
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1853645629924273664}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
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_Sprite: {fileID: -8111322212487550922, guid: 31b2877e77610584cac3a41c46e85320, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 0.01
--- !u!1 &4011995222962286647
GameObject:
m_ObjectHideFlags: 0
@ -29,6 +141,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7204825194549240432}
- {fileID: 3400129395157306382}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -49,37 +162,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: fe746195c25446c69428c4a4ae730170, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Behaviour.Message
actions:
- rid: 1880696163501342721
- rid: 1880696163501342722
- rid: 1880696163501342723
- rid: 1880696163501342724
actions: []
messageText: {fileID: 5534531474294439652}
bubbleRectTransform: {fileID: 3400129395157306382}
speakerIconImage: {fileID: 403176025496737113}
maxWidth: 0
references:
version: 2
RefIds:
- rid: 1880696163501342721
type: {class: MessageAppearAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
startScale: 0
endScale: 1
transitionSpeed: 10
- rid: 1880696163501342722
type: {class: WaitAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
duration: 1
- rid: 1880696163501342723
type: {class: MessageDisappearAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
startScale: 1
endScale: 0
transitionSpeed: 10
- rid: 1880696163501342724
type: {class: DeleteGameObjectAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
targetObject: {fileID: 4011995222962286647}
RefIds: []
--- !u!1 &7064759615442894017
GameObject:
m_ObjectHideFlags: 0
@ -113,10 +203,10 @@ RectTransform:
- {fileID: 4110742772746779756}
m_Father: {fileID: 2735431105283990082}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1, y: -0.5}
m_SizeDelta: {x: 2, y: 1}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 110, y: 0}
m_SizeDelta: {x: -220, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3318325516404832205
CanvasRenderer:
@ -142,13 +232,88 @@ MonoBehaviour:
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: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: -8111322212487550922, guid: 31b2877e77610584cac3a41c46e85320, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 0.01
--- !u!1 &7863304254649402940
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3022874467997197475}
- component: {fileID: 8958763011092971822}
- component: {fileID: 403176025496737113}
m_Layer: 5
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3022874467997197475
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863304254649402940}
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: 7204825194549240432}
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: -20, y: -20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8958763011092971822
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863304254649402940}
m_CullTransparentMesh: 1
--- !u!114 &403176025496737113
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7863304254649402940}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
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_Sprite: {fileID: -5177388603050735206, guid: 8884154dfe85442a3a3578be807dbcdf, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_Sprite: {fileID: -3550973283731103874, guid: 4db2fbc7e829aec46b75cceb207881b9, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
@ -191,7 +356,7 @@ RectTransform:
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_SizeDelta: {x: -20, y: -20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8816387387326177619
CanvasRenderer:
@ -248,12 +413,12 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 0.75
m_fontSize: 0.01
m_fontSizeBase: 0.5
m_fontWeight: 400
m_enableAutoSizing: 1
m_fontSizeMin: 0.01
m_fontSizeMax: 1
m_fontSizeMax: 100
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

View File

@ -0,0 +1,169 @@
fileFormatVersion: 2
guid: 8526ea9be1b0a56429731ec9f3edf875
TextureImporter:
internalIDToNameTable:
- first:
213: 420805981189327916
second: Player_Head_0
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: Player_Head_0
rect:
serializedVersion: 2
x: 206
y: 481
width: 541
height: 410
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
physicsShape: []
tessellationDetail: -1
bones: []
spriteID: c2c46247fc007d500800000000000000
internalID: 420805981189327916
vertices: []
indices:
edges: []
weights: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable:
Player_Head_0: 420805981189327916
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -442,6 +442,39 @@ SpriteRenderer:
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_SpriteSortPoint: 0
--- !u!1 &132110343
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 132110344}
m_Layer: 0
m_Name: Dialogues
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &132110344
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 132110343}
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:
- {fileID: 767070203}
- {fileID: 1794833573}
m_Father: {fileID: 1251775005}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &136585477
GameObject:
m_ObjectHideFlags: 0
@ -1866,7 +1899,7 @@ RectTransform:
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: -5.5, y: 8}
m_AnchoredPosition: {x: -130.5, y: -29.5}
m_SizeDelta: {x: 4, y: 2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &285988405
@ -3589,7 +3622,7 @@ RectTransform:
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: -5.5, y: 16}
m_AnchoredPosition: {x: -130.5, y: -21.5}
m_SizeDelta: {x: 4, y: 2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &597019435
@ -5006,13 +5039,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 767070202}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 7, y: -1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1359207619}
m_Father: {fileID: 1251775005}
m_Father: {fileID: 132110344}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &767070204
MonoBehaviour:
@ -5043,7 +5076,6 @@ MonoBehaviour:
isOneTime: 0
messagePlaceholderPrefab: {fileID: 230978959095769727, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
messageBubblePrefab: {fileID: 4011995222962286647, guid: 969225a5614fedf41878291f57bdeb88, type: 3}
defaultMessageOffset: {x: 0, y: 0.5, z: 0}
references:
version: 2
RefIds:
@ -5051,58 +5083,52 @@ MonoBehaviour:
type: {class: AddMessageAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
text: "\u041F\u0440\u0438\u0432\u0435\u0442!"
target: {fileID: 1359207618}
offset: {x: 0, y: 1, z: 0}
speakerIcon: {fileID: -3550973283731103874, guid: 4db2fbc7e829aec46b75cceb207881b9, type: 3}
- rid: 1880696163501342821
type: {class: WaitAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
duration: 0.5
duration: 3
- rid: 1880696163501342822
type: {class: AddMessageAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
text: "\u0422\u044B \u0442\u0443\u0442 \u043D\u043E\u0432\u0435\u043D\u044C\u043A\u0430\u044F?"
target: {fileID: 1359207618}
offset: {x: 0, y: 1, z: 0}
speakerIcon: {fileID: -3550973283731103874, guid: 4db2fbc7e829aec46b75cceb207881b9, type: 3}
- rid: 1880696163501342843
type: {class: WaitAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
duration: 0.5
duration: 3.5
- rid: 1880696163501342845
type: {class: AddMessageAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
text: "\u0421\u0435\u0439\u0447\u0430\u0441 \u0442\u0435\u0431\u044F \u0431\u0443\u0434\u0443\u0442\u044C
\u0443\u0447\u0438\u0442\u044C \u043A\u0438\u0434\u0430\u0442\u044C\u0441\u044F
\u0422\u0430\u043C\u0430\u0433\u043E\u0447\u0438\u043A\u043E\u043C!"
target: {fileID: 1359207618}
offset: {x: 0, y: 1, z: 0}
speakerIcon: {fileID: -3550973283731103874, guid: 4db2fbc7e829aec46b75cceb207881b9, type: 3}
- rid: 1880696163501342856
type: {class: AddMessageAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
text: "\u041F\u0440\u0438\u0432\u0435\u0442. \u043C\u0435\u043D\u044F \u0437\u043E\u0432\u0443\u0442
\u0410\u043B\u0438\u0441\u0430!"
target: {fileID: 0}
offset: {x: 0, y: 0, z: 0}
speakerIcon: {fileID: 420805981189327916, guid: 8526ea9be1b0a56429731ec9f3edf875, type: 3}
- rid: 1880696163501342872
type: {class: AddMessageAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
text: "\u041D\u0430\u0443\u0447\u0438\u0442\u0435 \u043C\u0435\u043D\u044F!"
target: {fileID: 0}
offset: {x: 0, y: 0, z: 0}
speakerIcon: {fileID: 420805981189327916, guid: 8526ea9be1b0a56429731ec9f3edf875, type: 3}
- rid: 1880696163501342873
type: {class: WaitAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
duration: 0.5
duration: 3.5
- rid: 1880696163501342874
type: {class: AddMessageAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
text: "\u041F\u0440\u043E\u0441\u0442\u043E \u043D\u0430\u0436\u043C\u0438
\"Ctrl\"!"
target: {fileID: 1359207618}
offset: {x: 0, y: 1, z: 0}
speakerIcon: {fileID: -3550973283731103874, guid: 4db2fbc7e829aec46b75cceb207881b9, type: 3}
- rid: 1880696163501342880
type: {class: WaitAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
duration: 1
duration: 3.5
- rid: 1880696163501343007
type: {class: FreezePlayerAction, ns: RR.Common.Behaviour, asm: Assembly-CSharp}
data:
@ -7891,7 +7917,7 @@ Transform:
- {fileID: 1202651711}
- {fileID: 522916305}
- {fileID: 1747659608}
- {fileID: 767070203}
- {fileID: 132110344}
m_Father: {fileID: 136585478}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1270592417
@ -9684,7 +9710,7 @@ RectTransform:
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: -5.5, y: 0}
m_AnchoredPosition: {x: -130.5, y: -37.5}
m_SizeDelta: {x: 4, y: 2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1662115355
@ -10204,6 +10230,132 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5e2f7649694807646a991b80b725b2e5, type: 3}
--- !u!1001 &1794833572
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 132110344}
m_Modifications:
- target: {fileID: 230978959095769727, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_Name
value: Message Placeholder
objectReference: {fileID: 0}
- target: {fileID: 4766314645341967760, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4766314645341967760, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4766314645341967760, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4766314645341967760, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4766314645341967760, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4766314645341967760, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
--- !u!224 &1794833573 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 5386693198774451858, guid: 0f453bdec7ad567458080bacb277b1c0, type: 3}
m_PrefabInstance: {fileID: 1794833572}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1826143540
PrefabInstance:
m_ObjectHideFlags: 0
@ -10443,8 +10595,8 @@ RectTransform:
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: 320, y: 320}
m_AnchoredPosition: {x: 250, y: 75}
m_SizeDelta: {x: 320, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1911231109
MonoBehaviour:

View File

@ -1,4 +1,5 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
namespace RR.Common.Behaviour
@ -7,29 +8,39 @@ namespace RR.Common.Behaviour
{
[SerializeField] private TextMeshProUGUI messageText;
[SerializeField] private RectTransform bubbleRectTransform;
[SerializeField] private Image speakerIconImage;
[SerializeField] private int maxWidth;
private string _text;
private Sprite _speakerIcon;
public void Initialize(string text)
/// <summary>
/// Инициализирует сообщение с текстом и иконкой говорящего.
/// </summary>
/// <param name="text">Текст сообщения</param>
/// <param name="speakerIcon">Иконка (спрайт) говорящего персонажа</param>
public void Initialize(string text, Sprite speakerIcon = null)
{
_text = text;
_speakerIcon = speakerIcon;
if (_text != null)
{
float width = Mathf.Ceil(_text.Length * 1.2f / 5f);
if (maxWidth > 0 && width > maxWidth)
messageText.text = _text;
}
// Устанавливаем иконку говорящего, если она передана
if (speakerIconImage)
{
if (_speakerIcon)
{
width = maxWidth;
messageText.textWrappingMode = TextWrappingModes.Normal;
speakerIconImage.sprite = _speakerIcon;
speakerIconImage.gameObject.SetActive(true);
}
else
{
messageText.textWrappingMode = TextWrappingModes.NoWrap;
speakerIconImage.gameObject.SetActive(false);
}
bubbleRectTransform.sizeDelta = new Vector2(width, bubbleRectTransform.sizeDelta.y);
messageText.text = _text;
}
if (actions.Count == 0)
@ -60,6 +71,10 @@ namespace RR.Common.Behaviour
endScale = 0f,
transitionSpeed = 3f
});
actions.Add(new DeleteGameObjectAction()
{
targetObject = gameObject
});
}
}
}

View File

@ -1,4 +1,3 @@
using System.Collections;
using UnityEngine;
namespace RR.Common.Behaviour
@ -12,10 +11,8 @@ namespace RR.Common.Behaviour
[SerializeField] private GameObject messagePlaceholderPrefab;
[SerializeField] private GameObject messageBubblePrefab;
[Header("Смещение сообщения")]
[SerializeField] private Vector3 defaultMessageOffset = new(0, 0.5f, 0);
private bool _isTriggered;
private Transform _placeholder;
private void OnTriggerEnter2D(Collider2D other)
{
@ -26,53 +23,45 @@ namespace RR.Common.Behaviour
if (isOneTime) _isTriggered = true;
}
public void Add(GameObject targetObject, string text, Vector3 customOffset = default)
/// <summary>
/// Получает или создает единственный Message Placeholder на сцене.
/// Placeholder становится дочерним объектом родителя MessageController.
/// </summary>
private Transform GetOrCreatePlaceholder()
{
if (_placeholder != null) return _placeholder;
// Ищем объект "Message Placeholder" среди дочерних объектов
Transform placeholder = targetObject.transform.Find("Message Placeholder");
// Если placeholder не найден, создаем его
if (!placeholder)
// Ищем существующий placeholder среди дочерних объектов родителя
Transform parentTransform = transform.parent ? transform.parent : transform;
_placeholder = parentTransform.Find("Message Placeholder");
if (_placeholder == null)
{
GameObject placeholderInstance = Instantiate(messagePlaceholderPrefab, targetObject.transform);
Vector3 offset;
if (customOffset != default)
offset = customOffset;
else
offset = defaultMessageOffset;
if (targetObject.transform.localScale != Vector3.one)
placeholderInstance.transform.localScale = Vector3.one / targetObject.transform.localScale.x;
// Создаем новый placeholder как дочерний объект родителя MessageController
GameObject placeholderInstance = Instantiate(messagePlaceholderPrefab, parentTransform);
placeholderInstance.name = "Message Placeholder";
// Вычисляем смещение с учетом размера коллайдера объекта
Collider2D targetCollider = targetObject.GetComponent<Collider2D>();
if (targetCollider)
// Если на объекте есть коллайдер, учитываем его высоту
offset = new Vector3(
offset.x,
targetCollider.bounds.size.y + offset.y,
offset.z
);
// Устанавливаем позицию placeholder с учетом смещения
placeholderInstance.transform.position = targetObject.transform.position + offset;
// Сохраняем ссылку на трансформ placeholder
placeholder = placeholderInstance.transform;
_placeholder = placeholderInstance.transform;
}
return _placeholder;
}
/// <summary>
/// Добавляет сообщение с иконкой говорящего.
/// </summary>
/// <param name="speakerIcon">Иконка (спрайт) говорящего персонажа</param>
/// <param name="text">Текст сообщения</param>
public void Add(Sprite speakerIcon, string text)
{
Transform placeholder = GetOrCreatePlaceholder();
// Создаем Message и добавляем его в placeholder
GameObject messageInstance = Instantiate(messageBubblePrefab, placeholder);
Message message = messageInstance.GetComponent<Message>();
if (message)
{
message.Initialize(text);
message.Initialize(text, speakerIcon);
}
}
}

View File

@ -7,13 +7,6 @@ namespace RR.Common.Behaviour
private void Update()
{
transform.rotation = Quaternion.identity;
if (transform.parent.localScale != Vector3.one)
{
transform.localScale = Vector3.one / transform.parent.localScale.x;
}
// Используем childCount вместо GetComponentsInChildren — намного быстрее
if (transform.childCount == 0)
{

View File

@ -5,21 +5,19 @@ using UnityEngine;
namespace RR.Common.Behaviour
{
/// <summary>
/// Действие добавления сообщения
/// Действие добавления сообщения с иконкой говорящего.
/// </summary>
[Serializable]
public class AddMessageAction : SequenceAction
{
[SerializeField] public string text;
[SerializeField] public GameObject target;
[SerializeField] public Vector3 offset;
[SerializeField] public Sprite speakerIcon;
public override IEnumerator Execute(Sequencer context, GameObject targetGO)
{
if (context is MessageController messageController)
{
GameObject actualTarget = target ? target : targetGO;
messageController.Add(actualTarget, text, offset);
messageController.Add(speakerIcon, text);
}
yield return null;
}