Browse Source

Merge branch 'master' into dialog-history

master
Chris Gregan 7 years ago
parent
commit
afb666d87d
  1. BIN
      Assets/AssetStoreTools/Editor/AssetStoreTools.dll
  2. 20
      Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta
  3. BIN
      Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll
  4. 20
      Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll.meta
  5. 4
      Assets/AssetStoreTools/Editor/DroidSansMono.ttf.meta
  6. 6
      Assets/AssetStoreTools/Editor/icon.png.meta
  7. 98
      Assets/Fungus/Docs/CHANGELOG.txt
  8. 3
      Assets/Fungus/EditorResources/FungusEditorResources.asset
  9. 3
      Assets/Fungus/EditorResources/FungusEditorResources.asset.meta
  10. BIN
      Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png
  11. 92
      Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png.meta
  12. BIN
      Assets/Fungus/EditorResources/Icons/fungus_mushroom.png
  13. 92
      Assets/Fungus/EditorResources/Icons/fungus_mushroom.png.meta
  14. 9
      Assets/Fungus/Integrations/Playmaker.meta
  15. BIN
      Assets/Fungus/Integrations/Playmaker/Fungus-PlayMaker.unitypackage
  16. 8
      Assets/Fungus/Integrations/Playmaker/Fungus-PlayMaker.unitypackage.meta
  17. 1
      Assets/Fungus/Integrations/Playmaker/ReadMe.txt
  18. 8
      Assets/Fungus/Integrations/Playmaker/ReadMe.txt.meta
  19. 156
      Assets/Fungus/Scripts/Commands/Condition.cs
  20. 17
      Assets/Fungus/Scripts/Commands/Destroy.cs
  21. 49
      Assets/Fungus/Scripts/Commands/ElseIf.cs
  22. 181
      Assets/Fungus/Scripts/Commands/If.cs
  23. 9
      Assets/Fungus/Scripts/Commands/Input.meta
  24. 60
      Assets/Fungus/Scripts/Commands/Input/GetAxis.cs
  25. 12
      Assets/Fungus/Scripts/Commands/Input/GetAxis.cs.meta
  26. 9
      Assets/Fungus/Scripts/Commands/LeanTween.meta
  27. 116
      Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs
  28. 12
      Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs.meta
  29. 55
      Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs
  30. 12
      Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs.meta
  31. 74
      Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs
  32. 12
      Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs.meta
  33. 46
      Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs
  34. 12
      Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs.meta
  35. 47
      Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs
  36. 12
      Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs.meta
  37. 126
      Assets/Fungus/Scripts/Commands/LuaCondition.cs
  38. 12
      Assets/Fungus/Scripts/Commands/LuaCondition.cs.meta
  39. 38
      Assets/Fungus/Scripts/Commands/LuaElseIf.cs
  40. 12
      Assets/Fungus/Scripts/Commands/LuaElseIf.cs.meta
  41. 26
      Assets/Fungus/Scripts/Commands/LuaIf.cs
  42. 12
      Assets/Fungus/Scripts/Commands/LuaIf.cs.meta
  43. 9
      Assets/Fungus/Scripts/Commands/Math.meta
  44. 26
      Assets/Fungus/Scripts/Commands/Math/Abs.cs
  45. 12
      Assets/Fungus/Scripts/Commands/Math/Abs.cs.meta
  46. 25
      Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
  47. 12
      Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs.meta
  48. 66
      Assets/Fungus/Scripts/Commands/Math/Clamp.cs
  49. 12
      Assets/Fungus/Scripts/Commands/Math/Clamp.cs.meta
  50. 29
      Assets/Fungus/Scripts/Commands/Math/Curve.cs
  51. 12
      Assets/Fungus/Scripts/Commands/Math/Curve.cs.meta
  52. 26
      Assets/Fungus/Scripts/Commands/Math/Exp.cs
  53. 12
      Assets/Fungus/Scripts/Commands/Math/Exp.cs.meta
  54. 28
      Assets/Fungus/Scripts/Commands/Math/Inv.cs
  55. 12
      Assets/Fungus/Scripts/Commands/Math/Inv.cs.meta
  56. 46
      Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
  57. 12
      Assets/Fungus/Scripts/Commands/Math/InvLerp.cs.meta
  58. 63
      Assets/Fungus/Scripts/Commands/Math/Lerp.cs
  59. 12
      Assets/Fungus/Scripts/Commands/Math/Lerp.cs.meta
  60. 56
      Assets/Fungus/Scripts/Commands/Math/Log.cs
  61. 12
      Assets/Fungus/Scripts/Commands/Math/Log.cs.meta
  62. 48
      Assets/Fungus/Scripts/Commands/Math/Map.cs
  63. 12
      Assets/Fungus/Scripts/Commands/Math/Map.cs.meta
  64. 61
      Assets/Fungus/Scripts/Commands/Math/MinMax.cs
  65. 12
      Assets/Fungus/Scripts/Commands/Math/MinMax.cs.meta
  66. 26
      Assets/Fungus/Scripts/Commands/Math/Neg.cs
  67. 12
      Assets/Fungus/Scripts/Commands/Math/Neg.cs.meta
  68. 39
      Assets/Fungus/Scripts/Commands/Math/Pow.cs
  69. 12
      Assets/Fungus/Scripts/Commands/Math/Pow.cs.meta
  70. 50
      Assets/Fungus/Scripts/Commands/Math/Round.cs
  71. 12
      Assets/Fungus/Scripts/Commands/Math/Round.cs.meta
  72. 26
      Assets/Fungus/Scripts/Commands/Math/Sign.cs
  73. 12
      Assets/Fungus/Scripts/Commands/Math/Sign.cs.meta
  74. 26
      Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
  75. 12
      Assets/Fungus/Scripts/Commands/Math/Sqrt.cs.meta
  76. 65
      Assets/Fungus/Scripts/Commands/Math/ToInt.cs
  77. 12
      Assets/Fungus/Scripts/Commands/Math/ToInt.cs.meta
  78. 77
      Assets/Fungus/Scripts/Commands/Math/Trig.cs
  79. 12
      Assets/Fungus/Scripts/Commands/Math/Trig.cs.meta
  80. 10
      Assets/Fungus/Scripts/Commands/Menu.cs
  81. 59
      Assets/Fungus/Scripts/Commands/MenuShuffle.cs
  82. 8
      Assets/Fungus/Scripts/Commands/MenuShuffle.cs.meta
  83. 2
      Assets/Fungus/Scripts/Commands/OpenURL.cs
  84. 9
      Assets/Fungus/Scripts/Commands/Property.meta
  85. 9
      Assets/Fungus/Scripts/Commands/Rigidbody2D.meta
  86. 85
      Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs
  87. 12
      Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs.meta
  88. 56
      Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs
  89. 12
      Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs.meta
  90. 69
      Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs
  91. 12
      Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs.meta
  92. 7
      Assets/Fungus/Scripts/Commands/Say.cs
  93. 9
      Assets/Fungus/Scripts/Commands/Scene.meta
  94. 35
      Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs
  95. 12
      Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs.meta
  96. 2
      Assets/Fungus/Scripts/Commands/SetInteractable.cs
  97. 118
      Assets/Fungus/Scripts/Commands/SetVariable.cs
  98. 45
      Assets/Fungus/Scripts/Commands/SpawnObject.cs
  99. 9
      Assets/Fungus/Scripts/Commands/Transform.meta
  100. 217
      Assets/Fungus/Scripts/Commands/Transform/TransformProperty.cs
  101. Some files were not shown because too many files have changed in this diff Show More

BIN
Assets/AssetStoreTools/Editor/AssetStoreTools.dll

Binary file not shown.

20
Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta

@ -1,19 +1,31 @@
fileFormatVersion: 2
guid: f02b3fe0a866fca419671914a860554a
guid: 46975cd389724d0499db55591d961a35
timeCreated: 1499691956
licenseType: Store
PluginImporter:
serializedVersion: 1
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 0
settings: {}
Editor:
data:
first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU

BIN
Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll

Binary file not shown.

20
Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll.meta

@ -1,19 +1,31 @@
fileFormatVersion: 2
guid: 07e97bd03b7bdeb40bbc176326cd8d7a
guid: a4f7ad432f1fed24caa2acbe1ceeef39
timeCreated: 1499692003
licenseType: Store
PluginImporter:
serializedVersion: 1
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
Any:
second:
enabled: 0
settings: {}
Editor:
data:
first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU

4
Assets/AssetStoreTools/Editor/DroidSansMono.ttf.meta

@ -1,5 +1,7 @@
fileFormatVersion: 2
guid: 928f503de488e44408a8625d75d54c61
guid: d54231d61af8b414486b80e17598cce1
timeCreated: 1499692004
licenseType: Store
TrueTypeFontImporter:
serializedVersion: 2
fontSize: 16

6
Assets/AssetStoreTools/Editor/icon.png.meta

@ -1,5 +1,7 @@
fileFormatVersion: 2
guid: 3ef5b3d0acd79c3499f502f1b991678a
guid: 7d783a70b51365a49a04d3f369611b99
timeCreated: 1499692003
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
@ -25,7 +27,7 @@ TextureImporter:
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 1024
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1

98
Assets/Fungus/Docs/CHANGELOG.txt

