Skip to content

Commit

Permalink
09 : 문장 데이터 불러오기
Browse files Browse the repository at this point in the history
https://doublsb.tistory.com/88

- List<string>의 형태로 데이터 전달
  • Loading branch information
DoublSB committed Apr 16, 2020
1 parent 44f9a9c commit 09658d2
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 12 deletions.
19 changes: 17 additions & 2 deletions Assets/DialogAsset/Demo/Demo.unity
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\uC5B4\uB9E4"
m_Text:
--- !u!222 &109289555
CanvasRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -844,7 +844,7 @@ MonoBehaviour:
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_PressedColor: {r: 1, g: 1, b: 1, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
Expand Down Expand Up @@ -887,6 +887,7 @@ GameObject:
- component: {fileID: 1459828193}
- component: {fileID: 1459828192}
- component: {fileID: 1459828194}
- component: {fileID: 1459828196}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
Expand Down Expand Up @@ -955,6 +956,20 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1459828196
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1459828191}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: af59b715d564ae9488e8438d6860bc3b, type: 3}
m_Name:
m_EditorClassIdentifier:
DialogManager: {fileID: 470720710}
Character: {fileID: 1888300537}
--- !u!1 &1740319719
GameObject:
m_ObjectHideFlags: 0
Expand Down
4 changes: 2 additions & 2 deletions Assets/DialogAsset/Script/DialogBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public string BackText
public string PrintText;

private string _originalText;
public DialogText(string OriginalText, int size)

public DialogText(string OriginalText = "", int size = 30)
{
_originalText = OriginalText;

Expand Down
32 changes: 24 additions & 8 deletions Assets/DialogAsset/Script/DialogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,25 @@ public class DialogManager : MonoBehaviour
private float SpeakTime;
private float LastSpeakTime;
private UnityAction _callback;
private Coroutine _textingRoutine;

//================================================
//Public Method
//================================================
public void Show(List<string> Text, Character character, bool CannotSkip = false, UnityAction Callback = null)
{
Window.SetActive(true);
Initialize(null);
StartCoroutine(Texting(Text, character, CannotSkip, Callback));
}

public void Show(string Text, Character character, bool CannotSkip = false, UnityAction Callback = null)
{
_callback = Callback;

Window.SetActive(true);
Initialize(null);
StartCoroutine(Texting(Text, character, CannotSkip));
_textingRoutine = StartCoroutine(Texting(Text, character, CannotSkip));
}

public void Click_Window()
Expand All @@ -58,20 +66,16 @@ public void Click_Window()

public void Hide()
{
StopAllCoroutines();
StopCoroutine(_textingRoutine);
Window.SetActive(false);

if(_callback != null) _callback.Invoke();
if (_callback != null) _callback.Invoke();
else state = State.Hide;
}

//================================================
//Private Method
//================================================
private void Start()
{
Show("/emote:Sad/흠... /wait:0.5//emote:Normal/재미있군.", character);
}

private void Initialize(Image image)
{
SpeakTime = 0.1f;
Expand All @@ -88,6 +92,18 @@ private void Initialize(Image image)

#region Show Text

private IEnumerator Texting(List<string> Text, Character character, bool CannotSkip = false, UnityAction Callback = null)
{
foreach (var item in Text)
{
Show(item, character, CannotSkip);

while (state != State.Hide) { yield return null; }
}

Callback.Invoke();
}

private IEnumerator Texting(string Text, Character character, bool CannotSkip = false)
{
LastSpeakTime = 0.1f;
Expand Down
24 changes: 24 additions & 0 deletions Assets/DialogAsset/Script/TestMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Doublsb.Dialog;

public class TestMessage : MonoBehaviour
{
public DialogManager DialogManager;
public Character Character;

private void Awake()
{
var dialogTexts = new List<string>();

dialogTexts.Add("/size:up/안녕. /size:down/내 이름은 /color:red/리/color:white/이다.");
dialogTexts.Add("나는 랩을 할 수 있지. /speed:0.02/속사포랩이나가신다나는아무튼트랩을하고있다 /speed:0.1/Ya /wait:0.1/ Ya.");
dialogTexts.Add("봤나? 내 솜씨는 정말이지, 아주 아름답/close/다고 할 수 있다.");
dialogTexts.Add("/emote:Sad/내 말. 자르지 말아줄래.");
dialogTexts.Add("/emote:Normal/니가 누르기 전까지 말하지 않을 것이다. /click//emote:Happy/옳지.");
dialogTexts.Add("아주 고오오오오맙다.");

DialogManager.Show(dialogTexts, Character);
}
}
11 changes: 11 additions & 0 deletions Assets/DialogAsset/Script/TestMessage.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 09658d2

Please sign in to comment.