Browse Source

Refactored scene start code to be handled exclusively by SaveManager. Added save history debug view.

master
Christopher 8 years ago
parent
commit
b03cdcac11
  1. 798
      Assets/Fungus/Resources/Prefabs/SaveMenu.prefab
  2. 13
      Assets/Fungus/Scripts/Commands/SavePoint.cs
  3. 178
      Assets/Fungus/Scripts/Components/SaveManager.cs
  4. 13
      Assets/Fungus/Scripts/Components/SaveMenu.cs
  5. 19
      Assets/Fungus/Scripts/Utils/SaveHistory.cs
  6. 7
      Assets/Fungus/Scripts/Utils/SavePointData.cs
  7. 9
      Assets/FungusExamples/SaveGame/SaveExample.unity

798
Assets/Fungus/Resources/Prefabs/SaveMenu.prefab

@ -211,6 +211,107 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!1 &1017909244067428
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224756314496247326}
- component: {fileID: 222346054301214274}
- component: {fileID: 114625242687138120}
- component: {fileID: 114305052877464294}
m_Layer: 5
m_Name: Scrollbar Horizontal
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1134525095276268
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224506178468526888}
m_Layer: 5
m_Name: Sliding Area
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1142916231164870
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224160472953040096}
- component: {fileID: 222114849256167646}
- component: {fileID: 114632310104905278}
m_Layer: 5
m_Name: Handle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1171231265388170
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224258996373127644}
- component: {fileID: 222243915251368484}
- component: {fileID: 114119135089980988}
- component: {fileID: 114993625917992760}
m_Layer: 5
m_Name: Scrollbar Vertical
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1210356177377382
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224353886759344458}
m_Layer: 5
m_Name: Sliding Area
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1216016164557284
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224259322050551826}
- component: {fileID: 114302650921901322}
- component: {fileID: 222328673954104156}
- component: {fileID: 114044970116333216}
m_Layer: 5
m_Name: Viewport
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1333170469647788 --- !u!1 &1333170469647788
GameObject: GameObject:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -228,6 +329,42 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!1 &1562890099353150
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224331103297166980}
- component: {fileID: 222091168920081386}
- component: {fileID: 114738251385494794}
m_Layer: 5
m_Name: Content
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1575375668969800
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224304764365683998}
- component: {fileID: 114162492929892552}
- component: {fileID: 222516594292902920}
- component: {fileID: 114763048961342110}
- component: {fileID: 114193710787652350}
m_Layer: 5
m_Name: DebugView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1801582794521622 --- !u!1 &1801582794521622
GameObject: GameObject:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -262,6 +399,23 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!1 &1997369251198830
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224880810258273170}
- component: {fileID: 222800070994067700}
- component: {fileID: 114056508902046002}
m_Layer: 5
m_Name: Handle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!82 &82000012749735044 --- !u!82 &82000012749735044
AudioSource: AudioSource:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -413,6 +567,7 @@ MonoBehaviour:
rewindButton: {fileID: 114000013791261618} rewindButton: {fileID: 114000013791261618}
forwardButton: {fileID: 114000014122010370} forwardButton: {fileID: 114000014122010370}
restartButton: {fileID: 114000012958020502} restartButton: {fileID: 114000012958020502}
debugView: {fileID: 114162492929892552}
--- !u!114 &114000010610974372 --- !u!114 &114000010610974372
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -1061,12 +1216,12 @@ MonoBehaviour:
m_FillAmount: 1 m_FillAmount: 1
m_FillClockwise: 1 m_FillClockwise: 1
m_FillOrigin: 0 m_FillOrigin: 0
--- !u!114 &114491427777887672 --- !u!114 &114044970116333216
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1898064487847954} m_GameObject: {fileID: 1216016164557284}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
@ -1080,20 +1235,20 @@ MonoBehaviour:
m_Calls: [] m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 62573ea76cbf34643bf28a259a6c901c, type: 3} m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 0 m_Type: 1
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
m_FillMethod: 4 m_FillMethod: 4
m_FillAmount: 1 m_FillAmount: 1
m_FillClockwise: 1 m_FillClockwise: 1
m_FillOrigin: 0 m_FillOrigin: 0
--- !u!114 &114875751214506758 --- !u!114 &114056508902046002
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1801582794521622} m_GameObject: {fileID: 1997369251198830}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
@ -1107,20 +1262,20 @@ MonoBehaviour:
m_Calls: [] m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 62573ea76cbf34643bf28a259a6c901c, type: 3} m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 0 m_Type: 1
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
m_FillMethod: 4 m_FillMethod: 4
m_FillAmount: 1 m_FillAmount: 1
m_FillClockwise: 1 m_FillClockwise: 1
m_FillOrigin: 0 m_FillOrigin: 0
--- !u!114 &114920314574492042 --- !u!114 &114119135089980988
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1333170469647788} m_GameObject: {fileID: 1171231265388170}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
@ -1134,64 +1289,412 @@ MonoBehaviour:
m_Calls: [] m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 8d3c80dd0c2904cdbb745cf481348a76, type: 3} m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 0 m_Type: 1
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
m_FillMethod: 4 m_FillMethod: 4
m_FillAmount: 1 m_FillAmount: 1
m_FillClockwise: 1 m_FillClockwise: 1
m_FillOrigin: 0 m_FillOrigin: 0
--- !u!222 &222000010636408894 --- !u!114 &114162492929892552
CanvasRenderer: MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011815857470}
--- !u!222 &222000010752835546
CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013007313816} m_GameObject: {fileID: 1575375668969800}
--- !u!222 &222000010789171018 m_Enabled: 1
CanvasRenderer: m_EditorHideFlags: 0
m_Script: {fileID: 1367256648, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Content: {fileID: 224331103297166980}
m_Horizontal: 1
m_Vertical: 1
m_MovementType: 1
m_Elasticity: 0.1
m_Inertia: 1
m_DecelerationRate: 0.135
m_ScrollSensitivity: 1
m_Viewport: {fileID: 224259322050551826}
m_HorizontalScrollbar: {fileID: 114305052877464294}
m_VerticalScrollbar: {fileID: 114993625917992760}
m_HorizontalScrollbarVisibility: 2
m_VerticalScrollbarVisibility: 2
m_HorizontalScrollbarSpacing: -3
m_VerticalScrollbarSpacing: -3
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.ScrollRect+ScrollRectEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &114193710787652350
MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011114926160} m_GameObject: {fileID: 1575375668969800}
--- !u!222 &222000010966400006 m_Enabled: 1
CanvasRenderer: m_EditorHideFlags: 0
m_Script: {fileID: 1679637790, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 1
m_MinWidth: -1
m_MinHeight: -1
m_PreferredWidth: -1
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1
--- !u!114 &114302650921901322
MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013166397642} m_GameObject: {fileID: 1216016164557284}
--- !u!222 &222000011100116716 m_Enabled: 1
CanvasRenderer: m_EditorHideFlags: 0
m_Script: {fileID: -1200242548, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShowMaskGraphic: 0
--- !u!114 &114305052877464294
MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010010131774} m_GameObject: {fileID: 1017909244067428}
--- !u!222 &222000011280725060 m_Enabled: 1
CanvasRenderer: m_EditorHideFlags: 0
m_Script: {fileID: -2061169968, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
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_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 114056508902046002}
m_HandleRect: {fileID: 224880810258273170}
m_Direction: 0
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Scrollbar+ScrollEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &114491427777887672
MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013328246242} m_GameObject: {fileID: 1898064487847954}
--- !u!222 &222000011515314216 m_Enabled: 1
CanvasRenderer: m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 62573ea76cbf34643bf28a259a6c901c, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114625242687138120
MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013032760896} m_GameObject: {fileID: 1017909244067428}
--- !u!222 &222000012009353026 m_Enabled: 1
CanvasRenderer: m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114632310104905278
MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013089762296} m_GameObject: {fileID: 1142916231164870}
--- !u!222 &222000013070489478 m_Enabled: 1
CanvasRenderer: m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114738251385494794
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1562890099353150}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 0
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!114 &114763048961342110
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1575375668969800}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114875751214506758
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1801582794521622}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 62573ea76cbf34643bf28a259a6c901c, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114920314574492042
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1333170469647788}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 8d3c80dd0c2904cdbb745cf481348a76, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114993625917992760
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1171231265388170}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -2061169968, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
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_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 114632310104905278}
m_HandleRect: {fileID: 224160472953040096}
m_Direction: 2
m_Value: 1
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Scrollbar+ScrollEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!222 &222000010636408894
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011815857470}
--- !u!222 &222000010752835546
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013007313816}
--- !u!222 &222000010789171018
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011114926160}
--- !u!222 &222000010966400006
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013166397642}
--- !u!222 &222000011100116716
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010010131774}
--- !u!222 &222000011280725060
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013328246242}
--- !u!222 &222000011515314216
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013032760896}
--- !u!222 &222000012009353026
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013089762296}
--- !u!222 &222000013070489478
CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
@ -1202,24 +1705,66 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010142133612} m_GameObject: {fileID: 1000010142133612}
--- !u!222 &222091168920081386
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1562890099353150}
--- !u!222 &222114849256167646
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1142916231164870}
--- !u!222 &222243915251368484
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1171231265388170}
--- !u!222 &222271235964525112 --- !u!222 &222271235964525112
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1333170469647788} m_GameObject: {fileID: 1333170469647788}
--- !u!222 &222328673954104156
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1216016164557284}
--- !u!222 &222346054301214274
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1017909244067428}
--- !u!222 &222456543252686318 --- !u!222 &222456543252686318
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1801582794521622} m_GameObject: {fileID: 1801582794521622}
--- !u!222 &222516594292902920
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1575375668969800}
--- !u!222 &222529376750664854 --- !u!222 &222529376750664854
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1898064487847954} m_GameObject: {fileID: 1898064487847954}
--- !u!222 &222800070994067700
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1997369251198830}
--- !u!223 &223000014176703286 --- !u!223 &223000014176703286
Canvas: Canvas:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -1311,6 +1856,7 @@ RectTransform:
- {fileID: 224000012687811630} - {fileID: 224000012687811630}
- {fileID: 224000012590701094} - {fileID: 224000012590701094}
- {fileID: 224000013149320576} - {fileID: 224000013149320576}
- {fileID: 224304764365683998}
m_Father: {fileID: 224000011191842766} m_Father: {fileID: 224000011191842766}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1450,6 +1996,24 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224160472953040096
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1142916231164870}
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_Children: []
m_Father: {fileID: 224506178468526888}
m_RootOrder: 0
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!224 &224255369405830710 --- !u!224 &224255369405830710
RectTransform: RectTransform:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -1468,6 +2032,121 @@ RectTransform:
m_AnchoredPosition: {x: -0.000025272, y: 0.000025272} m_AnchoredPosition: {x: -0.000025272, y: 0.000025272}
m_SizeDelta: {x: 21, y: 21} m_SizeDelta: {x: 21, y: 21}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224258996373127644
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1171231265388170}
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_Children:
- {fileID: 224506178468526888}
m_Father: {fileID: 224304764365683998}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: -17}
m_Pivot: {x: 1, y: 1}
--- !u!224 &224259322050551826
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1216016164557284}
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_Children:
- {fileID: 224331103297166980}
m_Father: {fileID: 224304764365683998}
m_RootOrder: 0
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: -17, y: -17}
m_Pivot: {x: 0, y: 1}
--- !u!224 &224304764365683998
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1575375668969800}
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_Children:
- {fileID: 224259322050551826}
- {fileID: 224756314496247326}
- {fileID: 224258996373127644}
m_Father: {fileID: 224000012525218478}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -186.18002, y: -212.91998}
m_SizeDelta: {x: 427, y: 366}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224331103297166980
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1562890099353150}
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_Children: []
m_Father: {fileID: 224259322050551826}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -0.000030517578}
m_SizeDelta: {x: 0, y: 300}
m_Pivot: {x: 0, y: 1}
--- !u!224 &224353886759344458
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1210356177377382}
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_Children:
- {fileID: 224880810258273170}
m_Father: {fileID: 224756314496247326}
m_RootOrder: 0
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!224 &224506178468526888
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1134525095276268}
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_Children:
- {fileID: 224160472953040096}
m_Father: {fileID: 224258996373127644}
m_RootOrder: 0
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!224 &224682822578024892 --- !u!224 &224682822578024892
RectTransform: RectTransform:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -1486,6 +2165,25 @@ RectTransform:
m_AnchoredPosition: {x: 0.0000076294, y: 0} m_AnchoredPosition: {x: 0.0000076294, y: 0}
m_SizeDelta: {x: 21, y: 21} m_SizeDelta: {x: 21, y: 21}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224756314496247326
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1017909244067428}
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_Children:
- {fileID: 224353886759344458}
m_Father: {fileID: 224304764365683998}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -17, y: 20}
m_Pivot: {x: 0, y: 0}
--- !u!224 &224819725728513600 --- !u!224 &224819725728513600
RectTransform: RectTransform:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -1504,6 +2202,24 @@ RectTransform:
m_AnchoredPosition: {x: 0.3, y: 1.1} m_AnchoredPosition: {x: 0.3, y: 1.1}
m_SizeDelta: {x: 27.7, y: 27.7} m_SizeDelta: {x: 27.7, y: 27.7}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224880810258273170
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1997369251198830}
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_Children: []
m_Father: {fileID: 224353886759344458}
m_RootOrder: 0
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!225 &225000012423540070 --- !u!225 &225000012423540070
CanvasGroup: CanvasGroup:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1

