Hide Ana-Lyse's dialogue component when taking photo, also correctly restore a hidden state with the dialogu turned off
This commit is contained in:
@@ -226,7 +226,7 @@ GameObject:
|
|||||||
- component: {fileID: 2741639361616064442}
|
- component: {fileID: 2741639361616064442}
|
||||||
- component: {fileID: 4903273501345439385}
|
- component: {fileID: 4903273501345439385}
|
||||||
- component: {fileID: 1054459649399154791}
|
- component: {fileID: 1054459649399154791}
|
||||||
- component: {fileID: 7319925080429004531}
|
- component: {fileID: 61210891595976786}
|
||||||
m_Layer: 10
|
m_Layer: 10
|
||||||
m_Name: Hidden
|
m_Name: Hidden
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -451,7 +451,7 @@ MonoBehaviour:
|
|||||||
audioSource: {fileID: 0}
|
audioSource: {fileID: 0}
|
||||||
clipPriority: 0
|
clipPriority: 0
|
||||||
sourcePriority: 1
|
sourcePriority: 1
|
||||||
--- !u!114 &7319925080429004531
|
--- !u!114 &61210891595976786
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
@@ -460,9 +460,9 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 1011363502278351410}
|
m_GameObject: {fileID: 1011363502278351410}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 95e46aacea5b42888ee7881894193c11, type: 3}
|
m_Script: {fileID: 11500000, guid: 1fa347bfb45f473f8639842928f8cfa1, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleState
|
m_EditorClassIdentifier: AppleHillsScripts::StateMachines.Quarry.AnneLise.HiddenState
|
||||||
--- !u!1 &1674229500073894281
|
--- !u!1 &1674229500073894281
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -830,6 +830,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 603ecc4a6ab6bb84c8cb9773fa310b69, type: 3}
|
m_Script: {fileID: 11500000, guid: 603ecc4a6ab6bb84c8cb9773fa310b69, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: '::'
|
m_EditorClassIdentifier: '::'
|
||||||
|
dialogueCanvas: {fileID: 7042752134100908030}
|
||||||
--- !u!114 &1193493154550576580
|
--- !u!114 &1193493154550576580
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1740,3 +1741,8 @@ RectTransform:
|
|||||||
m_CorrespondingSourceObject: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3}
|
m_CorrespondingSourceObject: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3}
|
||||||
m_PrefabInstance: {fileID: 4289827099693551234}
|
m_PrefabInstance: {fileID: 4289827099693551234}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!1 &7042752134100908030 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6499933157207406972, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 4289827099693551234}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class cameraSwitcherNailBird : MonoBehaviour
|
|||||||
|
|
||||||
private void OnTriggerExit2D(Collider2D other)
|
private void OnTriggerExit2D(Collider2D other)
|
||||||
{
|
{
|
||||||
if (other.CompareTag("Player"))
|
if (other.CompareTag("Player") && gameObject.activeInHierarchy)
|
||||||
{
|
{
|
||||||
playerInsideCount--;
|
playerInsideCount--;
|
||||||
if (playerInsideCount == 0 && virtualCamera != null)
|
if (playerInsideCount == 0 && virtualCamera != null)
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ namespace StateMachines.Quarry.AnneLise
|
|||||||
{
|
{
|
||||||
public class AnneLiseBushBehaviour : MonoBehaviour
|
public class AnneLiseBushBehaviour : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
[SerializeField] private GameObject dialogueCanvas;
|
||||||
|
|
||||||
|
|
||||||
private AppleMachine _anneLiseBushStateMachine;
|
private AppleMachine _anneLiseBushStateMachine;
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Start()
|
void Start()
|
||||||
@@ -16,6 +18,7 @@ namespace StateMachines.Quarry.AnneLise
|
|||||||
|
|
||||||
public void TakePhoto()
|
public void TakePhoto()
|
||||||
{
|
{
|
||||||
|
dialogueCanvas?.SetActive(false);
|
||||||
_anneLiseBushStateMachine.ChangeState("TakePhoto");
|
_anneLiseBushStateMachine.ChangeState("TakePhoto");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
78
Assets/Scripts/StateMachines/Quarry/AnneLise/HiddenState.cs
Normal file
78
Assets/Scripts/StateMachines/Quarry/AnneLise/HiddenState.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using Core.SaveLoad;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace StateMachines.Quarry.AnneLise
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Hidden state for Anne Lise that saves/restores the DialogueCanvas active state
|
||||||
|
/// </summary>
|
||||||
|
public class HiddenState : AppleState
|
||||||
|
{
|
||||||
|
private GameObject _dialogueCanvas;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Serializable data for the hidden state
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
private class HiddenStateData
|
||||||
|
{
|
||||||
|
public bool wasDialogueCanvasActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
// Find the immediate child called "DialogueCanvas"
|
||||||
|
Transform childTransform = transform.Find("DialogueCanvas");
|
||||||
|
if (childTransform != null)
|
||||||
|
{
|
||||||
|
_dialogueCanvas = childTransform.gameObject;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"[HiddenState] DialogueCanvas child not found on {gameObject.name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string SerializeState()
|
||||||
|
{
|
||||||
|
if (_dialogueCanvas == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[HiddenState] Cannot serialize state - DialogueCanvas is null");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
HiddenStateData data = new HiddenStateData
|
||||||
|
{
|
||||||
|
wasDialogueCanvasActive = _dialogueCanvas.activeSelf
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonUtility.ToJson(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnRestoreState(string data)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(data))
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[HiddenState] No data to restore");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_dialogueCanvas == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[HiddenState] Cannot restore state - DialogueCanvas is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HiddenStateData stateData = JsonUtility.FromJson<HiddenStateData>(data);
|
||||||
|
_dialogueCanvas.SetActive(stateData.wasDialogueCanvasActive);
|
||||||
|
Debug.Log($"[HiddenState] Restored DialogueCanvas active state to: {stateData.wasDialogueCanvasActive}");
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError($"[HiddenState] Failed to restore state: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1fa347bfb45f473f8639842928f8cfa1
|
||||||
|
timeCreated: 1763978213
|
||||||
Reference in New Issue
Block a user