@ -2,6 +2,104 @@ Changelog {#changelog}
=========
[TOC]
v3.8.0 {#v3_8_0}
======
Many thanks to contributors stevehalliwell, FrederickKDP, MeMark2, KVinS, charblar, FatPuzo for their work on this release!
## Added
- Added Flowchart.HasBlock() and ExecuteIfHasBlock() methods
- Added Global Variable support. Variables have new 'Global' variable scope.
- Added GlobalVar demo scene
## Changed
- Updated project version to Unity 2017.4.0f1
- Refactored the set variable system to make it easier to add variable comparison options
- Added comparison and setting of GameObjects variables
- Updated Batch for newer versions of Unity3D web player #650
## Fixed
- Fixed compile errors in Unity 2018.1 beta
- Fixed compiler warnings in Untity2017.3
- Fixed repeat play of music #659
- Fixed conflicting EditorResource folder issue #664
- Fixed SaveMenu DontDestroyOnLoad problems #661
- Fixed docs: the block name in 6 of "Connections between Blocks" section from "Block2" to "Start" #663
- Fixed lua say() function to match new say method parameters
v3.7.0 {#v3_7_0}
======
Many thanks to maintainer Steve Halliwell for all the amazing new functionality in this release!
## Added
- Added Playground examples showing 3 simple arcade games made using Fungus
- Added Rigidbody2D variable type
- Added Vector3 FungusCommands - Fields, Normalise, Convert to Vector2, Arithetic
- Added TransformProperty FungusCommand. Get and Set a transform's fields and properties. Does not currently support rotation, localRotation nor the Mat4x4 commands as we do not have the appropriate FungusVariables to store them in
- Added FungusCommand to Reload Current Scene
- Added Rigidbody2D FungusCommands - AddForce, AddTorque, StopMotion
- Added Input GetAxis fungusCommand, fetch Input.GetAxis and store in a FloatData
- SpawnObject FungusCommand can now store the gameobject it instantiates and can spawn at itself
- Destroy FungusCommand can now be told to pass down a delay to Destroy
- Added Fungus Commands for most of MathF
- Added Math demo scene
- Added Mouse fungus event demo scene
- Added Monobehaviour fungus event handlers and physics demo scene
- Added LeanTween commands and demo scene that approximates the old iTween demo
- Added SpeakingCharacter property to SayDialog
- Added Fungus panel in editor preferences
- Added option to toggle off the fungus icon in the hierarchy in case it conflicts with other tools or is just undesired
- Added TextTag WVO WaitForVoiceOver #572
- Added ability to show variable list in the Flowchart Inspector #643
- OpenURL FungusCommand renamed, fixes #554 #642
## Changed
- SaveManager now uses json files in a FungusSaves sub directory for all platforms but webplayer & webgl which still use playerprefs
- GetCommandInfo returns the highest priority CommandInfo to better support multiple names while maintaining what is shown in the inspector
- Allow multiple CommandInfos to be added to a class SpawnObject can now also be found under GameObject/Instantiate
- Changed Fungus icon loading to use FungusEditorResources
## Fixed
- Fixed typo in BlockEditor.BlockField() #633
- Fixed custom editor for ElseIf command #630
- Fixed Prefab Variable Dereferencing #618
- Fixed typo in Set Interactable description #647
- Fixed choice dialogues were not set to stay during the MenuDialogue #640
- Fixed camera fading and panning at the same time (thanks to iBicha!) #624
- Fixed warnings on Unity 2017.2
v3.6.0 {#v3_6_0}
======
## Added
- Support use of \n newline character in Say and Conversation text
- Added Fungus-Playmaker integration package in Fungus/Integrations/PlayMaker #602 - thanks Nilihum
- Added Delete Save Data button to Save Menu inspector.
- Variable substitution works in Set Variable (String) command
- New "BlockNameAndCustom" Keymode for Save Point command, use both block name and custom key together. #597 - thanks Trieger
- Added portrait DimColor #601 - thanks MorningFunGame
- Lua If and Lua Else If commands #609 - thanks PillowFightIo
- Stop a named Block in a Flowchart
- Added utility to convert all files to Mac line endings
## Changed
- Made all methods virtual in SayDialog.cs #607 thanks PillowFightIo
- Updated project to Unity 5.6.1, fixed some warnings.
- Use transform.Find instead of deprecated transform.FindChild
- Replaced some uses of slow GameObject.FindObjectOfType() and FindDerivedTypes()
## Fixed
- Fixed Write command "Clear Text" option not working #594
- Fixed portrait hide bug in conversation #590 - thanks to lealeelu
- Fixed stopping audio in conversation #592 - thanks to lealeelu
- Fixed can't use FungusLua separately to rest of Fungus #596
- Fixed can't inspect disabled Flowchart #598
- Fixed Cmd+Left Click doesn't register as right click on OSX #595
- Fixed luautils won't work on FungusLua standalone #604
- Fixed Save Menu: clicking to left of collapsed menu clicks hidden buttons #615
- Fixed Localization only localizes character name, not story text #611, #614
v3.5.1 {#v3_5_1}
======

3
Assets/Fungus/EditorResources/FungusEditorResources.asset

@ -27,6 +27,9 @@ MonoBehaviour:
duplicate:
free: {fileID: 2800000, guid: c97f334c466215a4f93eff31de3c1591, type: 3}
pro: {fileID: 2800000, guid: 2f17490d993c84bd7872ef6588ffba47, type: 3}
fungus_mushroom:
free: {fileID: 2800000, guid: 1c99c9bf7557e23469ed5dfce00504c0, type: 3}
pro: {fileID: 2800000, guid: 6368c1c16ebb1694091262337e4f8c44, type: 3}
up:
free: {fileID: 2800000, guid: 8f1242ad894201f43b2b6d52fd990f77, type: 3}
pro: {fileID: 2800000, guid: 2a76a781db2994b33b83cd84b8835da7, type: 3}

3
Assets/Fungus/EditorResources/FungusEditorResources.asset.meta

@ -1,8 +1,9 @@
fileFormatVersion: 2
guid: 29cae11326cb84802b83fc3ff25a47e8
timeCreated: 1478978272
timeCreated: 1495441032
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

92
Assets/Fungus/EditorResources/Icons/Pro/fungus_mushroom.png.meta

@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: 6368c1c16ebb1694091262337e4f8c44
timeCreated: 1500456217
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: 1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Fungus/EditorResources/Icons/fungus_mushroom.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

92
Assets/Fungus/EditorResources/Icons/fungus_mushroom.png.meta

@ -0,0 +1,92 @@
fileFormatVersion: 2
guid: 1c99c9bf7557e23469ed5dfce00504c0
timeCreated: 1500455974
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: 1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 1024
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Fungus/Integrations/Playmaker.meta

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

BIN
Assets/Fungus/Integrations/Playmaker/Fungus-PlayMaker.unitypackage

Binary file not shown.

8
Assets/Fungus/Integrations/Playmaker/Fungus-PlayMaker.unitypackage.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 81dbcde0f90df4e9ba9ca2794490e57a
timeCreated: 1491251885
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

1
Assets/Fungus/Integrations/Playmaker/ReadMe.txt

@ -22,3 +22,4 @@ To write Playmaker variable values to Fungus Variables, use the Action Browser >
To execute a block in a Fungus flowchart from , use the Action Browser > ScriptControl > Playmaker Execute Block command.
To trigger a global state transition in Playmaker from Fungus, use the Playmaker > Global State Transition command.
To read Fungus variable values into Playmaker Variables, use the Action Browser > ScriptControl > Receive Fungus Variable command.
To write Fungus variable values from the inspector into Playmaker global variables, use the Playmaker > Write To Playmaker command.

8
Assets/Fungus/Integrations/Playmaker/ReadMe.txt.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1cd4689522982464db8b5de6a590db9b
timeCreated: 1491251886
licenseType: Free
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

156
Assets/Fungus/Scripts/Commands/Condition.cs

@ -8,11 +8,6 @@ namespace Fungus
[AddComponentMenu("")]
public abstract class Condition : Command
{
[Tooltip("The type of comparison to be performed")]
[SerializeField] protected CompareOperator compareOperator;
#region Public members
public static string GetOperatorDescription(CompareOperator compareOperator)
{
string summary = "";
@ -41,6 +36,157 @@ namespace Fungus
return summary;
}
#region Public members
public override void OnEnter()
{
if (ParentBlock == null)
{
return;
}
if( !HasNeededProperties() )
{
Continue();
return;
}
if( !this.IsElseIf )
{
EvaluateAndContinue();
}
else
{
System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();
if (previousCommandType.IsSubclassOf(typeof(Condition)))
{
// Else If behaves the same as an If command
EvaluateAndContinue();
}
else
{
// Else If behaves mostly like an Else command,
// but will also jump to a following Else command.
// Stop if this is the last command in the list
if (CommandIndex >= ParentBlock.CommandList.Count - 1)
{
StopParentBlock();
return;
}
// Find the next End command at the same indent level as this Else If command
int indent = indentLevel;
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
var command = ParentBlock.CommandList[i];
if (command.IndentLevel == indent)
{
System.Type type = command.GetType();
if (type == typeof(End))
{
// Execute command immediately after the Else or End command
Continue(command.CommandIndex + 1);
return;
}
}
}
// No End command found
StopParentBlock();
}
}
}
public override bool OpenBlock()
{
return true;
}
#endregion
protected virtual void EvaluateAndContinue()
{
if (EvaluateCondition())
{
OnTrue();
}
else
{
OnFalse();
}
}
protected virtual void OnTrue()
{
Continue();
}
protected virtual void OnFalse()
{
// Last command in block
if (CommandIndex >= ParentBlock.CommandList.Count)
{
StopParentBlock();
return;
}
// Find the next Else, ElseIf or End command at the same indent level as this If command
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
Command nextCommand = ParentBlock.CommandList[i];
if (nextCommand == null)
{
continue;
}
// Find next command at same indent level as this If command
// Skip disabled commands, comments & labels
if (!((Command)nextCommand).enabled ||
nextCommand.GetType() == typeof(Comment) ||
nextCommand.GetType() == typeof(Label) ||
nextCommand.IndentLevel != indentLevel)
{
continue;
}
System.Type type = nextCommand.GetType();
if (type == typeof(Else) ||
type == typeof(End))
{
if (i >= ParentBlock.CommandList.Count - 1)
{
// Last command in Block, so stop
StopParentBlock();
}
else
{
// Execute command immediately after the Else or End command
Continue(nextCommand.CommandIndex + 1);
return;
}
}
else if (type.IsSubclassOf(typeof(Condition)) && (nextCommand as Condition).IsElseIf)
{
// Execute the Else If command
Continue(i);
return;
}
}
// No matching End command found, so just stop the block
StopParentBlock();
}
protected abstract bool EvaluateCondition();
protected abstract bool HasNeededProperties();
protected virtual bool IsElseIf { get { return false; } }
}
}

17
Assets/Fungus/Scripts/Commands/Destroy.cs

@ -19,12 +19,19 @@ namespace Fungus
[Tooltip("Reference to game object to destroy")]
[SerializeField] protected GameObjectData _targetGameObject;
[Tooltip("Optional delay given to destroy")]
[SerializeField]
protected FloatData destroyInXSeconds = new FloatData(0);
#region Public members
public override void OnEnter()
{
if (_targetGameObject.Value != null)
{
if (destroyInXSeconds.Value != 0)
Destroy(_targetGameObject, destroyInXSeconds.Value);
else
Destroy(_targetGameObject.Value);
}
@ -38,7 +45,7 @@ namespace Fungus
return "Error: No game object selected";
}
return _targetGameObject.Value.name;
return _targetGameObject.Value.name + (destroyInXSeconds.Value == 0 ? "" : " in " + destroyInXSeconds.Value.ToString());
}
public override Color GetButtonColor()
@ -46,6 +53,14 @@ namespace Fungus
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (_targetGameObject.gameObjectRef == variable || destroyInXSeconds.floatRef == variable)
return true;
return false;
}
#endregion
#region Backwards compatibility

