[Style] 폴더 정리
This commit is contained in:
parent
39a726b172
commit
f991e82fa9
@ -1,25 +0,0 @@
|
||||
%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}
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7cedb06e57fff540a2335f42ac38e2c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,25 +0,0 @@
|
||||
%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}
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83b9fc17fee6d884fb0c4ea5fc25e175
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -3,35 +3,50 @@ using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.Events;
|
||||
|
||||
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; //튜토리얼 동안 입력 제한
|
||||
[SerializeField] private TutorialStep firstStep; // 인스펙터에서 첫 단계 드래그
|
||||
|
||||
[Header("튜토리얼 패널 생성")]
|
||||
[SerializeField] private GameObject[] tutorialPanelPrefabs;
|
||||
|
||||
private GameObject _tutorialPanelObject;
|
||||
private TutorialPanelController _tutorialPanelController;
|
||||
|
||||
[Header("튜토리얼 터치 타겟들")]
|
||||
[SerializeField] private GameObject[] touchTargets;
|
||||
|
||||
[Header("감춰놓을 게임 오브젝트")]
|
||||
[SerializeField] private GameObject[] lockTargets;
|
||||
|
||||
private Coroutine _runningCoroutine;
|
||||
private CanvasGroup overlay; // 화면 암전 및 입력 차단
|
||||
private RectTransform targetRt;
|
||||
|
||||
public void Start()
|
||||
private Canvas overlayCanvas; // RectTransformUtility를 위한 Canvas
|
||||
private Action onTutorialComplete;
|
||||
|
||||
public void Start( )
|
||||
{
|
||||
StartTutorial();
|
||||
StartTutorial(null);
|
||||
}
|
||||
public void StartTutorial(Action onTutorialEnd, int panelIndex = 0)
|
||||
{
|
||||
var parentObject = FindObjectOfType(typeof(Canvas));
|
||||
if (parentObject != null)
|
||||
{
|
||||
overlayCanvas = parentObject as Canvas;
|
||||
|
||||
_tutorialPanelObject = Instantiate(tutorialPanelPrefabs[panelIndex], parentObject.GameObject().transform);
|
||||
overlay = _tutorialPanelObject.GetComponent<CanvasGroup>();
|
||||
_tutorialPanelController = _tutorialPanelObject.GetComponent<TutorialPanelController>();
|
||||
}
|
||||
|
||||
public void StartTutorial()
|
||||
{
|
||||
overlay.gameObject.SetActive(true);
|
||||
if (_tutorialPanelController != null)
|
||||
{
|
||||
onTutorialComplete = onTutorialEnd;
|
||||
overlay.alpha = 1f;
|
||||
overlay.blocksRaycasts = true;
|
||||
RunStep(firstStep);
|
||||
}
|
||||
else Debug.Log("패널 생성 실패, 튜토리얼 진행이 불가능합니다.");
|
||||
}
|
||||
|
||||
private void RunStep(TutorialStep step)
|
||||
@ -43,30 +58,25 @@ public class TutorialManager : MonoBehaviour
|
||||
private IEnumerator RunStepCoroutine(TutorialStep step)
|
||||
{
|
||||
// 단계 시작 이벤트
|
||||
step.onBegin?.Invoke();
|
||||
step.onStepBegin?.Invoke();
|
||||
// 메시지 갱신
|
||||
tutorialText.text = step.message;
|
||||
_tutorialPanelController.setTutorialText(step.message);
|
||||
|
||||
float elapsed = 0f;
|
||||
bool done = false;
|
||||
bool done = false;
|
||||
|
||||
//터치해야 할 위치가 있는지 체크
|
||||
if (step.touchTargetIndex >= 0)
|
||||
{
|
||||
targetRt = touchTargets[step.touchTargetIndex].GetComponent<RectTransform>();
|
||||
touchTargets[step.touchTargetIndex].SetActive(true);
|
||||
}
|
||||
//화면에서 숨겨야 할 요소가 있는지 체크
|
||||
if (step.deactiveObjectIndex >= 0)
|
||||
{
|
||||
lockTargets[step.deactiveObjectIndex].SetActive(false);
|
||||
targetRt = _tutorialPanelController.touchTargets[step.touchTargetIndex].GetComponent<RectTransform>();
|
||||
_tutorialPanelController.touchTargets[step.touchTargetIndex].SetActive(true);
|
||||
}
|
||||
|
||||
while (!done)
|
||||
{
|
||||
{
|
||||
// 1) 영역 터치 체크
|
||||
if (targetRt != null)
|
||||
{
|
||||
{
|
||||
// 클릭 또는 터치 이벤트
|
||||
bool pressed = Input.GetMouseButtonDown(0) || Input.touchCount > 0;
|
||||
if (pressed)
|
||||
@ -81,11 +91,7 @@ public class TutorialManager : MonoBehaviour
|
||||
{
|
||||
Debug.Log("타겟 터치");
|
||||
targetRt = null;
|
||||
touchTargets[step.touchTargetIndex].SetActive(false);
|
||||
if (step.deactiveObjectIndex >= 0)
|
||||
{
|
||||
lockTargets[step.deactiveObjectIndex].SetActive(true);
|
||||
}
|
||||
_tutorialPanelController.touchTargets[step.touchTargetIndex].SetActive(false);
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
@ -94,23 +100,18 @@ public class TutorialManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 타임아웃 체크
|
||||
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();
|
||||
|
||||
step.onStepComplete?.Invoke();
|
||||
|
||||
// 다음 단계로
|
||||
if (step.nextStep != null)
|
||||
RunStep(step.nextStep);
|
||||
@ -120,8 +121,19 @@ public class TutorialManager : MonoBehaviour
|
||||
|
||||
private void EndTutorial()
|
||||
{
|
||||
tutorialText.text = "";
|
||||
_tutorialPanelController.setTutorialText("");
|
||||
overlay.alpha = 0f;
|
||||
overlay.blocksRaycasts = false;
|
||||
|
||||
if(onTutorialComplete!=null)
|
||||
{
|
||||
onTutorialComplete?.Invoke();
|
||||
onTutorialComplete = null;
|
||||
}
|
||||
|
||||
if (_tutorialPanelObject == null)
|
||||
return;
|
||||
Destroy(_tutorialPanelObject);
|
||||
_tutorialPanelController = null;
|
||||
}
|
||||
}
|
28
Assets/LIN/Scripts/Tutorial/TutorialPanelController.cs
Normal file
28
Assets/LIN/Scripts/Tutorial/TutorialPanelController.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CanvasGroup))]
|
||||
public class TutorialPanelController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text tutorialText;
|
||||
|
||||
[Header("튜토리얼 터치 타겟들")]
|
||||
public GameObject[] touchTargets;
|
||||
|
||||
public void setTutorialText(string tutorialText)
|
||||
{
|
||||
this.tutorialText.text = tutorialText;
|
||||
}
|
||||
|
||||
public void Show(int index)
|
||||
{
|
||||
touchTargets[index].SetActive(true);
|
||||
}
|
||||
|
||||
public void Hide(int index)
|
||||
{
|
||||
touchTargets[index].SetActive(false);
|
||||
}
|
||||
}
|
11
Assets/LIN/Scripts/Tutorial/TutorialPanelController.cs.meta
Normal file
11
Assets/LIN/Scripts/Tutorial/TutorialPanelController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50f463251502b134d9b627d30c30842b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,22 +1,21 @@
|
||||
// TutorialStep.cs
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
[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 입력 시 완료
|
||||
public float timeout = 2f; // 0 이상이면 이 시간 경과 후 자동 완료
|
||||
|
||||
[Tooltip("터치해야 할 위치가 있다면, 게임매니저에게 인덱스 전달")]
|
||||
[Tooltip("단계별로 시작, 완료시 추가로 실행할 이벤트")]
|
||||
public UnityEvent onStepBegin; // 단계 시작 시 추가로 실행할 이벤트
|
||||
public UnityEvent onStepComplete; // 단계 완료 시 실행할 이벤트
|
||||
|
||||
[Tooltip("터치해야 할 위치가 있다면, 튜토리얼 매니저에게 인덱스 전달")]
|
||||
public int touchTargetIndex=-1;
|
||||
[Tooltip("배경캔버스에서 끌 오브젝트 인덱스 전달")]
|
||||
public int deactiveObjectIndex=-1;
|
||||
|
||||
[Tooltip("다음 단계로 넘어갈 TutorialStep, null이면 튜토리얼 종료")]
|
||||
public TutorialStep nextStep;
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18265c81aaa1344439d5501a08b7a633
|
||||
guid: 6468efabb5f9308459bd0e1662a3816f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
Loading…
x
Reference in New Issue
Block a user