13
Assets/Fungus/Scripts/Commands/SavePoint.cs

@ -51,19 +51,6 @@ namespace Fungus
[Tooltip("Resume execution from here after loading this Save Point.")] [Tooltip("Resume execution from here after loading this Save Point.")]
[SerializeField] protected bool resumeFromHere = true; [SerializeField] protected bool resumeFromHere = true;
protected virtual void Start()
{
// Each scene should have one Save Point with the 'Start' key.
// We automatically start execution from this command whenever the scene starts 'normally' (i.e. first play, restart or scene load via the Load Scene command or SceneManager.LoadScene).
// If on the other hand, the scene was loaded by loading a Save Point then the Save Manager handles resuming execution at the appropriate point, so we don't need to do anything here.
if (string.Compare(SavePointKey, "Start", true) == 0 &&
!FungusManager.Instance.SaveManager.HasLoadedSavePoint)
{
GetFlowchart().ExecuteBlock(ParentBlock, CommandIndex);
}
}
#region Public members #region Public members
/// <summary> /// <summary>

178
Assets/Fungus/Scripts/Components/SaveManager.cs

@ -1,10 +1,11 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using UnityEngine.SceneManagement;
namespace Fungus namespace Fungus
{ {
/// <summary> /// <summary>
/// Manages the Save History (a list of Save Points). /// Manages the Save History (a list of Save Points) and provides a set of operations for saving and loading games.
/// </summary> /// </summary>
public class SaveManager : MonoBehaviour public class SaveManager : MonoBehaviour
{ {
@ -39,28 +40,131 @@ namespace Fungus
return false; return false;
} }
/// <summary>
/// Starts Block execution based on a Save Point Key
/// The execution order is:
/// 1. Save Point Loaded event handlers with a matching key.
/// 2. First Save Point command (in any Block) with matching key. Execution starts at the following command.
/// 3. Any label in any block with name matching the key. Execution starts at the following command.
/// </summary>
protected virtual void ExecuteBlocks(string savePointKey)
{
// Execute Save Point Loaded event handlers with matching key.
SavePointLoaded.NotifyEventHandlers(savePointKey);
// Execute any block containing a SavePoint command matching the save key, with Resume From Here enabled
var savePoints = Object.FindObjectsOfType<SavePoint>();
for (int i = 0; i < savePoints.Length; i++)
{
var savePoint = savePoints[i];
if (savePoint.ResumeFromHere &&
string.Compare(savePoint.SavePointKey, savePointKey, true) == 0)
{
int index = savePoint.CommandIndex;
var block = savePoint.ParentBlock;
var flowchart = savePoint.GetFlowchart();
flowchart.ExecuteBlock(block, index + 1);
// Assume there's only one SavePoint using this key
break;
}
}
// Execute any block containing a Label matching the save key
var labels = Object.FindObjectsOfType<Label>();
for (int i = 0; i < labels.Length; i++)
{
var label = labels[i];
if (string.Compare(label.Key, savePointKey, true) == 0)
{
int index = label.CommandIndex;
var block = label.ParentBlock;
var flowchart = label.GetFlowchart();
flowchart.ExecuteBlock(block, index + 1);
}
}
}
/// <summary>
/// Starts execution at the first Save Point with the key 'Start'.
/// </summary>
protected virtual void ExecuteStartBlock()
{
// Each scene should have one Save Point with the 'Start' key.
// We automatically start execution from this command whenever the scene starts 'normally' (i.e. first play, restart or scene load via the Load Scene command or SceneManager.LoadScene).
var savePoints = Object.FindObjectsOfType<SavePoint>();
for (int i = 0; i < savePoints.Length; i++)
{
var savePoint = savePoints[i];
if (string.Compare(savePoint.SavePointKey, "Start", true) == 0)
{
savePoint.GetFlowchart().ExecuteBlock(savePoint.ParentBlock, savePoint.CommandIndex);
break;
}
}
}
// Scene loading in Unity is asynchronous so we need to take care to avoid race conditions.
// The following callbacks tell us when a scene has been loaded and when
// a saved game has been loaded. We delay taking action until the next
// frame (via a delegate) so that we're sure which case we're dealing with.
protected virtual void OnEnable() protected virtual void OnEnable()
{ {
SaveManagerSignals.OnSavePointLoaded += OnSavePointLoaded; SaveManagerSignals.OnSavePointLoaded += OnSavePointLoaded;
SceneManager.sceneLoaded += OnSceneLoaded;
} }
protected virtual void OnDisable() protected virtual void OnDisable()
{ {
SaveManagerSignals.OnSavePointLoaded -= OnSavePointLoaded; SaveManagerSignals.OnSavePointLoaded -= OnSavePointLoaded;
SceneManager.sceneLoaded -= OnSceneLoaded;
} }
protected virtual void OnSavePointLoaded(string savePointKey) protected virtual void OnSavePointLoaded(string savePointKey)
{ {
// Flag that a save point was loaded. var key = savePointKey;
// The flag remains set for 1 frame to give other components enough time to poll it in their Start method. loadAction = () => ExecuteBlocks(key);
HasLoadedSavePoint = true;
StartCoroutine(ResetHasLoadedSavePoint());
} }
protected virtual IEnumerator ResetHasLoadedSavePoint() protected virtual void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{ {
yield return new WaitForEndOfFrame(); // Ignore additive scene loads
HasLoadedSavePoint = false; if (mode == LoadSceneMode.Additive)
{
return;
}
// We first assume that this is a 'normal' scene load rather than a saved game being loaded.
// If we subsequently receive a notification that a saved game was loaded then the load action
// set here will be overridden by the OnSavePointLoaded callback above.
if (loadAction == null)
{
loadAction = ExecuteStartBlock;
}
}
protected System.Action loadAction;
protected virtual void Update()
{
// Execute any previously scheduled load action
if (loadAction != null)
{
loadAction();
loadAction = null;
}
}
protected virtual void LoadSavedGame(string saveDataKey)
{
if (ReadSaveHistory(saveDataKey))
{
saveHistory.ClearRewoundSavePoints();
saveHistory.LoadLatestSavePoint();
}
} }
#region Public members #region Public members
@ -80,8 +184,6 @@ namespace Fungus
/// </summary> /// </summary>
public virtual int NumRewoundSavePoints { get { return saveHistory.NumRewoundSavePoints; } } public virtual int NumRewoundSavePoints { get { return saveHistory.NumRewoundSavePoints; } }
public virtual bool HasLoadedSavePoint { get; private set; }
/// <summary> /// <summary>
/// Writes the Save History to persistent storage. /// Writes the Save History to persistent storage.
/// </summary> /// </summary>
@ -91,15 +193,13 @@ namespace Fungus
} }
/// <summary> /// <summary>
/// Loads the Save History from persistent storage. /// Loads the Save History from persistent storage and loads the latest Save Point.
/// </summary> /// </summary>
public void Load(string saveDataKey = DefaultSaveDataKey) public void Load(string saveDataKey = DefaultSaveDataKey)
{ {
if (ReadSaveHistory(saveDataKey)) // Set a load action to be executed on next update
{ var key = saveDataKey;
saveHistory.ClearRewoundSavePoints(); loadAction = () => LoadSavedGame(key);
saveHistory.LoadLatestSavePoint();
}
} }
/// <summary> /// <summary>
@ -167,50 +267,14 @@ namespace Fungus
} }
/// <summary> /// <summary>
/// Starts Block execution based on a Save Point Key /// Returns an info string to help debug issues with the save data.
/// The execution order is:
/// 1. Save Point Loaded event handlers with a matching key.
/// 2. First Save Point command (in any Block) with matching key. Execution starts at the following command.
/// 3. Any label in any block with name matching the key. Execution starts at the following command.
/// </summary> /// </summary>
public static void ExecuteBlocks(string savePointKey) /// <returns>The debug info.</returns>
public virtual string GetDebugInfo()
{ {
// Execute Save Point Loaded event handlers with matching key. return saveHistory.GetDebugInfo();
SavePointLoaded.NotifyEventHandlers(savePointKey);
// Execute any block containing a SavePoint command matching the save key, with Resume From Here enabled
var savePoints = Object.FindObjectsOfType<SavePoint>();
for (int i = 0; i < savePoints.Length; i++)
{
var savePoint = savePoints[i];
if (savePoint.ResumeFromHere &&
string.Compare(savePoint.SavePointKey, savePointKey, true) == 0)
{
int index = savePoint.CommandIndex;
var block = savePoint.ParentBlock;
var flowchart = savePoint.GetFlowchart();
flowchart.ExecuteBlock(block, index + 1);
// Assume there's only one SavePoint using this key
break;
}
}
// Execute any block containing a Label matching the save key
var labels = Object.FindObjectsOfType<Label>();
for (int i = 0; i < labels.Length; i++)
{
var label = labels[i];
if (string.Compare(label.Key, savePointKey, true) == 0)
{
int index = label.CommandIndex;
var block = label.ParentBlock;
var flowchart = label.GetFlowchart();
flowchart.ExecuteBlock(block, index + 1);
}
}
} }
#endregion #endregion
} }
} }

