[Feat] 일상생활 튜토리얼 구현중

This commit is contained in:
HaeinLEE 2025-04-30 13:52:58 +09:00
parent b5a39714f0
commit 8edeab89c4
22 changed files with 329 additions and 2 deletions

13
.idea/.idea.Degulleo3DTutorials/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,13 @@
# 디폴트 무시된 파일
/shelf/
/workspace.xml
# Rider에서 무시된 파일
/.idea.Degulleo3DTutorials.iml
/projectSettingsUpdater.xml
/contentModel.xml
/modules.xml
# 에디터 기반 HTTP 클라이언트 요청
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

BIN
Assets/LIN/Housing Copy.unity (Stored with Git LFS)

Binary file not shown.

BIN
Assets/LIN/Prefabs/JoystickPanel.prefab (Stored with Git LFS) Normal file

Binary file not shown.

View File

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

BIN
Assets/LIN/Prefabs/Player.prefab (Stored with Git LFS) Normal file

Binary file not shown.

View File

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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 18265c81aaa1344439d5501a08b7a633
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b22d834cf5e26e647be215074940d40e, type: 3}
m_Name: FirstTutorialStep
m_EditorClassIdentifier:
message: Let's begin tutorial. First, touch next button.
onBegin:
m_PersistentCalls:
m_Calls: []
onComplete:
m_PersistentCalls:
m_Calls: []
timeout: 0
requiredKey: 0
touchTargetIndex: 0
nextStep: {fileID: 11400000, guid: 83b9fc17fee6d884fb0c4ea5fc25e175, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a7cedb06e57fff540a2335f42ac38e2c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b22d834cf5e26e647be215074940d40e, type: 3}
m_Name: SecondTutorialStep
m_EditorClassIdentifier:
message: Well done, now then touch the button which has round shape
onBegin:
m_PersistentCalls:
m_Calls: []
onComplete:
m_PersistentCalls:
m_Calls: []
timeout: 0
requiredKey: 0
touchTargetIndex: 1
nextStep: {fileID: 0}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 83b9fc17fee6d884fb0c4ea5fc25e175
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4153e2ad34614334a86d1fc810eaed5e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b22d834cf5e26e647be215074940d40e, type: 3}
m_Name: FirstTutorialStep
m_EditorClassIdentifier:
message:
onBegin:
m_PersistentCalls:
m_Calls: []
onComplete:
m_PersistentCalls:
m_Calls: []
timeout: 0
requiredKey: 0
touchTargetIndex: 0
nextStep: {fileID: 0}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 80e7d98a23eacbb4eab74b9a479a04e2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,112 @@
using System;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
using System.Collections;
public class TutorialManager : MonoBehaviour
{
[SerializeField] private TutorialStep firstStep;
[SerializeField] private CanvasGroup overlay; // 입력 차단 & 다크닝용
[SerializeField] private TMP_Text tutorialText;
[SerializeField] private Canvas overlayCanvas; // RectTransformUtility를 위한 Canvas
// [SerializeField] private GameObject housingUICanvas; //튜토리얼 동안 입력 제한
[Header("튜토리얼 터치 타겟들")]
[SerializeField] private GameObject[] touchTargets;
[Header("터치 타겟에 맞춰 감춰놓을 게임 오브젝트")]
[SerializeField] private GameObject[] lockTargets;
private Coroutine _runningCoroutine;
private RectTransform targetRt;
public void Start()
{
StartTutorial();
}
public void StartTutorial()
{
overlay.alpha = 1f;
overlay.blocksRaycasts = true;
RunStep(firstStep);
}
private void RunStep(TutorialStep step)
{
if (_runningCoroutine != null) StopCoroutine(_runningCoroutine);
_runningCoroutine = StartCoroutine(RunStepCoroutine(step));
}
private IEnumerator RunStepCoroutine(TutorialStep step)
{
// 단계 시작 이벤트
step.onBegin?.Invoke();
// 메시지 갱신
tutorialText.text = step.message;
float elapsed = 0f;
bool done = false;
//터치해야 할 위치가 있는지 체크
if (step.touchTargetIndex >= 0)
{
targetRt = touchTargets[step.touchTargetIndex].GetComponent<RectTransform>();
lockTargets[step.touchTargetIndex].SetActive(false);
}
while (!done)
{
// 1) 영역 터치 체크
if (targetRt != null)
{
// 클릭 또는 터치 이벤트
bool pressed = Input.GetMouseButtonDown(0) || Input.touchCount > 0;
if (pressed)
{
Vector2 screenPos = Input.touchCount > 0
? Input.GetTouch(0).position
: (Vector2)Input.mousePosition;
// 터치 위치가 지정 RectTransform 안에 있는지 검사
if (RectTransformUtility.RectangleContainsScreenPoint(
targetRt, screenPos, overlayCanvas.worldCamera))
{
yield return new WaitForSeconds(1f);
// done = true;
// Debug.Log("영역 터치");
}
}
}
// 타임아웃 체크
if (step.timeout > 0f && elapsed >= step.timeout)
done = true;
// 키 입력 체크
if (step.requiredKey != KeyCode.None && Input.GetKeyDown(step.requiredKey))
done = true;
elapsed += Time.deltaTime;
yield return null;
}
// 단계 완료 이벤트
step.onComplete?.Invoke();
// 다음 단계로
if (step.nextStep != null)
RunStep(step.nextStep);
else
EndTutorial();
}
private void EndTutorial()
{
tutorialText.text = "";
overlay.alpha = 0f;
overlay.blocksRaycasts = false;
}
}

View File

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

View File

@ -0,0 +1,21 @@
using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(fileName = "TutorialStep", menuName = "Tutorial/Tutorial Step")]
public class TutorialStep : ScriptableObject
{
[TextArea(2, 5)]
public string message; // 플레이어에게 보여줄 텍스트
public UnityEvent onBegin; // 단계 시작 시 추가로 실행할 이벤트
public UnityEvent onComplete; // 단계 완료 시 실행할 이벤트
public float timeout = 0f; // 0 이상이면 이 시간 경과 후 자동 완료
public KeyCode requiredKey = KeyCode.None; // 지정 Key 입력 시 완료
[Tooltip("터치해야 할 위치가 있다면, 게임매니저에게 인덱스 전달")]
public int touchTargetIndex=-1;
[Tooltip("다음 단계로 넘어갈 TutorialStep, null이면 튜토리얼 종료")]
public TutorialStep nextStep;
}

View File

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

BIN
Assets/LIN/Tutorial Test.unity (Stored with Git LFS) Normal file

Binary file not shown.

View File

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