49
Assets/Fungus/Scripts/Commands/ElseIf.cs

@ -12,54 +12,11 @@ namespace Fungus
"Else If",
"Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.")]
[AddComponentMenu("")]
public class ElseIf : If
public class ElseIf : VariableCondition
{
#region Public members
public override void OnEnter()
{
System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();
protected override bool IsElseIf { get { return true; } }
if (previousCommandType == typeof(If) ||
previousCommandType == typeof(ElseIf) )
{
// Else If behaves the same as an If command
EvaluateAndContinue();
}
else
{
// Else If behaves mostly like an Else command,
// but will also jump to a following Else command.
// Stop if this is the last command in the list
if (CommandIndex >= ParentBlock.CommandList.Count - 1)
{
StopParentBlock();
return;
}
// Find the next End command at the same indent level as this Else If command
int indent = indentLevel;
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
var command = ParentBlock.CommandList[i];
if (command.IndentLevel == indent)
{
System.Type type = command.GetType();
if (type == typeof(End))
{
// Execute command immediately after the Else or End command
Continue(command.CommandIndex + 1);
return;
}
}
}
// No End command found
StopParentBlock();
}
}
#region Public members
public override bool OpenBlock()
{

181
Assets/Fungus/Scripts/Commands/If.cs

@ -12,189 +12,10 @@ namespace Fungus
"If",
"If the test expression is true, execute the following command block.")]
[AddComponentMenu("")]
public class If : Condition
public class If : VariableCondition
{
[Tooltip("Variable to use in expression")]
[VariableProperty(typeof(BooleanVariable),
typeof(IntegerVariable),
typeof(FloatVariable),
typeof(StringVariable))]
[SerializeField] protected Variable variable;
[Tooltip("Boolean value to compare against")]
[SerializeField] protected BooleanData booleanData;
[Tooltip("Integer value to compare against")]
[SerializeField] protected IntegerData integerData;
[Tooltip("Float value to compare against")]
[SerializeField] protected FloatData floatData;
[Tooltip("String value to compare against")]
[SerializeField] protected StringDataMulti stringData;
protected virtual void EvaluateAndContinue()
{
if (EvaluateCondition())
{
OnTrue();
}
else
{
OnFalse();
}
}
protected virtual void OnTrue()
{
Continue();
}
protected virtual void OnFalse()
{
// Last command in block
if (CommandIndex >= ParentBlock.CommandList.Count)
{
StopParentBlock();
return;
}
// Find the next Else, ElseIf or End command at the same indent level as this If command
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
Command nextCommand = ParentBlock.CommandList[i];
if (nextCommand == null)
{
continue;
}
// Find next command at same indent level as this If command
// Skip disabled commands, comments & labels
if (!((Command)nextCommand).enabled ||
nextCommand.GetType() == typeof(Comment) ||
nextCommand.GetType() == typeof(Label) ||
nextCommand.IndentLevel != indentLevel)
{
continue;
}
System.Type type = nextCommand.GetType();
if (type == typeof(Else) ||
type == typeof(End))
{
if (i >= ParentBlock.CommandList.Count - 1)
{
// Last command in Block, so stop
StopParentBlock();
}
else
{
// Execute command immediately after the Else or End command
Continue(nextCommand.CommandIndex + 1);
return;
}
}
else if (type == typeof(ElseIf))
{
// Execute the Else If command
Continue(i);
return;
}
}
// No matching End command found, so just stop the block
StopParentBlock();
}
protected virtual bool EvaluateCondition()
{
BooleanVariable booleanVariable = variable as BooleanVariable;
IntegerVariable integerVariable = variable as IntegerVariable;
FloatVariable floatVariable = variable as FloatVariable;
StringVariable stringVariable = variable as StringVariable;
bool condition = false;
if (booleanVariable != null)
{
condition = booleanVariable.Evaluate(compareOperator, booleanData.Value);
}
else if (integerVariable != null)
{
condition = integerVariable.Evaluate(compareOperator, integerData.Value);
}
else if (floatVariable != null)
{
condition = floatVariable.Evaluate(compareOperator, floatData.Value);
}
else if (stringVariable != null)
{
condition = stringVariable.Evaluate(compareOperator, stringData.Value);
}
return condition;
}
#region Public members
public override void OnEnter()
{
if (ParentBlock == null)
{
return;
}
if (variable == null)
{
Continue();
return;
}
EvaluateAndContinue();
}
public override string GetSummary()
{
if (variable == null)
{
return "Error: No variable selected";
}
string summary = variable.Key + " ";
summary += Condition.GetOperatorDescription(compareOperator) + " ";
if (variable.GetType() == typeof(BooleanVariable))
{
summary += booleanData.GetDescription();
}
else if (variable.GetType() == typeof(IntegerVariable))
{
summary += integerData.GetDescription();
}
else if (variable.GetType() == typeof(FloatVariable))
{
summary += floatData.GetDescription();
}
else if (variable.GetType() == typeof(StringVariable))
{
summary += stringData.GetDescription();
}
return summary;
}
public override bool HasReference(Variable variable)
{
return (variable == this.variable);
}
public override bool OpenBlock()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);

9
Assets/Fungus/Scripts/Commands/Input.meta

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

60
Assets/Fungus/Scripts/Commands/Input/GetAxis.cs

@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fungus
{
// <summary>
/// Store Input.GetAxis in a variable
/// </summary>
[CommandInfo("Input",
"GetAxis",
"Store Input.GetAxis in a variable")]
[AddComponentMenu("")]
public class GetAxis : Command
{
[SerializeField]
protected StringData axisName;
[Tooltip("If true, calls GetAxisRaw instead of GetAxis")]
[SerializeField]
protected bool axisRaw = false;
[Tooltip("Float to store the value of the GetAxis")]
[SerializeField]
protected FloatData outValue;
public override void OnEnter()
{
if (axisRaw)
{
outValue.Value = Input.GetAxisRaw(axisName.Value);
}
else
{
outValue.Value = Input.GetAxis(axisName.Value);
}
Continue();
}
public override string GetSummary()
{
return axisName + (axisRaw ? " Raw" : "");
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (axisName.stringRef == variable || outValue.floatRef == variable)
return true;
return false;
}
}
}

12
Assets/Fungus/Scripts/Commands/Input/GetAxis.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bb18ee740f55ba24680c15466ff13ece
timeCreated: 1503744409
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Fungus/Scripts/Commands/LeanTween.meta

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

116
Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs

@ -0,0 +1,116 @@
using UnityEngine;
using UnityEngine.Serialization;
namespace Fungus
{
/// <summary>
/// Abstract base class for LeanTween commands.
/// </summary>
[ExecuteInEditMode]
public abstract class BaseLeanTweenCommand : Command
{
[Tooltip("Target game object to apply the Tween to")]
[SerializeField]
protected GameObjectData _targetObject;
[Tooltip("The time in seconds the animation will take to complete")]
[SerializeField]
protected FloatData _duration = new FloatData(1f);
public enum ToFrom { To, From }
[Tooltip("Does the tween act from current TO destination or is it reversed and act FROM destination to its current")]
[SerializeField]
protected ToFrom _toFrom;
public bool IsInFromMode { get { return _toFrom == ToFrom.From; } }
public enum AbsAdd { Absolute, Additive }
[Tooltip("Does the tween use the value as a target or as a delta to be added to current.")]
[SerializeField]
protected AbsAdd _absAdd;
public bool IsInAddativeMode { get { return _absAdd == AbsAdd.Additive; } }
[Tooltip("The shape of the easing curve applied to the animation")]
[SerializeField]
protected LeanTweenType easeType = LeanTweenType.easeInOutQuad;
[Tooltip("The type of loop to apply once the animation has completed")]
[SerializeField]
protected LeanTweenType loopType = LeanTweenType.once;
[Tooltip("Number of times to repeat the tween, -1 is infinite.")]
[SerializeField]
protected int repeats = 0;
[Tooltip("Stop any previously LeanTweens on this object before adding this one. Warning; expensive.")]
[SerializeField]
protected bool stopPreviousTweens = false;
[Tooltip("Wait until the tween has finished before executing the next command")]
[SerializeField]
protected bool waitUntilFinished = true;
[HideInInspector] protected LTDescr ourTween;
protected virtual void OnTweenComplete()
{
Continue();
}
#region Public members
public override void OnEnter()
{
if (_targetObject.Value == null)
{
Continue();
return;
}
if (stopPreviousTweens)
{
LeanTween.cancel(_targetObject.Value);
}
ourTween = ExecuteTween();
ourTween.setEase(easeType)
.setRepeat(repeats)
.setLoopType(loopType);
if (waitUntilFinished)
{
if(ourTween != null)
{
ourTween.setOnComplete(OnTweenComplete);
}
}
else
{
Continue();
}
}
public abstract LTDescr ExecuteTween();
public override string GetSummary()
{
if (_targetObject.Value == null)
{
return "Error: No target object selected";
}
return _targetObject.Value.name + " over " + _duration.Value + " seconds";
}
public override Color GetButtonColor()
{
return new Color32(233, 163, 180, 255);
}
#endregion
}
}