13
Assets/Fungus/Scripts/Components/SaveMenu.cs

@ -1,6 +1,5 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using System.Collections.Generic;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
namespace Fungus namespace Fungus
@ -37,6 +36,9 @@ namespace Fungus
[Tooltip("The button which restarts the game.")] [Tooltip("The button which restarts the game.")]
[SerializeField] protected Button restartButton; [SerializeField] protected Button restartButton;
[Tooltip("A scrollable text field used for debugging the save data. The text field should be disabled in normal use.")]
[SerializeField] protected ScrollRect debugView;
protected static bool saveMenuActive = false; protected static bool saveMenuActive = false;
protected AudioSource clickAudioSource; protected AudioSource clickAudioSource;
@ -105,6 +107,15 @@ namespace Fungus
{ {
forwardButton.interactable = saveManager.NumRewoundSavePoints > 0; forwardButton.interactable = saveManager.NumRewoundSavePoints > 0;
} }
if (debugView.enabled)
{
var debugText = debugView.GetComponentInChildren<Text>();
if (debugText != null)
{
debugText.text = saveManager.GetDebugInfo();
}
}
} }
protected void PlayClickSound() protected void PlayClickSound()

19
Assets/Fungus/Scripts/Utils/SaveHistory.cs

@ -102,6 +102,25 @@ namespace Fungus
rewoundSavePoints.Clear(); rewoundSavePoints.Clear();
} }
public virtual string GetDebugInfo()
{
string debugInfo = "Save points:\n";
foreach (var savePoint in savePoints)
{
debugInfo += savePoint.Substring(0, savePoint.IndexOf(',')).Replace("\n", "").Replace("{", "").Replace("}","") + "\n";
}
debugInfo += "Rewound points:\n";
foreach (var savePoint in rewoundSavePoints)
{
debugInfo += savePoint.Substring(0, savePoint.IndexOf(',')).Replace("\n", "").Replace("{", "").Replace("}","") + "\n";
}
return debugInfo;
}
#endregion #endregion
} }
} }

