Browse Source

Fixed Fade To View can sometimes not work in Unity 5.3 #370

master
chrisgregan 9 years ago
parent
commit
354a0188da
  1. 14
      Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs
  2. 14
      Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs
  3. 358
      Assets/Tests/Camera/CameraTests.unity
  4. 2
      ProjectSettings/ProjectVersion.txt

14
Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs

@ -31,20 +31,28 @@ namespace Fungus
[Tooltip("Camera to use for the fade. Will use main camera if set to none.")]
public Camera targetCamera;
public virtual void Start()
protected virtual void AcquireCamera()
{
if (targetCamera == null)
if (targetCamera != null)
{
targetCamera = Camera.main;
return;
}
targetCamera = Camera.main;
if (targetCamera == null)
{
targetCamera = GameObject.FindObjectOfType<Camera>();
}
}
public virtual void Start()
{
AcquireCamera();
}
public override void OnEnter()
{
AcquireCamera();
if (targetCamera == null ||
targetView == null)
{

14
Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs

@ -22,20 +22,28 @@ namespace Fungus
[Tooltip("Camera to use for the pan. Will use main camera if set to none.")]
public Camera targetCamera;
public virtual void Start()
protected virtual void AcquireCamera()
{
if (targetCamera == null)
if (targetCamera != null)
{
targetCamera = Camera.main;
return;
}
targetCamera = Camera.main;
if (targetCamera == null)
{
targetCamera = GameObject.FindObjectOfType<Camera>();
}
}
public virtual void Start()
{
AcquireCamera();
}
public override void OnEnter()
{
AcquireCamera();
if (targetCamera == null ||
targetView == null)
{

358
Assets/Tests/Camera/CameraTests.unity

@ -137,7 +137,7 @@ Transform:
- {fileID: 169490923}
- {fileID: 763909869}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
--- !u!1 &169490921
GameObject:
m_ObjectHideFlags: 0
@ -181,6 +181,49 @@ Transform:
m_Children: []
m_Father: {fileID: 116319155}
m_RootOrder: 2
--- !u!1 &265644406
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 100000, guid: e0d427add844a4d9faf970a3afa07583, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 265644407}
- 114: {fileID: 265644408}
m_Layer: 0
m_Name: View
m_TagString: Untagged
m_Icon: {fileID: 5721338939258241955, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &265644407
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 400000, guid: e0d427add844a4d9faf970a3afa07583, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265644406}
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: 1621267341}
m_RootOrder: 1
--- !u!114 &265644408
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11400000, guid: e0d427add844a4d9faf970a3afa07583,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265644406}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 95c387d3e32404bcc91c60318d766bb1, type: 3}
m_Name:
m_EditorClassIdentifier:
viewSize: 1
primaryAspectRatio: {x: 4, y: 3}
secondaryAspectRatio: {x: 2, y: 1}
--- !u!1 &297082796
GameObject:
m_ObjectHideFlags: 0
@ -473,7 +516,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
--- !u!1 &740080468
GameObject:
m_ObjectHideFlags: 0
@ -788,7 +831,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
--- !u!1 &858416965
GameObject:
m_ObjectHideFlags: 0
@ -1072,7 +1115,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3}
m_Name:
m_EditorClassIdentifier:
selectedFlowchart: {fileID: 297082802}
selectedFlowchart: {fileID: 2004563605}
--- !u!4 &1537635168
Transform:
m_ObjectHideFlags: 1
@ -1084,7 +1127,58 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
--- !u!1 &1621267339
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1621267341}
- 114: {fileID: 1621267340}
m_Layer: 0
m_Name: AcquireCameraTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1621267340
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1621267339}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b1dba0b27b0864740a8720e920aa88c0, type: 3}
m_Name:
m_EditorClassIdentifier:
timeout: 5
ignored: 0
succeedAfterAllAssertionsAreExecuted: 0
expectException: 0
expectedExceptionList:
succeedWhenExceptionIsThrown: 0
includedPlatforms: -1
platformsToIgnore: []
dynamic: 0
dynamicTypeName:
--- !u!4 &1621267341
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1621267339}
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: 2004563601}
- {fileID: 265644407}
m_Father: {fileID: 0}
m_RootOrder: 7
--- !u!1 &1636512972
GameObject:
m_ObjectHideFlags: 0
@ -1143,7 +1237,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!114 &1658645684
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1182,7 +1276,7 @@ Transform:
- {fileID: 1636512973}
- {fileID: 858416966}
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 6
--- !u!1 &1911312607
GameObject:
m_ObjectHideFlags: 0
@ -1286,3 +1380,253 @@ Transform:
m_Children: []
m_Father: {fileID: 116319155}
m_RootOrder: 1
--- !u!1 &1948710916
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 100000, guid: 0e6bcf37a2876432fa58eff8888bf177, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1948710920}
- 212: {fileID: 1948710919}
- 61: {fileID: 1948710918}
- 114: {fileID: 1948710917}
m_Layer: 0
m_Name: ClickableSprite
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1948710917
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11400000, guid: 0e6bcf37a2876432fa58eff8888bf177,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1948710916}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cc03961113fa349c09cb06ef2911013d, type: 3}
m_Name:
m_EditorClassIdentifier:
clickEnabled: 1
hoverCursor: {fileID: 0}
--- !u!61 &1948710918
BoxCollider2D:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 6100000, guid: 0e6bcf37a2876432fa58eff8888bf177,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1948710916}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Size: {x: 3, y: 3}
--- !u!212 &1948710919
SpriteRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 21200000, guid: 0e6bcf37a2876432fa58eff8888bf177,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1948710916}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 0
m_ReflectionProbeUsage: 0
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
--- !u!4 &1948710920
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 400000, guid: 0e6bcf37a2876432fa58eff8888bf177, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1948710916}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.06, y: 0, z: 0}
m_LocalScale: {x: 0.50204486, y: 0.50204486, z: 0.50204486}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
--- !u!1 &2004563600
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 2004563601}
- 114: {fileID: 2004563605}
- 114: {fileID: 2004563604}
- 114: {fileID: 2004563603}
- 114: {fileID: 2004563602}
- 114: {fileID: 2004563606}
- 114: {fileID: 2004563607}
m_Layer: 0
m_Name: Flowchart
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2004563601
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004563600}
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: 1621267341}
m_RootOrder: 0
--- !u!114 &2004563602
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004563600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 437f9a4e3dbc647f9bdce95308418bff, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 1
errorMessage:
indentLevel: 0
duration: 1
fadeOut: 0
targetView: {fileID: 265644408}
waitUntilFinished: 1
fadeColor: {r: 0, g: 0, b: 0, a: 1}
fadeTexture: {fileID: 0}
targetCamera: {fileID: 0}
--- !u!114 &2004563603
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11462346, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004563600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3}
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 2004563604}
--- !u!114 &2004563604
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004563600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3}
m_Name:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 67
y: 70
width: 120
height: 40
itemId: 0
blockName: Start
description:
eventHandler: {fileID: 2004563603}
commandList:
- {fileID: 2004563602}
- {fileID: 2004563607}
- {fileID: 2004563606}
--- !u!114 &2004563605
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004563600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 1.0
scrollPos: {x: 0, y: 0}
variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1
blockViewHeight: 400
zoom: 1
scrollViewRect:
serializedVersion: 2
x: -343
y: -340
width: 1114
height: 859
selectedBlock: {fileID: 2004563604}
selectedCommands:
- {fileID: 2004563607}
variables: []
description:
stepPause: 0
colorCommands: 1
hideComponents: 1
saveSelection: 1
localizationId:
hideCommands: []
--- !u!114 &2004563606
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004563600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4920f47cde1a84b11ad07b7317568494, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 2
errorMessage:
indentLevel: 0
--- !u!114 &2004563607
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2004563600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45c952ea1ad444e479b570fa242679c5, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 3
errorMessage:
indentLevel: 0
duration: 1
targetView: {fileID: 265644408}
waitUntilFinished: 1
targetCamera: {fileID: 0}

2
ProjectSettings/ProjectVersion.txt

@ -1,2 +1,2 @@
m_EditorVersion: 5.3.1f1
m_EditorVersion: 5.3.2f1
m_StandardAssetsVersion: 0

Loading…
Cancel
Save