12
Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 22379d19093ceb34098232d6f1b848a0
timeCreated: 1499564933
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

55
Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs

@ -0,0 +1,55 @@

using UnityEngine;
using UnityEngine.Serialization;
using System.Collections;
using System;
namespace Fungus
{
/// <summary>
/// Moves a game object to a specified position over time. The position can be defined by a transform in another object (using To Transform) or by setting an absolute position (using To Position, if To Transform is set to None).
/// </summary>
[CommandInfo("LeanTween",
"Move",
"Moves a game object to a specified position over time. The position can be defined by a transform in another object (using To Transform) or by setting an absolute position (using To Position, if To Transform is set to None).")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class MoveLean : BaseLeanTweenCommand
{
[Tooltip("Target transform that the GameObject will move to")]
[SerializeField]
protected TransformData _toTransform;
[Tooltip("Target world position that the GameObject will move to, if no From Transform is set")]
[SerializeField]
protected Vector3Data _toPosition;
[Tooltip("Whether to animate in world space or relative to the parent. False by default.")]
[SerializeField]
protected bool isLocal;
public override LTDescr ExecuteTween()
{
var loc = _toTransform.Value == null ? _toPosition.Value : _toTransform.Value.position;
if(IsInAddativeMode)
{
loc += _targetObject.Value.transform.position;
}
if(IsInFromMode)
{
var cur = _targetObject.Value.transform.position;
_targetObject.Value.transform.position = loc;
loc = cur;
}
if (isLocal)
return LeanTween.moveLocal(_targetObject.Value, loc, _duration);
else
return LeanTween.move(_targetObject.Value, loc, _duration);
}
}
}

12
Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3ca31fffe1be42a49b96bbb8b7ff5a50
timeCreated: 1499566229
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

74
Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs

@ -0,0 +1,74 @@

using UnityEngine;
using UnityEngine.Serialization;
using System.Collections;
using System;
namespace Fungus
{
/// <summary>
/// Rotates a game object to the specified angles over time.
/// </summary>
[CommandInfo("LeanTween",
"Rotate",
"Rotates a game object to the specified angles over time.")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class RotateLean : BaseLeanTweenCommand
{
[Tooltip("Target transform that the GameObject will rotate to")]
[SerializeField]
protected TransformData _toTransform;
[Tooltip("Target rotation that the GameObject will rotate to, if no To Transform is set")]
[SerializeField]
protected Vector3Data _toRotation;
[Tooltip("Whether to animate in world space or relative to the parent. False by default.")]
[SerializeField]
protected bool isLocal;
public enum RotateMode { PureRotate, LookAt2D, LookAt3D}
[Tooltip("Whether to use the provided Transform or Vector as a target to look at rather than a euler to match.")]
[SerializeField]
protected RotateMode rotateMode = RotateMode.PureRotate;
public override LTDescr ExecuteTween()
{
var rot = _toTransform.Value == null ? _toRotation.Value : _toTransform.Value.rotation.eulerAngles;
if(rotateMode == RotateMode.LookAt3D)
{
var pos = _toTransform.Value == null ? _toRotation.Value : _toTransform.Value.position;
var dif = pos - _targetObject.Value.transform.position;
rot = Quaternion.LookRotation(dif.normalized).eulerAngles;
}
else if(rotateMode == RotateMode.LookAt2D)
{
var pos = _toTransform.Value == null ? _toRotation.Value : _toTransform.Value.position;
var dif = pos - _targetObject.Value.transform.position;
dif.z = 0;
rot = Quaternion.FromToRotation(_targetObject.Value.transform.up, dif.normalized).eulerAngles;
}
if (IsInAddativeMode)
{
rot += _targetObject.Value.transform.rotation.eulerAngles;
}
if (IsInFromMode)
{
var cur = _targetObject.Value.transform.rotation.eulerAngles;
_targetObject.Value.transform.rotation = Quaternion.Euler(rot);
rot = cur;
}
if (isLocal)
return LeanTween.rotateLocal(_targetObject.Value, rot, _duration);
else
return LeanTween.rotate(_targetObject.Value, rot, _duration);
}
}
}

12
Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b8feaa22bae049c43a1c6dfe095c498c
timeCreated: 1499583595
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

46
Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs

@ -0,0 +1,46 @@

using UnityEngine;
using UnityEngine.Serialization;
using System.Collections;
using System;
namespace Fungus
{
/// <summary>
/// Changes a game object's scale to a specified value over time.
/// </summary>
[CommandInfo("LeanTween",
"Scale",
"Changes a game object's scale to a specified value over time.")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class ScaleLean : BaseLeanTweenCommand
{
[Tooltip("Target transform that the GameObject will scale to")]
[SerializeField]
protected TransformData _toTransform;
[Tooltip("Target scale that the GameObject will scale to, if no To Transform is set")]
[SerializeField]
protected Vector3Data _toScale = new Vector3Data(Vector3.one);
public override LTDescr ExecuteTween()
{
var sc = _toTransform.Value == null ? _toScale.Value : _toTransform.Value.localScale;
if (IsInAddativeMode)
{
sc += _targetObject.Value.transform.localScale;
}
if (IsInFromMode)
{
var cur = _targetObject.Value.transform.localScale;
_targetObject.Value.transform.localScale = sc;
sc = cur;
}
return LeanTween.scale(_targetObject.Value, sc, _duration);
}
}
}

12
Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 30cbb61ab588b1a4093d2ef0254045b0
timeCreated: 1499585056
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs

@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fungus
{
/// <summary>
///
/// </summary>
[CommandInfo("LeanTween",
"StopTweens",
"Stops the LeanTweens on a target GameObject")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class StopTweensLean : Command
{
[Tooltip("Target game object stop LeanTweens on")]
[SerializeField]
protected GameObjectData _targetObject;
public override void OnEnter()
{
if (_targetObject.Value != null)
{
LeanTween.cancel(_targetObject.Value);
}
Continue();
}
public override string GetSummary()
{
if (_targetObject.Value == null)
{
return "Error: No target object selected";
}
return "Stop all LeanTweens on " + _targetObject.Value.name;
}
public override Color GetButtonColor()
{
return new Color32(233, 163, 180, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d998218fa600bac43adbc431e9dd6c0c
timeCreated: 1499761355
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

126
Assets/Fungus/Scripts/Commands/LuaCondition.cs

@ -0,0 +1,126 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Fungus;
using MoonSharp.Interpreter;
namespace Fungus
{
public class LuaCondition : Condition
{
[Tooltip("Lua Environment to use to execute this Lua script (null for global)")]
[SerializeField] protected LuaEnvironment luaEnvironment;
[Tooltip("The lua comparison string to run; implicitly prepends 'return' onto this")]
[TextArea]
public string luaCompareString;
protected bool initialised;
protected string friendlyName = "";
protected Closure luaFunction;
protected override bool EvaluateCondition()
{
bool condition = false;
luaEnvironment.RunLuaFunction(luaFunction, false, (returnValue) => {
if( returnValue != null )
{
condition = returnValue.Boolean;
}
else
{
Debug.LogWarning("No return value from " + friendlyName);
}
});
return condition;
}
protected override bool HasNeededProperties()
{
return !string.IsNullOrEmpty(luaCompareString);
}
protected virtual void Start()
{
InitExecuteLua();
}
protected virtual string GetLuaString()
{
return "return not not (" + luaCompareString + ")";
}
/// <summary>
/// Initialises the Lua environment and compiles the Lua string for execution later on.
/// </summary>
protected virtual void InitExecuteLua()
{
if (initialised)
{
return;
}
// Cache a descriptive name to use in Lua error messages
friendlyName = gameObject.name + "." + ParentBlock.BlockName + "." + this.GetType().ToString() + " #" + CommandIndex.ToString();
Flowchart flowchart = GetFlowchart();
// See if a Lua Environment has been assigned to this Flowchart
if (luaEnvironment == null)
{
luaEnvironment = flowchart.LuaEnv;
}
// No Lua Environment specified so just use any available or create one.
if (luaEnvironment == null)
{
luaEnvironment = LuaEnvironment.GetLua();
}
string s = GetLuaString();
luaFunction = luaEnvironment.LoadLuaFunction(s, friendlyName);
// Add a binding to the parent flowchart
if (flowchart.LuaBindingName != "")
{
Table globals = luaEnvironment.Interpreter.Globals;
if (globals != null)
{
globals[flowchart.LuaBindingName] = flowchart;
}
}
// Always initialise when playing in the editor.
// Allows the user to edit the Lua script while the game is playing.
if ( !(Application.isPlaying && Application.isEditor) )
{
initialised = true;
}
}
#region Public members
public override string GetSummary()
{
if (string.IsNullOrEmpty(luaCompareString))
{
return "Error: no lua compare string provided";
}
return luaCompareString;
}
public override bool OpenBlock()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

12
Assets/Fungus/Scripts/Commands/LuaCondition.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 75ddfadd68d3d4713803a6b170cb0b51
timeCreated: 1493078204
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

38
Assets/Fungus/Scripts/Commands/LuaElseIf.cs

@ -0,0 +1,38 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.
/// </summary>
[CommandInfo("Flow",
"Lua Else If",
"Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.")]
[AddComponentMenu("")]
public class LuaElseIf : LuaCondition
{
protected override bool IsElseIf { get { return true; } }
#region Public members
public override bool OpenBlock()
{
return true;
}
public override bool CloseBlock()
{
return true;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

12
Assets/Fungus/Scripts/Commands/LuaElseIf.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9739de3269e5246b399e3a1cd41b94de
timeCreated: 1493078204
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/LuaIf.cs

@ -0,0 +1,26 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// If the test expression is true, execute the following command block.
/// </summary>
[CommandInfo("Flow",
"Lua If",
"If the test expression is true, execute the following command block.")]
[AddComponentMenu("")]
public class LuaIf : LuaCondition
{
#region Public members
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
#endregion
}
}

12
Assets/Fungus/Scripts/Commands/LuaIf.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a8d396bcbf372485cad471c0bb64bb44
timeCreated: 1493078204
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/Fungus/Scripts/Commands/Math.meta

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

26
Assets/Fungus/Scripts/Commands/Math/Abs.cs

@ -0,0 +1,26 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of a Abs
/// </summary>
[CommandInfo("Math",
"Abs",
"Command to execute and store the result of a Abs")]
[AddComponentMenu("")]
public class Abs : BaseUnaryMathCommand
{
public override void OnEnter()
{
outValue.Value = Mathf.Abs(inValue.Value);
Continue();
}
public override string GetSummary()
{
return "Abs";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Abs.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6d11e978db36df445816ec2535d381ce
timeCreated: 1501211592
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

25
Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs

@ -0,0 +1,25 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Base class for all simple Unary
/// </summary>
[AddComponentMenu("")]
public abstract class BaseUnaryMathCommand : Command
{
[Tooltip("Value to be passed in to the function.")]
[SerializeField]
protected FloatData inValue;
[Tooltip("Where the result of the function is stored.")]
[SerializeField]
protected FloatData outValue;
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 513a02811ba512d4ab54d157a15ae8c2
timeCreated: 1501211592
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

66
Assets/Fungus/Scripts/Commands/Math/Clamp.cs

@ -0,0 +1,66 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to contain a value between a lower and upper bound, with optional wrapping modes
/// </summary>
[CommandInfo("Math",
"Clamp",
"Command to contain a value between a lower and upper bound, with optional wrapping modes")]
[AddComponentMenu("")]
public class Clamp : Command
{
public enum Mode
{
Clamp,
Repeat,
PingPong
}
[SerializeField]
protected Mode mode = Mode.Clamp;
//[Tooltip("LHS Value ")]
[SerializeField]
protected FloatData lower, upper, value;
[Tooltip("Result put here, if using pingpong don't use the same var for value as outValue.")]
[SerializeField]
protected FloatData outValue;
public override void OnEnter()
{
var l = lower.Value;
var u = upper.Value;
var v = value.Value;
switch (mode)
{
case Mode.Clamp:
outValue.Value = Mathf.Clamp(value.Value, lower.Value, upper.Value);
break;
case Mode.Repeat:
outValue.Value = (Mathf.Repeat(v - l, u - l)) + l;
break;
case Mode.PingPong:
outValue.Value = (Mathf.PingPong(v - l, u - l)) + l;
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return Mode.Clamp.ToString() + (mode != Mode.Clamp ? " & " + mode.ToString() : "");
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Clamp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2929f1e90a24b6446a70d27316cff20a
timeCreated: 1501225403
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

29
Assets/Fungus/Scripts/Commands/Math/Curve.cs

@ -0,0 +1,29 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Pass a value through an AnimationCurve
/// </summary>
[CommandInfo("Math",
"Curve",
"Pass a value through an AnimationCurve")]
[AddComponentMenu("")]
public class Curve : BaseUnaryMathCommand
{
[SerializeField]
protected AnimationCurve curve = AnimationCurve.Linear(0, 0, 1, 1);
public override void OnEnter()
{
outValue.Value = curve.Evaluate(inValue.Value);
Continue();
}
public override string GetSummary()
{
return "Curve";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Curve.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c03f48fc50d3747478ad85653a21a5f5
timeCreated: 1501226831
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Exp.cs

@ -0,0 +1,26 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of a Exp
/// </summary>
[CommandInfo("Math",
"Exp",
"Command to execute and store the result of a Exp")]
[AddComponentMenu("")]
public class Exp : BaseUnaryMathCommand
{
public override void OnEnter()
{
outValue.Value = Mathf.Exp(inValue.Value);
Continue();
}
public override string GetSummary()
{
return "Exp";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Exp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f28df8ed8a80fa345b3b5e3dcacdea65
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

28
Assets/Fungus/Scripts/Commands/Math/Inv.cs

@ -0,0 +1,28 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Multiplicative Inverse of a float (1/f)
/// </summary>
[CommandInfo("Math",
"Inverse",
"Multiplicative Inverse of a float (1/f)")]
[AddComponentMenu("")]
public class Inv : BaseUnaryMathCommand
{
public override void OnEnter()
{
var v = inValue.Value;
outValue.Value = v != 0 ? (1.0f / inValue.Value) : 0.0f;
Continue();
}
public override string GetSummary()
{
return "Inverse 1/f";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Inv.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 36d3a877e83b1d1478f1ac099414d17a
timeCreated: 1501213679
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

46
Assets/Fungus/Scripts/Commands/Math/InvLerp.cs

@ -0,0 +1,46 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Calculates the inverse lerp, the percentage a value is between two others.
/// </summary>
[CommandInfo("Math",
"InvLerp",
"Calculates the inverse lerp, the percentage a value is between two others.")]
[AddComponentMenu("")]
public class InvLerp : Command
{
[Tooltip("Clamp percentage to 0-1?")]
[SerializeField]
protected bool clampResult = true;
//[Tooltip("LHS Value ")]
[SerializeField]
protected FloatData a, b, value;
//[Tooltip("Where the result of the function is stored.")]
[SerializeField]
protected FloatData outValue;
public override void OnEnter()
{
if (clampResult)
outValue.Value = Mathf.InverseLerp(a.Value, b.Value, value.Value);
else
outValue.Value = (value.Value - a.Value) / (b.Value - a.Value);
Continue();
}
public override string GetSummary()
{
return "InvLerp [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/InvLerp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 80c88869f66a81f4b95e843c36724e65
timeCreated: 1501213063
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

63
Assets/Fungus/Scripts/Commands/Math/Lerp.cs

@ -0,0 +1,63 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Linearly Interpolate from A to B
/// </summary>
[CommandInfo("Math",
"Lerp",
"Linearly Interpolate from A to B")]
[AddComponentMenu("")]
public class Lerp : Command
{
public enum Mode
{
Lerp,
LerpUnclamped,
LerpAngle
}
[SerializeField]
protected Mode mode = Mode.Lerp;
//[Tooltip("LHS Value ")]
[SerializeField]
protected FloatData a = new FloatData(0), b = new FloatData(1), percentage;
//[Tooltip("Where the result of the function is stored.")]
[SerializeField]
protected FloatData outValue;
public override void OnEnter()
{
switch (mode)
{
case Mode.Lerp:
outValue.Value = Mathf.Lerp(a.Value, b.Value, percentage.Value);
break;
case Mode.LerpUnclamped:
outValue.Value = Mathf.LerpUnclamped(a.Value, b.Value, percentage.Value);
break;
case Mode.LerpAngle:
outValue.Value = Mathf.LerpAngle(a.Value, b.Value, percentage.Value);
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return mode.ToString() + " [" + a.Value.ToString() + "-" + b.Value.ToString() + "]";
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Lerp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b44d8d3a71d3e7b45a89437c8f84e687
timeCreated: 1501212773
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

56
Assets/Fungus/Scripts/Commands/Math/Log.cs

@ -0,0 +1,56 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of a Log
/// </summary>
[CommandInfo("Math",
"Log",
"Command to execute and store the result of a Log")]
[AddComponentMenu("")]
public class Log : BaseUnaryMathCommand
{
public enum Mode
{
Base10,
Natural
}
[Tooltip("Which log to use, natural or base 10")]
[SerializeField]
protected Mode mode = Mode.Natural;
public override void OnEnter()
{
switch (mode)
{
case Mode.Base10:
outValue.Value = Mathf.Log10(inValue.Value);
break;
case Mode.Natural:
outValue.Value = Mathf.Log(inValue.Value);
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
switch (mode)
{
case Mode.Base10:
return "Log Base 10";
case Mode.Natural:
return "Natural Log";
default:
break;
}
return "Log";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Log.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 47ecda391b679d8449893d4466f41b13
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

48
Assets/Fungus/Scripts/Commands/Math/Map.cs

@ -0,0 +1,48 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Map a value that exists in 1 range of numbers to another.
/// </summary>
[CommandInfo("Math",
"Map",
"Map a value that exists in 1 range of numbers to another.")]
[AddComponentMenu("")]
public class Map : Command
{
//[Tooltip("LHS Value ")]
[SerializeField]
protected FloatData initialRangeLower = new FloatData(0), initialRangeUpper = new FloatData(1), value;
[SerializeField]
protected FloatData newRangeLower = new FloatData(0), newRangeUpper = new FloatData(1);
[SerializeField]
protected FloatData outValue;
public override void OnEnter()
{
var p = value.Value - initialRangeLower.Value;
p /= initialRangeUpper.Value - initialRangeLower.Value;
var res = p * (newRangeUpper.Value - newRangeLower.Value);
res += newRangeLower.Value;
outValue.Value = res;
Continue();
}
public override string GetSummary()
{
return "Map [" + initialRangeLower.Value.ToString() + "-" + initialRangeUpper.Value.ToString() + "] to [" +
newRangeLower.Value.ToString() + "-" + newRangeUpper.Value.ToString() + "]";
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Map.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 78d80bb5401d8044eb9eee0d4eb0b645
timeCreated: 1501226122
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

61
Assets/Fungus/Scripts/Commands/Math/MinMax.cs

@ -0,0 +1,61 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to store the min or max of 2 values
/// </summary>
[CommandInfo("Math",
"MinMax",
"Command to store the min or max of 2 values")]
[AddComponentMenu("")]
public class MinMax : Command
{
public enum Function
{
Min,
Max
}
[Tooltip("Min Or Max")]
[SerializeField]
protected Function function = Function.Min;
//[Tooltip("LHS Value ")]
[SerializeField]
protected FloatData inLHSValue, inRHSValue;
//[Tooltip("Where the result of the function is stored.")]
[SerializeField]
protected FloatData outValue;
public override void OnEnter()
{
switch (function)
{
case Function.Min:
outValue.Value = Mathf.Min(inLHSValue.Value, inRHSValue.Value);
break;
case Function.Max:
outValue.Value = Mathf.Max(inLHSValue.Value, inRHSValue.Value);
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return function.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/MinMax.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 514ec18f5085cba48bbe6701e4697eb0
timeCreated: 1501212523
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Neg.cs

@ -0,0 +1,26 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Negate a float
/// </summary>
[CommandInfo("Math",
"Negate",
"Negate a float")]
[AddComponentMenu("")]
public class Neg : BaseUnaryMathCommand
{
public override void OnEnter()
{
outValue.Value = -(inValue.Value);
Continue();
}
public override string GetSummary()
{
return "Negate";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Neg.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ff146879925212d4988aa4318efcbbd5
timeCreated: 1501213679
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

39
Assets/Fungus/Scripts/Commands/Math/Pow.cs

@ -0,0 +1,39 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Raise a value to the power of another
/// </summary>
[CommandInfo("Math",
"Pow",
"Raise a value to the power of another.")]
[AddComponentMenu("")]
public class Pow : Command
{
[SerializeField]
protected FloatData baseValue, exponentValue;
[Tooltip("Where the result of the function is stored.")]
[SerializeField]
protected FloatData outValue;
public override void OnEnter()
{
outValue.Value = Mathf.Pow(baseValue.Value, exponentValue.Value);
Continue();
}
public override string GetSummary()
{
return "Pow";
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Pow.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 23b09e2ab627fec4cb0200f7252dbc90
timeCreated: 1501497818
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

50
Assets/Fungus/Scripts/Commands/Math/Round.cs

@ -0,0 +1,50 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of a Round
/// </summary>
[CommandInfo("Math",
"Round",
"Command to execute and store the result of a Round")]
[AddComponentMenu("")]
public class Round : BaseUnaryMathCommand
{
public enum Mode
{
Round,
Floor,
Ceil
}
[Tooltip("Mode; Round (closest), floor(smaller) or ceil(bigger).")]
[SerializeField]
protected Mode function = Mode.Round;
public override void OnEnter()
{
switch (function)
{
case Mode.Round:
outValue.Value = Mathf.Round(inValue.Value);
break;
case Mode.Floor:
outValue.Value = Mathf.Floor(inValue.Value);
break;
case Mode.Ceil:
outValue.Value = Mathf.Ceil(inValue.Value);
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return function.ToString();
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Round.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b9c834185b491334d8e41ca4fc49a56e
timeCreated: 1501212403
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Sign.cs

@ -0,0 +1,26 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of a Sign
/// </summary>
[CommandInfo("Math",
"Sign",
"Command to execute and store the result of a Sign")]
[AddComponentMenu("")]
public class Sign : BaseUnaryMathCommand
{
public override void OnEnter()
{
outValue.Value = Mathf.Sign(inValue.Value);
Continue();
}
public override string GetSummary()
{
return "Sign";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Sign.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6a03542258f6b654b8a6d64938803f71
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Sqrt.cs

@ -0,0 +1,26 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of a Sqrt
/// </summary>
[CommandInfo("Math",
"Sqrt",
"Command to execute and store the result of a Sqrt")]
[AddComponentMenu("")]
public class Sqrt : BaseUnaryMathCommand
{
public override void OnEnter()
{
outValue.Value = Mathf.Sqrt(inValue.Value);
Continue();
}
public override string GetSummary()
{
return "Sqrt";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Sqrt.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6e52daa13ab8fe7499a7774ebc194fc5
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

65
Assets/Fungus/Scripts/Commands/Math/ToInt.cs

@ -0,0 +1,65 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of a float to int conversion
/// </summary>
[CommandInfo("Math",
"ToInt",
"Command to execute and store the result of a float to int conversion")]
[AddComponentMenu("")]
public class ToInt : Command
{
public enum Mode
{
RoundToInt,
FloorToInt,
CeilToInt,
}
[Tooltip("To integer mode; round, floor or ceil.")]
[SerializeField]
protected Mode function = Mode.RoundToInt;
[Tooltip("Value to be passed in to the function.")]
[SerializeField]
protected FloatData inValue;
[Tooltip("Where the result of the function is stored.")]
[SerializeField]
protected IntegerData outValue;
public override void OnEnter()
{
switch (function)
{
case Mode.RoundToInt:
outValue.Value = Mathf.RoundToInt(inValue.Value);
break;
case Mode.FloorToInt:
outValue.Value = Mathf.FloorToInt(inValue.Value);
break;
case Mode.CeilToInt:
outValue.Value = Mathf.CeilToInt(inValue.Value);
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return function.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/ToInt.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 209dba259f0c4134daa0ec3b64c78062
timeCreated: 1501210911
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

77
Assets/Fungus/Scripts/Commands/Math/Trig.cs

@ -0,0 +1,77 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Command to execute and store the result of basic trigonometry
/// </summary>
[CommandInfo("Math",
"Trig",
"Command to execute and store the result of basic trigonometry")]
[AddComponentMenu("")]
public class Trig : BaseUnaryMathCommand
{
public enum Function
{
Rad2Deg,
Deg2Rad,
ACos,
ASin,
ATan,
Cos,
Sin,
Tan
}
[Tooltip("Trigonometric function to run.")]
[SerializeField]
protected Function function = Function.Sin;
public override void OnEnter()
{
switch (function)
{
case Function.Rad2Deg:
outValue.Value = inValue.Value * Mathf.Rad2Deg;
break;
case Function.Deg2Rad:
outValue.Value = inValue.Value * Mathf.Deg2Rad;
break;
case Function.ACos:
outValue.Value = Mathf.Acos(inValue.Value);
break;
case Function.ASin:
outValue.Value = Mathf.Asin(inValue.Value);
break;
case Function.ATan:
outValue.Value = Mathf.Atan(inValue.Value);
break;
case Function.Cos:
outValue.Value = Mathf.Cos(inValue.Value);
break;
case Function.Sin:
outValue.Value = Mathf.Sin(inValue.Value);
break;
case Function.Tan:
outValue.Value = Mathf.Tan(inValue.Value);
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return function.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Trig.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ee9ab1525ab1b794489f2517aab1d5e2
timeCreated: 1501148787
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

10
Assets/Fungus/Scripts/Commands/Menu.cs

@ -35,6 +35,9 @@ namespace Fungus
[Tooltip("A custom Menu Dialog to use to display this menu. All subsequent Menu commands will use this dialog.")]
[SerializeField] protected MenuDialog setMenuDialog;
[Tooltip("If true, this option will be passed to the Menu Dialogue but marked as hidden, this can be used to hide options while maintaining a Menu Shuffle.")]
[SerializeField] protected BooleanData hideThisOption = new BooleanData(false);
#region Public members
public MenuDialog SetMenuDialog { get { return setMenuDialog; } set { setMenuDialog = value; } }
@ -47,10 +50,8 @@ namespace Fungus
MenuDialog.ActiveMenuDialog = setMenuDialog;
}
bool hideOption = (hideIfVisited && targetBlock != null && targetBlock.GetExecutionCount() > 0);
bool hideOption = (hideIfVisited && targetBlock != null && targetBlock.GetExecutionCount() > 0) || hideThisOption.Value;
if (!hideOption)
{
var menuDialog = MenuDialog.GetMenuDialog();
if (menuDialog != null)
{
@ -59,8 +60,7 @@ namespace Fungus
var flowchart = GetFlowchart();
string displayText = flowchart.SubstituteVariables(text);
menuDialog.AddOption(displayText, interactable, targetBlock);
}
menuDialog.AddOption(displayText, interactable, hideOption, targetBlock);
}
Continue();

59
Assets/Fungus/Scripts/Commands/MenuShuffle.cs

@ -0,0 +1,59 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using UnityEngine.Serialization;
using System.Collections.Generic;
namespace Fungus
{
/// <summary>
/// Shuffle the order of the items in a Fungus Menu
/// </summary>
[CommandInfo("Narrative",
"Menu Shuffle",
"Shuffle the order of the items in a Fungus Menu")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class MenuShuffle : Command
{
public enum Mode
{
Every,
Once
}
[SerializeField]
[Tooltip("Determines if the order is shuffled everytime this command is it (Every) or if it is consistent when returned to but random (Once)")]
protected Mode shuffleMode = Mode.Once;
private int seed = -1;
public override void OnEnter()
{
var menuDialog = MenuDialog.GetMenuDialog();
//if we shuffle every time or we haven't shuffled yet
if(shuffleMode == Mode.Every || seed == -1)
{
seed = Random.Range(0,1000000);
}
if (menuDialog != null)
{
menuDialog.Shuffle(new System.Random(seed));
}
Continue();
}
public override string GetSummary()
{
return shuffleMode.ToString();
}
public override Color GetButtonColor()
{
return new Color32(184, 210, 235, 255);
}
}
}

8
Assets/Fungus/Scripts/Commands/MenuShuffle.cs.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4d88125c88dab4a44851835e94ff4d90
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

2
Assets/Fungus/Scripts/Commands/OpenURL.cs

@ -12,7 +12,7 @@ namespace Fungus
[CommandInfo("Scripting",
"Open URL",
"Opens the specified URL in the browser.")]
public class LinkToWebsite : Command
public class OpenURL : Command
{
[Tooltip("URL to open in the browser")]
[SerializeField] protected StringData url = new StringData();

9
Assets/Fungus/Scripts/Commands/Property.meta

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

9
Assets/Fungus/Scripts/Commands/Rigidbody2D.meta

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

85
Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs

@ -0,0 +1,85 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fungus
{
// <summary>
/// Add force to a Rigidbody2D
/// </summary>
[CommandInfo("Rigidbody2D",
"AddForce2D",
"Add force to a Rigidbody2D")]
[AddComponentMenu("")]
public class AddForce2D : Command
{
[SerializeField]
protected Rigidbody2DData rb;
[SerializeField]
protected ForceMode2D forceMode = ForceMode2D.Force;
public enum ForceFunction
{
AddForce,
AddForceAtPosition,
AddRelativeForce
}
[SerializeField]
protected ForceFunction forceFunction = ForceFunction.AddForce;
[Tooltip("Vector of force to be added")]
[SerializeField]
protected Vector2Data force;
[Tooltip("Scale factor to be applied to force as it is used.")]
[SerializeField]
protected FloatData forceScaleFactor = new FloatData(1);
[Tooltip("World position the force is being applied from. Used only in AddForceAtPosition")]
[SerializeField]
protected Vector2Data atPosition;
public override void OnEnter()
{
switch (forceFunction)
{
case ForceFunction.AddForce:
rb.Value.AddForce(force.Value * forceScaleFactor.Value, forceMode);
break;
case ForceFunction.AddForceAtPosition:
rb.Value.AddForceAtPosition(force.Value * forceScaleFactor.Value, atPosition.Value, forceMode);
break;
case ForceFunction.AddRelativeForce:
rb.Value.AddRelativeForce(force.Value * forceScaleFactor.Value, forceMode);
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return forceMode.ToString() + ": " + force.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (rb.rigidbody2DRef == variable || force.vector2Ref == variable || forceScaleFactor.floatRef == variable ||
atPosition.vector2Ref == variable)
return true;
return false;
}
}
}

12
Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 59927941e3d79be4dac4408058904465
timeCreated: 1503094848
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

56
Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs

@ -0,0 +1,56 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fungus
{
// <summary>
/// Add Torque to a Rigidbody2D
/// </summary>
[CommandInfo("Rigidbody2D",
"AddTorque2D",
"Add Torque to a Rigidbody2D")]
[AddComponentMenu("")]
public class AddTorque2D : Command
{
[SerializeField]
protected Rigidbody2DData rb;
[SerializeField]
protected ForceMode2D forceMode = ForceMode2D.Force;
[Tooltip("Amount of torque to be added")]
[SerializeField]
protected FloatData force;
public override void OnEnter()
{
rb.Value.AddTorque(force.Value, forceMode);
Continue();
}
public override string GetSummary()
{
if (rb.Value == null)
{
return "Error: rb not set";
}
return forceMode.ToString() + ": " + force.Value.ToString() + (force.floatRef != null ? " (" + force.floatRef.Key + ")" : "");
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (rb.rigidbody2DRef == variable || force.floatRef == variable)
return true;
return false;
}
}
}

12
Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 42fb61d4cee69b244bcf4fcc8e4ae28b
timeCreated: 1503744011
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

69
Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs

@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fungus
{
// <summary>
/// Stop velocity and angular velocity on a Rigidbody2D
/// </summary>
[CommandInfo("Rigidbody2D",
"StopMotion2D",
"Stop velocity and angular velocity on a Rigidbody2D")]
[AddComponentMenu("")]
public class StopMotionRigidBody2D : Command
{
[SerializeField]
protected Rigidbody2DData rb;
public enum Motion
{
Velocity,
AngularVelocity,
AngularAndLinearVelocity
}
[SerializeField]
protected Motion motionToStop = Motion.AngularAndLinearVelocity;
public override void OnEnter()
{
switch (motionToStop)
{
case Motion.Velocity:
rb.Value.velocity = Vector2.zero;
break;
case Motion.AngularVelocity:
rb.Value.angularVelocity = 0;
break;
case Motion.AngularAndLinearVelocity:
rb.Value.angularVelocity = 0;
rb.Value.velocity = Vector2.zero;
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
return motionToStop.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (rb.rigidbody2DRef == variable)
return true;
return false;
}
}
}

12
Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bd2e830ee16360d418acee50d83c9c13
timeCreated: 1504225685
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
Assets/Fungus/Scripts/Commands/Say.cs

@ -48,6 +48,11 @@ namespace Fungus
[Tooltip("Stop playing voiceover when text finishes writing.")]
[SerializeField] protected bool stopVoiceover = true;
[Tooltip("Wait for the Voice Over to complete before continuing")]
[SerializeField] protected bool waitForVO = false;
//add wait for vo that overrides stopvo
[Tooltip("Sets the active Say dialog with a reference to a Say Dialog object in the scene. All story text will now display using this Say Dialog.")]
[SerializeField] protected SayDialog setSayDialog;
@ -120,7 +125,7 @@ namespace Fungus
string subbedText = flowchart.SubstituteVariables(displayText);
sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, voiceOverClip, delegate {
sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, waitForVO, voiceOverClip, delegate {
Continue();
});
}

9
Assets/Fungus/Scripts/Commands/Scene.meta

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

35
Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs

@ -0,0 +1,35 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Reload the current scene
/// </summary>
[CommandInfo("Scene",
"Reload",
"Reload the current scene")]
[AddComponentMenu("")]
public class ReloadScene : Command
{
[Tooltip("Image to display while loading the scene")]
[SerializeField]
protected Texture2D loadingImage;
public override void OnEnter()
{
SceneLoader.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name, loadingImage);
Continue();
}
public override string GetSummary()
{
return "";
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9c784b19efbe8424fa879e0d6d883281
timeCreated: 1501237128
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

2
Assets/Fungus/Scripts/Commands/SetInteractable.cs

@ -12,7 +12,7 @@ namespace Fungus
/// </summary>
[CommandInfo("UI",
"Set Interactable",
"Set the interactable sate of selectable objects.")]
"Set the interactable state of selectable objects.")]
public class SetInteractable : Command
{
[Tooltip("List of objects to be affected by the command")]

118
Assets/Fungus/Scripts/Commands/SetVariable.cs

@ -2,28 +2,10 @@
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using System.Collections.Generic;
namespace Fungus
{
/// <summary>
/// Mathematical operations that can be performed on variables.
/// </summary>
public enum SetOperator
{
/// <summary> = operator. </summary>
Assign,
/// <summary> =! operator. </summary>
Negate,
/// <summary> += operator. </summary>
Add,
/// <summary> -= operator. </summary>
Subtract,
/// <summary> *= operator. </summary>
Multiply,
/// <summary> /= operator. </summary>
Divide
}
/// <summary>
/// Sets a Boolean, Integer, Float or String variable to a new value using a simple arithmetic operation. The value can be a constant or reference another variable of the same type.
/// </summary>
@ -37,7 +19,8 @@ namespace Fungus
[VariableProperty(typeof(BooleanVariable),
typeof(IntegerVariable),
typeof(FloatVariable),
typeof(StringVariable))]
typeof(StringVariable),
typeof(GameObjectVariable))]
[SerializeField] protected Variable variable;
[Tooltip("The type of math operation to be performed")]
@ -55,6 +38,9 @@ namespace Fungus
[Tooltip("String value to set with")]
[SerializeField] protected StringDataMulti stringData;
[Tooltip("GameObject value to set with")]
[SerializeField] protected GameObjectData gameObjectData;
protected virtual void DoSetOperation()
{
if (variable == null)
@ -64,90 +50,42 @@ namespace Fungus
if (variable.GetType() == typeof(BooleanVariable))
{
BooleanVariable lhs = (variable as BooleanVariable);
bool rhs = booleanData.Value;
switch (setOperator)
{
default:
case SetOperator.Assign:
lhs.Value = rhs;
break;
case SetOperator.Negate:
lhs.Value = !rhs;
break;
}
BooleanVariable booleanVariable = (variable as BooleanVariable);
booleanVariable.Apply(setOperator, booleanData.Value);
}
else if (variable.GetType() == typeof(IntegerVariable))
{
IntegerVariable lhs = (variable as IntegerVariable);
int rhs = integerData.Value;
switch (setOperator)
{
default:
case SetOperator.Assign:
lhs.Value = rhs;
break;
case SetOperator.Add:
lhs.Value += rhs;
break;
case SetOperator.Subtract:
lhs.Value -= rhs;
break;
case SetOperator.Multiply:
lhs.Value *= rhs;
break;
case SetOperator.Divide:
lhs.Value /= rhs;
break;
}
IntegerVariable integerVariable = (variable as IntegerVariable);
integerVariable.Apply(setOperator, integerData.Value);
}
else if (variable.GetType() == typeof(FloatVariable))
{
FloatVariable lhs = (variable as FloatVariable);
float rhs = floatData.Value;
switch (setOperator)
{
default:
case SetOperator.Assign:
lhs.Value = rhs;
break;
case SetOperator.Add:
lhs.Value += rhs;
break;
case SetOperator.Subtract:
lhs.Value -= rhs;
break;
case SetOperator.Multiply:
lhs.Value *= rhs;
break;
case SetOperator.Divide:
lhs.Value /= rhs;
break;
}
FloatVariable floatVariable = (variable as FloatVariable);
floatVariable.Apply(setOperator, floatData.Value);
}
else if (variable.GetType() == typeof(StringVariable))
{
StringVariable lhs = (variable as StringVariable);
string rhs = stringData.Value;
StringVariable stringVariable = (variable as StringVariable);
var flowchart = GetFlowchart();
rhs = flowchart.SubstituteVariables(rhs);
switch (setOperator)
{
default:
case SetOperator.Assign:
lhs.Value = rhs;
break;
stringVariable.Apply(setOperator, flowchart.SubstituteVariables(stringData.Value));
}
else if (variable.GetType() == typeof(GameObjectVariable))
{
GameObjectVariable gameObjectVariable = (variable as GameObjectVariable);
gameObjectVariable.Apply(setOperator, gameObjectData.Value);
}
}
#region Public members
public static readonly Dictionary<System.Type, SetOperator[]> operatorsByVariableType = new Dictionary<System.Type, SetOperator[]>() {
{ typeof(BooleanVariable), BooleanVariable.setOperators },
{ typeof(IntegerVariable), IntegerVariable.setOperators },
{ typeof(FloatVariable), FloatVariable.setOperators },
{ typeof(StringVariable), StringVariable.setOperators },
{ typeof(GameObjectVariable), GameObjectVariable.setOperators }
};
/// <summary>
/// The type of math operation to be performed.
/// </summary>
@ -208,6 +146,10 @@ namespace Fungus
{
description += stringData.GetDescription();
}
else if (variable.GetType() == typeof(GameObjectVariable))
{
description += gameObjectData.GetDescription();
}
return description;
}

45
Assets/Fungus/Scripts/Commands/SpawnObject.cs

@ -11,7 +11,11 @@ namespace Fungus
/// </summary>
[CommandInfo("Scripting",
"Spawn Object",
"Spawns a new object based on a reference to a scene or prefab game object.")]
"Spawns a new object based on a reference to a scene or prefab game object.",
Priority = 10)]
[CommandInfo("GameObject",
"Instantiate",
"Instantiate a game object")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class SpawnObject : Command
@ -19,15 +23,24 @@ namespace Fungus
[Tooltip("Game object to copy when spawning. Can be a scene object or a prefab.")]
[SerializeField] protected GameObjectData _sourceObject;
[Tooltip("Transform to use for position of newly spawned object.")]
[Tooltip("Transform to use as parent during instantiate.")]
[SerializeField] protected TransformData _parentTransform;
[Tooltip("If true, will use the Transfrom of this Flowchart for the position and rotation.")]
[SerializeField] protected BooleanData _spawnAtSelf = new BooleanData(false);
[Tooltip("Local position of newly spawned object.")]
[SerializeField] protected Vector3Data _spawnPosition;
[Tooltip("Local rotation of newly spawned object.")]
[SerializeField] protected Vector3Data _spawnRotation;
[Tooltip("Optional variable to store the GameObject that was just created.")]
[SerializeField]
protected GameObjectData _newlySpawnedObject;
#region Public members
public override void OnEnter()
@ -38,14 +51,28 @@ namespace Fungus
return;
}
GameObject newObject = GameObject.Instantiate(_sourceObject.Value);
GameObject newObject = null;
if (_parentTransform.Value != null)
{
newObject.transform.parent = _parentTransform.Value;
newObject = GameObject.Instantiate(_sourceObject.Value,_parentTransform.Value);
}
else
{
newObject = GameObject.Instantiate(_sourceObject.Value);
}
if (!_spawnAtSelf.Value)
{
newObject.transform.localPosition = _spawnPosition.Value;
newObject.transform.localRotation = Quaternion.Euler(_spawnRotation.Value);
}
else
{
newObject.transform.SetPositionAndRotation(transform.position, transform.rotation);
}
_newlySpawnedObject.Value = newObject;
Continue();
}
@ -65,6 +92,16 @@ namespace Fungus
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (_sourceObject.gameObjectRef == variable || _parentTransform.transformRef == variable ||
_spawnAtSelf.booleanRef == variable || _spawnPosition.vector3Ref == variable ||
_spawnRotation.vector3Ref == variable)
return true;
return false;
}
#endregion
#region Backwards compatibility

9
Assets/Fungus/Scripts/Commands/Transform.meta

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

217
Assets/Fungus/Scripts/Commands/Transform/TransformProperty.cs

@ -0,0 +1,217 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fungus
{
// <summary>
/// Get or Set a property of a transform component
/// </summary>
[CommandInfo("Transform",
"Property",
"Get or Set a property of a transform component")]
[AddComponentMenu("")]
public class TransformProperty : Command
{
public enum GetSet
{
Get,
Set,
}
public GetSet getOrSet = GetSet.Get;
public enum Property
{
ChildCount,
EulerAngles,
Forward,
HasChanged,
HierarchyCapacity,
HierarchyCount,
LocalEulerAngles,
LocalPosition,
LocalScale,
LossyScale,
Parent,
Position,
Right,
Root,
Up,
//no quat or mat4 yet
//LocalRotation,
//Rotation,
//LocalToWorldMatrix,
//WorldToLocalMatrix
}
[SerializeField]
protected Property property = Property.Position;
[SerializeField]
protected TransformData transformData;
[SerializeField]
[VariableProperty(typeof(BooleanVariable),
typeof(IntegerVariable),
typeof(Vector3Variable),
typeof(TransformVariable))]
protected Variable inOutVar;
public override void OnEnter()
{
var iob = inOutVar as BooleanVariable;
var ioi = inOutVar as IntegerVariable;
var iov = inOutVar as Vector3Variable;
var iot = inOutVar as TransformVariable;
var t = transformData.Value;
switch (getOrSet)
{
case GetSet.Get:
switch (property)
{
case Property.ChildCount:
ioi.Value = t.childCount;
break;
case Property.EulerAngles:
iov.Value = t.eulerAngles;
break;
case Property.Forward:
iov.Value = t.forward;
break;
case Property.HasChanged:
iob.Value = t.hasChanged;
break;
case Property.HierarchyCapacity:
ioi.Value = t.hierarchyCapacity;
break;
case Property.HierarchyCount:
ioi.Value = t.hierarchyCount;
break;
case Property.LocalEulerAngles:
iov.Value = t.localEulerAngles;
break;
case Property.LocalPosition:
iov.Value = t.localPosition;
break;
case Property.LocalScale:
iov.Value = t.localScale;
break;
case Property.LossyScale:
iov.Value = t.lossyScale;
break;
case Property.Parent:
iot.Value = t.parent;
break;
case Property.Position:
iov.Value = t.position;
break;
case Property.Right:
iov.Value = t.right;
break;
case Property.Root:
iot.Value = t.parent;
break;
case Property.Up:
iov.Value = t.up;
break;
default:
break;
}
break;
case GetSet.Set:
switch (property)
{
case Property.ChildCount:
Debug.LogWarning("Cannot Set childCount, it is read only");
break;
case Property.EulerAngles:
t.eulerAngles = iov.Value;
break;
case Property.Forward:
t.forward = iov.Value;
break;
case Property.HasChanged:
t.hasChanged = iob.Value;
break;
case Property.HierarchyCapacity:
t.hierarchyCapacity = ioi.Value;
break;
case Property.HierarchyCount:
Debug.LogWarning("Cannot Set HierarchyCount, it is read only");
break;
case Property.LocalEulerAngles:
t.localEulerAngles = iov.Value;
break;
case Property.LocalPosition:
t.localPosition = iov.Value;
break;
case Property.LocalScale:
t.localScale = iov.Value;
break;
case Property.LossyScale:
Debug.LogWarning("Cannot Set LossyScale, it is read only");
break;
case Property.Parent:
t.parent = iot.Value;
break;
case Property.Position:
t.position = iov.Value;
break;
case Property.Right:
t.right = iov.Value;
break;
case Property.Root:
Debug.LogWarning("Cannot Set Root, it is read only");
break;
case Property.Up:
t.up = iov.Value;
break;
default:
break;
}
break;
default:
break;
}
Continue();
}
public override string GetSummary()
{
if (transformData.Value == null)
{
return "Error: no transform set";
}
var iob = inOutVar as BooleanVariable;
var ioi = inOutVar as IntegerVariable;
var iov = inOutVar as Vector3Variable;
var iot = inOutVar as TransformVariable;
if (iob == null && ioi == null && iov == null && iot == null)
{
return "Error: no variable set to push or pull data to or from";
}
//We could do further checks here, eg, you have selected childcount but set a vec3variable
return getOrSet.ToString() + " " + property.ToString();
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
public override bool HasReference(Variable variable)
{
if (transformData.transformRef == variable || inOutVar == variable)
return true;
return false;
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save