7
Assets/Fungus/Scripts/Utils/SavePointData.cs

@ -20,7 +20,10 @@ namespace Fungus
protected static void OnSceneLoaded(Scene scene, LoadSceneMode mode) protected static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{ {
if (scene.name != tempSavePointData.SceneName) // Additive scene loads and non-matching scene loads could happen if someone is using
// Fungus as part of a bigger game, so just ignore these events and hope they know what they're doing.
if (mode == LoadSceneMode.Additive ||
scene.name != tempSavePointData.SceneName)
{ {
return; return;
} }
@ -34,8 +37,6 @@ namespace Fungus
FlowchartData.Decode(flowchartData); FlowchartData.Decode(flowchartData);
} }
SaveManager.ExecuteBlocks(savePointData.savePointKey);
SaveManagerSignals.DoSavePointLoaded(savePointData.savePointKey); SaveManagerSignals.DoSavePointLoaded(savePointData.savePointKey);
} }

9
Assets/FungusExamples/SaveGame/SaveExample.unity

@ -632,6 +632,11 @@ Prefab:
propertyPath: m_Pivot.y propertyPath: m_Pivot.y
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 224000013748593462, guid: bd2b99773f3e0489aae9f9b5053ad360,
type: 2}
propertyPath: m_AnchoredPosition.y
value: 0.079956055
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2} m_ParentPrefab: {fileID: 100100000, guid: bd2b99773f3e0489aae9f9b5053ad360, type: 2}
m_IsPrefabParent: 0 m_IsPrefabParent: 0
@ -1260,11 +1265,11 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
version: 1 version: 1
scrollPos: {x: -103.9434, y: -49.980755} scrollPos: {x: -92.87758, y: -50.260628}
variablesScrollPos: {x: 0, y: 0} variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1 variablesExpanded: 1
blockViewHeight: 400 blockViewHeight: 400
zoom: 1 zoom: 0.9789249
scrollViewRect: scrollViewRect:
serializedVersion: 2 serializedVersion: 2
x: -400.28992 x: -400.28992

Loading…
Cancel
Save