Browse Source

Merge pull request #365 from FungusGames/wait-input

Added WaitInput contribution #276
master
Chris Gregan 9 years ago
parent
commit
55e716fed0
  1. 186
      Assets/Tests/Scripting/Scripting.unity
  2. 52
      Assets/Tests/Scripting/WaitInput.cs
  3. 12
      Assets/Tests/Scripting/WaitInput.cs.meta

186
Assets/Tests/Scripting/Scripting.unity

@ -85,6 +85,140 @@ NavMeshSettings:
cellSize: 0.16666667
manualCellSize: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &115525217
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 115525218}
- 114: {fileID: 115525223}
- 114: {fileID: 115525222}
- 114: {fileID: 115525221}
- 114: {fileID: 115525220}
- 114: {fileID: 115525219}
m_Layer: 0
m_Name: Flowchart
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &115525218
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 115525217}
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: 676156676}
m_RootOrder: 0
--- !u!114 &115525219
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 115525217}
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 &115525220
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 115525217}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c2531255f7c494d548e7f33daf27dcaf, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 1
errorMessage:
indentLevel: 0
duration: 2
--- !u!114 &115525221
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11462346, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 115525217}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3}
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 115525222}
--- !u!114 &115525222
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 115525217}
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: 115525221}
commandList:
- {fileID: 115525220}
- {fileID: 115525219}
--- !u!114 &115525223
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 115525217}
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: 115525222}
selectedCommands:
- {fileID: 115525219}
variables: []
description:
stepPause: 0
colorCommands: 1
hideComponents: 1
saveSelection: 1
localizationId:
hideCommands: []
--- !u!1 &169310208
GameObject:
m_ObjectHideFlags: 0
@ -1574,7 +1708,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3}
m_Name:
m_EditorClassIdentifier:
selectedFlowchart: {fileID: 491823363}
selectedFlowchart: {fileID: 115525223}
--- !u!4 &646902075
Transform:
m_ObjectHideFlags: 1
@ -1587,6 +1721,56 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &676156674
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 676156676}
- 114: {fileID: 676156675}
m_Layer: 0
m_Name: WaitInput
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &676156675
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 676156674}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b1dba0b27b0864740a8720e920aa88c0, type: 3}
m_Name:
m_EditorClassIdentifier:
timeout: 5
ignored: 0
succeedAfterAllAssertionsAreExecuted: 1
expectException: 0
expectedExceptionList:
succeedWhenExceptionIsThrown: 0
includedPlatforms: -1
platformsToIgnore: []
dynamic: 0
dynamicTypeName:
--- !u!4 &676156676
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 676156674}
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: 115525218}
m_Father: {fileID: 0}
m_RootOrder: 9
--- !u!1 &697320579
GameObject:
m_ObjectHideFlags: 0

52
Assets/Tests/Scripting/WaitInput.cs

@ -0,0 +1,52 @@
using UnityEngine;
using System.Collections;
using Fungus;
[CommandInfo("Flow",
"WaitInput",
"Waits for a period of time or for player input before executing the next command in the block.")]
[AddComponentMenu("")]
public class WaitInput : Command
{
[Tooltip("Duration to wait for. If negative will wait until player input occurs.")]
public float duration = 1;
public override void OnEnter()
{
StartCoroutine( CheckInput() );
}
IEnumerator CheckInput()
{
float timer = 0f;
while (duration < 0f || timer < duration)
{
timer += Time.deltaTime;
if( Input.anyKeyDown || Input.GetMouseButtonDown(0) )
{
break;
}
yield return null;
}
Continue();
}
public override string GetSummary()
{
if( duration <= float.Epsilon )
{
return "Any input";
}
return "Any input, or " + duration.ToString() + " seconds";
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}

12
Assets/Tests/Scripting/WaitInput.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c2531255f7c494d548e7f33daf27dcaf
timeCreated: 1453467088
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save