Browse Source

Merge pull request #481 from snozbot/call-with-index

Added Command Index property to Call command
master
Chris Gregan 9 years ago
parent
commit
5a947f9cbc
  1. 4
      Assets/Fungus/Flowchart/Editor/CallEditor.cs
  2. 7
      Assets/Fungus/Flowchart/Scripts/Commands/Call.cs
  3. 9
      Assets/Tests/Flow.meta
  4. 481
      Assets/Tests/Flow/FlowTests.unity
  5. 8
      Assets/Tests/Flow/FlowTests.unity.meta

4
Assets/Fungus/Flowchart/Editor/CallEditor.cs

@ -10,6 +10,7 @@ namespace Fungus
{
protected SerializedProperty targetFlowchartProp;
protected SerializedProperty targetBlockProp;
protected SerializedProperty commandIndexProp;
protected SerializedProperty callModeProp;
protected virtual void OnEnable()
@ -19,6 +20,7 @@ namespace Fungus
targetFlowchartProp = serializedObject.FindProperty("targetFlowchart");
targetBlockProp = serializedObject.FindProperty("targetBlock");
commandIndexProp = serializedObject.FindProperty("commandIndex");
callModeProp = serializedObject.FindProperty("callMode");
}
@ -46,6 +48,8 @@ namespace Fungus
new GUIContent("Target Block", "Block to call"),
new GUIContent("<None>"),
flowchart);
EditorGUILayout.PropertyField(commandIndexProp);
}
EditorGUILayout.PropertyField(callModeProp);

7
Assets/Fungus/Flowchart/Scripts/Commands/Call.cs

@ -19,6 +19,9 @@ namespace Fungus
[FormerlySerializedAs("targetSequence")]
[Tooltip("Block to start executing")]
public Block targetBlock;
[Tooltip("Command index to start executing")]
public int commandIndex;
public enum CallMode
{
@ -64,12 +67,12 @@ namespace Fungus
flowchart.selectedBlock = targetBlock;
}
StartCoroutine(targetBlock.Execute(0, onComplete));
StartCoroutine(targetBlock.Execute(commandIndex, onComplete));
}
else
{
// Execute block in another Flowchart
targetFlowchart.ExecuteBlock(targetBlock, 0, onComplete);
targetFlowchart.ExecuteBlock(targetBlock, commandIndex, onComplete);
}
}

9
Assets/Tests/Flow.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a89da0f9d6ecd4bbaa2792cab3e0fff3
folderAsset: yes
timeCreated: 1463576398
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

481
Assets/Tests/Flow/FlowTests.unity

@ -0,0 +1,481 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
SceneSettings:
m_ObjectHideFlags: 0
m_PVSData:
m_PVSObjectsArray: []
m_PVSPortalsArray: []
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 6
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 6
m_GIWorkflowMode: 1
m_LightmapsMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 3
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AOMaxDistance: 1
m_Padding: 2
m_CompAOExponent: 0
m_LightmapParameters: {fileID: 0}
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherRayCount: 1024
m_ReflectionCompression: 2
m_LightingDataAsset: {fileID: 0}
m_RuntimeCPUUsage: 25
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
accuratePlacement: 0
minRegionArea: 2
cellSize: 0.16666667
manualCellSize: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &309986961
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 309986963}
- 114: {fileID: 309986962}
m_Layer: 0
m_Name: CallWithIndex
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &309986962
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 309986961}
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 &309986963
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 309986961}
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: 897339005}
m_Father: {fileID: 0}
m_RootOrder: 2
--- !u!1 &765506376
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 765506378}
- 114: {fileID: 765506377}
m_Layer: 0
m_Name: TestRunner
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &765506377
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 765506376}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5c3afc1c624179749bcdecf7b0224902, type: 3}
m_Name:
m_EditorClassIdentifier:
currentTest: {fileID: 0}
--- !u!4 &765506378
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 765506376}
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: 0}
m_RootOrder: 3
--- !u!1 &897339004
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 897339005}
- 114: {fileID: 897339012}
- 114: {fileID: 897339011}
- 114: {fileID: 897339010}
- 114: {fileID: 897339009}
- 114: {fileID: 897339008}
- 114: {fileID: 897339007}
- 114: {fileID: 897339006}
m_Layer: 0
m_Name: Flowchart
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &897339005
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
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: 309986963}
m_RootOrder: 0
--- !u!114 &897339006
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4920f47cde1a84b11ad07b7317568494, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 4
errorMessage:
indentLevel: 0
--- !u!114 &897339007
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2dcb71131f45b47fead560a97ef55f1c, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 3
errorMessage:
indentLevel: 0
failMessage:
--- !u!114 &897339008
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 050fb9e6e72f442b3b883da8a965bdeb, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 2
errorMessage:
indentLevel: 0
targetFlowchart: {fileID: 0}
targetBlock: {fileID: 897339009}
commandIndex: 1
callMode: 0
--- !u!114 &897339009
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3}
m_Name:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 243
y: 70
width: 120
height: 40
itemId: 1
blockName: OtherBlock
description:
eventHandler: {fileID: 0}
commandList:
- {fileID: 897339007}
- {fileID: 897339006}
--- !u!114 &897339010
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11462346, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3}
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 897339011}
--- !u!114 &897339011
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3}
m_Name:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 68
y: 70
width: 120
height: 40
itemId: 0
blockName: Start
description:
eventHandler: {fileID: 897339010}
commandList:
- {fileID: 897339008}
--- !u!114 &897339012
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 897339004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 1
scrollPos: {x: 0, y: 0}
variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1
blockViewHeight: 400
zoom: 1
scrollViewRect:
serializedVersion: 2
x: -350
y: -350
width: 1121
height: 869
selectedBlock: {fileID: 0}
selectedCommands: []
variables: []
description: "Test using the call index property to call \na specific command in
a Block"
stepPause: 0
colorCommands: 1
hideComponents: 1
saveSelection: 1
localizationId:
showLineNumbers: 0
hideCommands: []
--- !u!1 &1220080381
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1220080386}
- 20: {fileID: 1220080385}
- 92: {fileID: 1220080384}
- 124: {fileID: 1220080383}
- 81: {fileID: 1220080382}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1220080382
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1220080381}
m_Enabled: 1
--- !u!124 &1220080383
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1220080381}
m_Enabled: 1
--- !u!92 &1220080384
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1220080381}
m_Enabled: 1
--- !u!20 &1220080385
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1220080381}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &1220080386
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1220080381}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &1873336849
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1873336851}
- 114: {fileID: 1873336850}
m_Layer: 0
m_Name: _FungusState
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1873336850
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1873336849}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3}
m_Name:
m_EditorClassIdentifier:
selectedFlowchart: {fileID: 897339012}
--- !u!4 &1873336851
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1873336849}
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: 0}
m_RootOrder: 1

8
Assets/Tests/Flow/FlowTests.unity.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2df8760e0f8d84900a1559096b2c74e4
timeCreated: 1463576406
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save