diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..164aae81
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,34 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is. Is it a bug during playback or a bug in editing Flowcharts, Blocks, Commands, and so on? When and where it is happening, is it only in editor or only in build or both?
+
+**To Reproduce**
+In order for someone else to attempt to solve the issue we need to know how to make it occur. As such when reporting bugs please detail how to make them occur in existing FungusExample scenes, or how to create a scene from empty, or attach a unitypackage with a minimal scene in it.
+Then describe the steps to reproduce the behavior:
+1. Go to the scene '...' in the FungusExample ***OR*** In a new scene, add the following '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Versions & Platform (please complete the following information):**
+ - Unity version [e.g. 2019.2.20f1 or 2017.4.25]
+ - Fungus Version[e.g. v.3.12.0] This can be found in your Docs/ChangeLog or via Preferences->Fungus
+ - Editor OS: [e.g. Win 10 or OSX Mavericks]
+ - Build Platform [e.g. WebGL, Windows IL2CPP, iOS, Android]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 00000000..715fe44b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,22 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+Please double check the feature or suggestion you have has not already been raised by searching within the existing [issues](https://github.com/snozbot/fungus/issues). If you find something similar to what you were thinking, please reply to the existing issue with either additional details/suggestions or simply a +1.
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 00000000..4ed64e02
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,42 @@
+🚨Before submitting this PR.
+- Please review the [guidelines for contributing](./CONTRIBUTING.md) to this repository.
+- We welcome the submission of incomplete PRs, for comment, feedback, or assistance. Please prefix the PR with [WIP].
+- Make sure you are making a pull request against the **develop branch** (left side). Also you should start *your branch* off *develop*.
+- Make sure you are requesting to **pull a topic/feature/bugfix branch** (right side). We don't recommend you request from your master!
+- Check the commit's or even all commits' message styles matches our style and structure.
+- Check your code additions pass all tests.
+- Check your code additions have not negatively impacted or altered the behaviour of the FungusExamples.
+- If adding a new feature, ensure you have added a demo to the FungusExamples and if possible added Tests too.
+
+💔Thank you! With that done and out of the way, you can remove all the above text and get to submitting this PR.
+
+### Description
+
+
+### What is the current behavior?
+
+
+### What is the new behavior?
+
+-
+-
+-
+
+### Important Notes
+
+
+- [ ] My change require changes to documentation
+- My changes modify
+ - [ ] the editing of flowcharts/blocks/commands etc.
+ - [ ] the runtime execution of existing Fungus Features. e.g., Say, Menus, Portraits, etc.
+- [ ] My change adds additional tests
+- [ ] My change modifies existing FungusExamples
+
+
+
+
+### Other information
+
+
diff --git a/.gitignore b/.gitignore
index 4149961d..2a799fe2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ UWP/*
Assets/Plugins/
Assets/Plugins.meta
Logs/*
+.vscode/launch.json
diff --git a/Assets/Fungus/Docs/CHANGELOG.txt b/Assets/Fungus/Docs/CHANGELOG.txt
index e56d654e..852a1ad1 100644
--- a/Assets/Fungus/Docs/CHANGELOG.txt
+++ b/Assets/Fungus/Docs/CHANGELOG.txt
@@ -1,7 +1,7 @@
Changelog {#changelog}
=========
-v3.12.0 rc1
+v3.12.0
======
## Added
@@ -32,6 +32,7 @@ v3.12.0 rc1
- More elaborated use of text in TMPro demo
- Block Inspector forces type at creation. Thanks to Michaelwolf95
- Warning when requesting menu elements that are not avaialble, such as more menu items that you have created.
+- Fungus Docs can now generate in github markdown format
v3.11.5 {#v3.11.5}
diff --git a/Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab b/Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab
new file mode 100644
index 00000000..9c94da38
--- /dev/null
+++ b/Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab
@@ -0,0 +1,434 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &3892339027384508655
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 3892339027384508654}
+ - component: {fileID: 3892339027384508652}
+ - component: {fileID: 3892339027384508653}
+ m_Layer: 5
+ m_Name: Background
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &3892339027384508654
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339027384508655}
+ 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: 3892339028978780123}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 1, y: 1}
+ m_AnchoredPosition: {x: 0, y: 0}
+ m_SizeDelta: {x: 0, y: 0}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &3892339027384508652
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339027384508655}
+ m_CullTransparentMesh: 0
+--- !u!114 &3892339027384508653
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339027384508655}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Material: {fileID: 0}
+ m_Color: {r: 0.2783019, g: 0.50158674, b: 1, a: 1}
+ m_RaycastTarget: 1
+ m_OnCullStateChanged:
+ m_PersistentCalls:
+ m_Calls: []
+ m_Texture: {fileID: 0}
+ m_UVRect:
+ serializedVersion: 2
+ x: 0
+ y: 0
+ width: 1
+ height: 1
+--- !u!1 &3892339028022738724
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 3892339028022738723}
+ - component: {fileID: 3892339028022738735}
+ - component: {fileID: 3892339028022738720}
+ - component: {fileID: 3892339028022738721}
+ - component: {fileID: 3892339028022738722}
+ m_Layer: 5
+ m_Name: EntryDisplayHolder
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &3892339028022738723
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028022738724}
+ 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: 3892339028978780123}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 1}
+ m_AnchorMax: {x: 0, y: 1}
+ m_AnchoredPosition: {x: 0, y: 0.000015258789}
+ m_SizeDelta: {x: 600, y: 0}
+ m_Pivot: {x: 0, y: 1}
+--- !u!222 &3892339028022738735
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028022738724}
+ m_CullTransparentMesh: 0
+--- !u!114 &3892339028022738720
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028022738724}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Material: {fileID: 0}
+ m_Color: {r: 0.2783019, g: 0.50158674, b: 1, a: 1}
+ m_RaycastTarget: 1
+ m_OnCullStateChanged:
+ m_PersistentCalls:
+ m_Calls: []
+ m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
+ m_Type: 1
+ m_PreserveAspect: 0
+ m_FillCenter: 1
+ m_FillMethod: 4
+ m_FillAmount: 1
+ m_FillClockwise: 1
+ m_FillOrigin: 0
+ m_UseSpriteMesh: 0
+ m_PixelsPerUnitMultiplier: 1
+--- !u!114 &3892339028022738721
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028022738724}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Padding:
+ m_Left: 0
+ m_Right: 0
+ m_Top: 0
+ m_Bottom: 0
+ m_ChildAlignment: 0
+ m_Spacing: 0
+ m_ChildForceExpandWidth: 1
+ m_ChildForceExpandHeight: 0
+ m_ChildControlWidth: 1
+ m_ChildControlHeight: 1
+ m_ChildScaleWidth: 0
+ m_ChildScaleHeight: 0
+--- !u!114 &3892339028022738722
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028022738724}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_HorizontalFit: 0
+ m_VerticalFit: 2
+--- !u!1 &3892339028774243865
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 3892339028774243842}
+ - component: {fileID: 3892339028774243843}
+ - component: {fileID: 3892339028774243844}
+ - component: {fileID: 3892339028774243845}
+ - component: {fileID: 3892339028774243846}
+ - component: {fileID: 3892339028774243864}
+ m_Layer: 5
+ m_Name: NarrativeLog
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &3892339028774243842
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028774243865}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 0, y: 0, z: 0}
+ m_Children:
+ - {fileID: 3892339028978780123}
+ m_Father: {fileID: 0}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
+ m_SizeDelta: {x: 0, y: 0}
+ m_Pivot: {x: 0, y: 0}
+--- !u!223 &3892339028774243843
+Canvas:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028774243865}
+ m_Enabled: 1
+ serializedVersion: 3
+ m_RenderMode: 0
+ m_Camera: {fileID: 0}
+ m_PlaneDistance: 100
+ m_PixelPerfect: 0
+ m_ReceivesEvents: 1
+ m_OverrideSorting: 0
+ m_OverridePixelPerfect: 0
+ m_SortingBucketNormalizedSize: 0
+ m_AdditionalShaderChannelsFlag: 0
+ m_SortingLayerID: 0
+ m_SortingOrder: 0
+ m_TargetDisplay: 0
+--- !u!114 &3892339028774243844
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028774243865}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_UiScaleMode: 0
+ m_ReferencePixelsPerUnit: 100
+ m_ScaleFactor: 1
+ m_ReferenceResolution: {x: 800, y: 600}
+ m_ScreenMatchMode: 0
+ m_MatchWidthOrHeight: 0
+ m_PhysicalUnit: 3
+ m_FallbackScreenDPI: 96
+ m_DefaultSpriteDPI: 96
+ m_DynamicPixelsPerUnit: 1
+--- !u!114 &3892339028774243845
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028774243865}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_IgnoreReversedGraphics: 1
+ m_BlockingObjects: 0
+ m_BlockingMask:
+ serializedVersion: 2
+ m_Bits: 4294967295
+--- !u!225 &3892339028774243846
+CanvasGroup:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028774243865}
+ m_Enabled: 1
+ m_Alpha: 1
+ m_Interactable: 1
+ m_BlocksRaycasts: 1
+ m_IgnoreParentGroups: 0
+--- !u!114 &3892339028774243864
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028774243865}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: fde579c9edfbe7e469349e39e2a87a48, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ entryDisplayPrefab: {fileID: 2879084013005042991, guid: 243a94cf6d8dda84f8351f4289587571,
+ type: 3}
+ entryHolder: {fileID: 3892339028022738723}
+--- !u!1 &3892339028978780124
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 3892339028978780123}
+ - component: {fileID: 3892339028978780103}
+ - component: {fileID: 3892339028978780120}
+ - component: {fileID: 3892339028978780121}
+ - component: {fileID: 3892339028978780122}
+ m_Layer: 5
+ m_Name: MainWindow
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &3892339028978780123
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028978780124}
+ 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: 3892339027384508654}
+ - {fileID: 3892339028022738723}
+ m_Father: {fileID: 3892339028774243842}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0.5, y: 0.5}
+ m_AnchorMax: {x: 0.5, y: 0.5}
+ m_AnchoredPosition: {x: 0, y: 108.70001}
+ m_SizeDelta: {x: 600, y: 300}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &3892339028978780103
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028978780124}
+ m_CullTransparentMesh: 0
+--- !u!114 &3892339028978780120
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028978780124}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Material: {fileID: 0}
+ m_Color: {r: 1, g: 1, b: 1, a: 0.392}
+ m_RaycastTarget: 1
+ m_OnCullStateChanged:
+ m_PersistentCalls:
+ m_Calls: []
+ m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
+ m_Type: 1
+ m_PreserveAspect: 0
+ m_FillCenter: 1
+ m_FillMethod: 4
+ m_FillAmount: 1
+ m_FillClockwise: 1
+ m_FillOrigin: 0
+ m_UseSpriteMesh: 0
+ m_PixelsPerUnitMultiplier: 1
+--- !u!114 &3892339028978780121
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028978780124}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Content: {fileID: 3892339028022738723}
+ m_Horizontal: 0
+ m_Vertical: 1
+ m_MovementType: 2
+ m_Elasticity: 0.1
+ m_Inertia: 1
+ m_DecelerationRate: 0.135
+ m_ScrollSensitivity: 1
+ m_Viewport: {fileID: 0}
+ m_HorizontalScrollbar: {fileID: 0}
+ m_VerticalScrollbar: {fileID: 0}
+ m_HorizontalScrollbarVisibility: 0
+ m_VerticalScrollbarVisibility: 0
+ m_HorizontalScrollbarSpacing: 0
+ m_VerticalScrollbarSpacing: 0
+ m_OnValueChanged:
+ m_PersistentCalls:
+ m_Calls: []
+--- !u!114 &3892339028978780122
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3892339028978780124}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_ShowMaskGraphic: 1
diff --git a/Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab.meta b/Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab.meta
new file mode 100644
index 00000000..d675b9f0
--- /dev/null
+++ b/Assets/Fungus/Resources/Prefabs/NarrativeLog.prefab.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: bffd475e4bfb82f49810ceafe8d17b78
+PrefabImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab b/Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab
new file mode 100644
index 00000000..6f602b65
--- /dev/null
+++ b/Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab
@@ -0,0 +1,269 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &2333275596563789949
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 8885489252217067950}
+ - component: {fileID: 7933068750079926288}
+ - component: {fileID: 4379489694222926579}
+ m_Layer: 5
+ m_Name: NameText
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &8885489252217067950
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2333275596563789949}
+ 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: 2481548615123137394}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
+ m_SizeDelta: {x: 0, y: 0}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &7933068750079926288
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2333275596563789949}
+ m_CullTransparentMesh: 0
+--- !u!114 &4379489694222926579
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2333275596563789949}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Material: {fileID: 0}
+ m_Color: {r: 1, g: 1, b: 1, a: 1}
+ m_RaycastTarget: 1
+ m_OnCullStateChanged:
+ m_PersistentCalls:
+ m_Calls: []
+ m_FontData:
+ m_Font: {fileID: 12800000, guid: 64bd3e45f7a714f16b3c213f55f17fea, type: 3}
+ m_FontSize: 18
+ m_FontStyle: 0
+ m_BestFit: 0
+ m_MinSize: 1
+ m_MaxSize: 40
+ m_Alignment: 0
+ m_AlignByGeometry: 0
+ m_RichText: 1
+ m_HorizontalOverflow: 0
+ m_VerticalOverflow: 0
+ m_LineSpacing: 1
+ m_Text: Name
+--- !u!1 &3511986559566215052
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 3365827255933976305}
+ - component: {fileID: 3857872114285753493}
+ - component: {fileID: 19882628764411882}
+ m_Layer: 5
+ m_Name: StoryText
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &3365827255933976305
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3511986559566215052}
+ 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: 2481548615123137394}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
+ m_SizeDelta: {x: 0, y: 0}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &3857872114285753493
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3511986559566215052}
+ m_CullTransparentMesh: 0
+--- !u!114 &19882628764411882
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 3511986559566215052}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Material: {fileID: 0}
+ m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
+ m_RaycastTarget: 1
+ m_OnCullStateChanged:
+ m_PersistentCalls:
+ m_Calls: []
+ m_FontData:
+ m_Font: {fileID: 12800000, guid: 64bd3e45f7a714f16b3c213f55f17fea, type: 3}
+ m_FontSize: 22
+ m_FontStyle: 0
+ m_BestFit: 0
+ m_MinSize: 2
+ m_MaxSize: 40
+ m_Alignment: 0
+ m_AlignByGeometry: 0
+ m_RichText: 1
+ m_HorizontalOverflow: 0
+ m_VerticalOverflow: 0
+ m_LineSpacing: 1
+ m_Text: New Text
+--- !u!1 &9061313995661533662
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 2481548615123137394}
+ - component: {fileID: 3382758035194104851}
+ - component: {fileID: 819304301769093009}
+ - component: {fileID: 5508376540251964814}
+ - component: {fileID: 2879084013005042991}
+ m_Layer: 5
+ m_Name: NarrativeLogEntryDisplay
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &2481548615123137394
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 9061313995661533662}
+ 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: 8885489252217067950}
+ - {fileID: 3365827255933976305}
+ m_Father: {fileID: 0}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
+ m_SizeDelta: {x: 0, y: 278}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &3382758035194104851
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 9061313995661533662}
+ m_CullTransparentMesh: 0
+--- !u!114 &819304301769093009
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 9061313995661533662}
+ m_Enabled: 0
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Material: {fileID: 0}
+ m_Color: {r: 1, g: 1, b: 1, a: 1}
+ m_RaycastTarget: 1
+ m_OnCullStateChanged:
+ m_PersistentCalls:
+ m_Calls: []
+ m_Texture: {fileID: 0}
+ m_UVRect:
+ serializedVersion: 2
+ x: 0
+ y: 0
+ width: 1
+ height: 1
+--- !u!114 &5508376540251964814
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 9061313995661533662}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_Padding:
+ m_Left: 10
+ m_Right: 10
+ m_Top: 10
+ m_Bottom: 10
+ m_ChildAlignment: 0
+ m_Spacing: 0
+ m_ChildForceExpandWidth: 1
+ m_ChildForceExpandHeight: 1
+ m_ChildControlWidth: 1
+ m_ChildControlHeight: 1
+ m_ChildScaleWidth: 0
+ m_ChildScaleHeight: 0
+--- !u!114 &2879084013005042991
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 9061313995661533662}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 824b58b7741a0dd4e9b43693c47b24f7, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ nameTextField: {fileID: 4379489694222926579}
+ storyTextField: {fileID: 19882628764411882}
diff --git a/Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab.meta b/Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab.meta
new file mode 100644
index 00000000..cad28ab4
--- /dev/null
+++ b/Assets/Fungus/Resources/Prefabs/NarrativeLogEntryDisplay.prefab.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 243a94cf6d8dda84f8351f4289587571
+PrefabImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/AssertCommand.cs b/Assets/Fungus/Scripts/Commands/AssertCommand.cs
new file mode 100644
index 00000000..229c3db6
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/AssertCommand.cs
@@ -0,0 +1,70 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+using UnityEngine.Assertions;
+
+namespace Fungus
+{
+ ///
+ /// Assert on 2 Fungus variable values.
+ ///
+ [CommandInfo("Scripting",
+ "Assert",
+ "Assert based on compared values.")]
+ [AddComponentMenu("")]
+ public class AssertCommand : Command
+ {
+ [SerializeField]
+ protected StringData message;
+
+ [SerializeField]
+ [VariableProperty(AllVariableTypes.VariableAny.Any)]
+ protected Variable a, b;
+
+ public enum Method
+ {
+ AreEqual,
+ AreNotEqual,
+ }
+
+ [SerializeField]
+ protected Method method;
+
+ public override void OnEnter()
+ {
+ switch (method)
+ {
+ case Method.AreEqual:
+ Assert.AreEqual(a.GetValue(), b.GetValue());
+ break;
+
+ case Method.AreNotEqual:
+ Assert.AreNotEqual(a.GetValue(), b.GetValue());
+ break;
+
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (a == null)
+ return "Error: No A variable";
+ if (b == null)
+ return "Error: No B variable";
+
+ return a.Key + " " + method.ToString() + " " + b.Key;
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == message.stringRef ||
+ variable == a || variable == b ||
+ base.HasReference(variable);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/AssertCommand.cs.meta b/Assets/Fungus/Scripts/Commands/AssertCommand.cs.meta
new file mode 100644
index 00000000..a16fc062
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/AssertCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c40b126bd148ae743b56bc8c00162589
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Break.cs b/Assets/Fungus/Scripts/Commands/Break.cs
index 4286468f..b1f36030 100644
--- a/Assets/Fungus/Scripts/Commands/Break.cs
+++ b/Assets/Fungus/Scripts/Commands/Break.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -8,61 +8,39 @@ namespace Fungus
///
/// Force a loop to terminate immediately.
///
- [CommandInfo("Flow",
- "Break",
+ [CommandInfo("Flow",
+ "Break",
"Force a loop to terminate immediately.")]
[AddComponentMenu("")]
public class Break : Command
{
#region Public members
+ //located the containing loop and tell it to end
public override void OnEnter()
{
- // Find index of previous while command
- int whileIndex = -1;
- int whileIndentLevel = -1;
- for (int i = CommandIndex - 1; i >=0; --i)
+ Condition loopingCond = null;
+ // Find index of previous looping command
+ for (int i = CommandIndex - 1; i >= 0; --i)
{
- While whileCommand = ParentBlock.CommandList[i] as While;
- if (whileCommand != null)
+ Condition cond = ParentBlock.CommandList[i] as Condition;
+ if (cond != null && cond.IsLooping)
{
- whileIndex = i;
- whileIndentLevel = whileCommand.IndentLevel;
+ loopingCond = cond;
break;
}
}
- if (whileIndex == -1)
+ if (loopingCond == null)
{
- // No enclosing While command found, just continue
+ // No enclosing loop command found, just continue
+ Debug.LogError("Break called but found no enclosing looping construct." + GetLocationIdentifier());
Continue();
- return;
}
-
- // Find matching End statement at same indent level as While
- for (int i = whileIndex + 1; i < ParentBlock.CommandList.Count; ++i)
+ else
{
- End endCommand = ParentBlock.CommandList[i] as End;
-
- if (endCommand != null &&
- endCommand.IndentLevel == whileIndentLevel)
- {
- // Sanity check that break command is actually between the While and End commands
- if (CommandIndex > whileIndex && CommandIndex < endCommand.CommandIndex)
- {
- // Continue at next command after End
- Continue (endCommand.CommandIndex + 1);
- return;
- }
- else
- {
- break;
- }
- }
+ loopingCond.MoveToEnd();
}
-
- // No matching End command found so just continue
- Continue();
}
public override Color GetButtonColor()
diff --git a/Assets/Fungus/Scripts/Commands/Call.cs b/Assets/Fungus/Scripts/Commands/Call.cs
index 7150f206..12a5ff58 100644
--- a/Assets/Fungus/Scripts/Commands/Call.cs
+++ b/Assets/Fungus/Scripts/Commands/Call.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -53,8 +53,6 @@ namespace Fungus
public override void OnEnter()
{
- var flowchart = GetFlowchart();
-
if (targetBlock != null)
{
// Check if calling your own parent block
diff --git a/Assets/Fungus/Scripts/Commands/CallMethod.cs b/Assets/Fungus/Scripts/Commands/CallMethod.cs
index 74f6855a..107a1439 100644
--- a/Assets/Fungus/Scripts/Commands/CallMethod.cs
+++ b/Assets/Fungus/Scripts/Commands/CallMethod.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ClearMenu.cs b/Assets/Fungus/Scripts/Commands/ClearMenu.cs
index 82722c4a..1c53c46a 100644
--- a/Assets/Fungus/Scripts/Commands/ClearMenu.cs
+++ b/Assets/Fungus/Scripts/Commands/ClearMenu.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Transform.meta b/Assets/Fungus/Scripts/Commands/Collection.meta
similarity index 57%
rename from Assets/Fungus/Scripts/Commands/Transform.meta
rename to Assets/Fungus/Scripts/Commands/Collection.meta
index 7eb641ce..ee30b8f3 100644
--- a/Assets/Fungus/Scripts/Commands/Transform.meta
+++ b/Assets/Fungus/Scripts/Commands/Collection.meta
@@ -1,9 +1,8 @@
fileFormatVersion: 2
-guid: f7ddb80a0487d1342b36129da32ad1f6
+guid: 7d7820abad934b747ae1797c3aa82197
folderAsset: yes
-timeCreated: 1503815490
-licenseType: Free
DefaultImporter:
+ externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs
new file mode 100644
index 00000000..49322556
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs
@@ -0,0 +1,35 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Base class for all FungusCollection commands
+ ///
+ [AddComponentMenu("")]
+ public abstract class CollectionBaseCommand : Command
+ {
+ [SerializeField]
+ protected CollectionData collection;
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(191, 217, 235, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == collection.collectionRef;
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ return collection.Value.name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs.meta
new file mode 100644
index 00000000..68f6899a
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: dab2b4efcfae62841b5070c4cfec8c4a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs
new file mode 100644
index 00000000..b5f790a4
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs
@@ -0,0 +1,42 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Base class for all FungusCollection commands that use an intvar
+ ///
+ [AddComponentMenu("")]
+ public abstract class CollectionBaseIntCommand : CollectionBaseCommand
+ {
+ [SerializeField]
+ protected IntegerData integer;
+
+ public override void OnEnter()
+ {
+ if (collection.Value != null)
+ {
+ OnEnterInner();
+ }
+
+ Continue();
+ }
+
+ protected abstract void OnEnterInner();
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == integer.integerRef || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ return integer.Value.ToString() + " on " + collection.Value.name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs.meta
new file mode 100644
index 00000000..f9e38838
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseIntCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 328b7e125f24d5349be4fe583267ba1d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs
new file mode 100644
index 00000000..0183a54d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs
@@ -0,0 +1,50 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Base class for all FungusCollection commands that require a second collection of the same type
+ ///
+ [AddComponentMenu("")]
+ public abstract class CollectionBaseTwoCollectionCommand : CollectionBaseCommand
+ {
+ [SerializeField]
+ protected CollectionData rhsCollection;
+
+ public override void OnEnter()
+ {
+ if (collection.Value != null && rhsCollection.Value != null)
+ {
+ OnEnterInner();
+ }
+
+ Continue();
+ }
+
+ protected abstract void OnEnterInner();
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == rhsCollection.collectionRef || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ if (rhsCollection.Value == null)
+ return "Error: no variable selected";
+
+ if (collection.Value.ContainedType() != rhsCollection.Value.ContainedType())
+ {
+ return "Error: Collection types do not match. " + collection.Value.ContainedType().Name + " != " + rhsCollection.Value.ContainedType().Name;
+ }
+
+ return collection.Value.name + " , " + rhsCollection.Value.name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs.meta
new file mode 100644
index 00000000..593556c3
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseTwoCollectionCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c4010b5577069fc4cb9480f87ed3f73e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs
new file mode 100644
index 00000000..6744aaad
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs
@@ -0,0 +1,47 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Base class for all FungusCollection commands that require a compatible variable and an integer
+ ///
+ [AddComponentMenu("")]
+ public abstract class CollectionBaseVarAndIntCommand : CollectionBaseVarCommand
+ {
+ [SerializeField]
+ [VariableProperty(typeof(IntegerVariable))]
+ protected IntegerVariable integer;
+
+ public override void OnEnter()
+ {
+ if (collection.Value != null && variableToUse != null && integer != null)
+ {
+ OnEnterInner();
+ }
+
+ Continue();
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == integer || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ if (variableToUse == null)
+ return "Error: no variable selected";
+
+ if (integer == null)
+ return "Error: no integer selected";
+
+ return integer.Key + " on " + variableToUse.Key + " in " + collection.Value.name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs.meta
new file mode 100644
index 00000000..2cb1e4c0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarAndIntCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 561b53abc515d704d8845caa3b3ee26f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs
new file mode 100644
index 00000000..249e2d2c
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs
@@ -0,0 +1,54 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Base class for all FungusCollection commands that require a compatible variable type
+ ///
+ [AddComponentMenu("")]
+ public abstract class CollectionBaseVarCommand : CollectionBaseCommand, ICollectionCompatible
+ {
+ [SerializeField]
+ [VariableProperty(compatibleVariableName = "collection")]
+ protected Variable variableToUse;
+
+ public override void OnEnter()
+ {
+ if (collection.Value != null && variableToUse != null)
+ {
+ OnEnterInner();
+ }
+
+ Continue();
+ }
+
+ protected abstract void OnEnterInner();
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == variableToUse || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ if (variableToUse == null)
+ return "Error: no variable selected";
+
+ return variableToUse.Key + " to " + collection.Value.name;
+ }
+
+ bool ICollectionCompatible.IsVarCompatibleWithCollection(Variable variable, string compatibleWith)
+ {
+ if (compatibleWith == "collection")
+ return collection.Value == null ? false : collection.Value.IsElementCompatible(variable);
+ else
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs.meta
new file mode 100644
index 00000000..ee8dd1b5
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionBaseVarCommand.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fe12b6eb87e59984cb4122f978f11e45
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs
new file mode 100644
index 00000000..82c3b1cd
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs
@@ -0,0 +1,39 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Add an item to a collection
+ ///
+ [CommandInfo("Collection",
+ "Add",
+ "Add an item to a collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandAdd : CollectionBaseVarCommand
+ {
+ [Tooltip("Only add if the item does not already exist in the collection")]
+ [SerializeField]
+ protected BooleanData onlyIfUnique = new BooleanData(false);
+
+ protected override void OnEnterInner()
+ {
+ if (onlyIfUnique.Value)
+ collection.Value.AddUnique(variableToUse);
+ else
+ collection.Value.Add(variableToUse);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return onlyIfUnique.booleanRef == variable || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ return base.GetSummary() + (onlyIfUnique.Value ? " Unique" : "");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs.meta
new file mode 100644
index 00000000..9b6b0353
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAdd.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a30a3b6902ecde54ea81d503f6a2b27e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs
new file mode 100644
index 00000000..e31ae989
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs
@@ -0,0 +1,39 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Add all items in given rhs collection to target collection
+ ///
+ [CommandInfo("Collection",
+ "Add All",
+ "Add all items in given rhs collection to target collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandAddAll : CollectionBaseTwoCollectionCommand
+ {
+ [Tooltip("Only add if the item does not already exist in the collection")]
+ [SerializeField]
+ protected BooleanData onlyIfUnique = new BooleanData(false);
+
+ protected override void OnEnterInner()
+ {
+ if (onlyIfUnique.Value)
+ collection.Value.AddUnique(rhsCollection);
+ else
+ collection.Value.Add(rhsCollection);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return onlyIfUnique.booleanRef == variable || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ return base.GetSummary() + (onlyIfUnique.Value ? " Unique" : "");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs.meta
new file mode 100644
index 00000000..7f10b77f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandAddAll.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5688faa1580d8d147b59e18fcdd888ad
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs
new file mode 100644
index 00000000..19450f9f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs
@@ -0,0 +1,27 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Clears a target collection
+ ///
+ [CommandInfo("Collection",
+ "Clear",
+ "Clears a target collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandClear : CollectionBaseCommand
+ {
+ public override void OnEnter()
+ {
+ if (collection.Value != null)
+ {
+ collection.Value.Clear();
+ }
+
+ Continue();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs.meta
new file mode 100644
index 00000000..70c94b54
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandClear.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8b071472a9dcdc7469059042e2e6e50d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs
new file mode 100644
index 00000000..30e6fd80
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs
@@ -0,0 +1,37 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Does the collection contain the given variable
+ ///
+ [CommandInfo("Collection",
+ "Contains",
+ "Does the collection contain the given variable")]
+ [AddComponentMenu("")]
+ public class CollectionCommandContains : CollectionBaseVarCommand
+ {
+ [VariableProperty(typeof(BooleanVariable))]
+ protected BooleanVariable result;
+
+ protected override void OnEnterInner()
+ {
+ if (result == null)
+ {
+ Debug.LogWarning("No result var set");
+ }
+ else
+ {
+ result.Value = collection.Value.Contains(variableToUse);
+ }
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return result == variable || base.HasReference(variable);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs.meta
new file mode 100644
index 00000000..16c6438d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContains.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6bd67ee6ac8134b4e9aea26299040034
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs
new file mode 100644
index 00000000..8794e9f7
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs
@@ -0,0 +1,53 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Does target collection, contain all rhs collection items
+ ///
+ [CommandInfo("Collection",
+ "Contains All Of",
+ "Does target collection, contain all rhs collection items")]
+ [AddComponentMenu("")]
+ public class CollectionCommandContainsAll : CollectionBaseTwoCollectionCommand
+ {
+ [Tooltip("Do they have to be in the same order?")]
+ [SerializeField]
+ protected BooleanData inSameOrder = new BooleanData(false);
+
+ [VariableProperty(typeof(BooleanVariable))]
+ protected BooleanVariable result;
+
+ protected override void OnEnterInner()
+ {
+ if (result == null)
+ {
+ Debug.LogWarning("No result var set");
+ }
+ else
+ {
+ if (inSameOrder.Value)
+ {
+ result.Value = collection.Value.ContainsAllOfOrdered(rhsCollection.Value);
+ }
+ else
+ {
+ result.Value = collection.Value.ContainsAllOf(rhsCollection.Value);
+ }
+ }
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return result == variable || inSameOrder.booleanRef == variable || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ return base.GetSummary() + (inSameOrder.Value ? " Ordered" : "");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs.meta
new file mode 100644
index 00000000..31913dea
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAll.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1df2de5cf986f9d419a124bb9d834b11
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs
new file mode 100644
index 00000000..26ef61da
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs
@@ -0,0 +1,37 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Does target collection, contain any of the items in the rhs collection items
+ ///
+ [CommandInfo("Collection",
+ "Contains Any Of",
+ "Does target collection, contain any of the items in the rhs collection items")]
+ [AddComponentMenu("")]
+ public class CollectionCommandContainsAny : CollectionBaseTwoCollectionCommand
+ {
+ [VariableProperty(typeof(BooleanVariable))]
+ protected BooleanVariable result;
+
+ protected override void OnEnterInner()
+ {
+ if (result == null)
+ {
+ Debug.LogWarning("No result var set");
+ }
+ else
+ {
+ result.Value = collection.Value.ContainsAnyOf(rhsCollection.Value);
+ }
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return result == variable || base.HasReference(variable);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs.meta
new file mode 100644
index 00000000..9522c299
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandContainsAny.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c4e05f36271510b41a7d7889025e180e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs
new file mode 100644
index 00000000..09663e32
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Clears target and then adds all of rhs to target.
+ ///
+ [CommandInfo("Collection",
+ "Copy",
+ "Clears target and then adds all of rhs to target.")]
+ [AddComponentMenu("")]
+ public class CollectionCommandCopy : CollectionBaseTwoCollectionCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.CopyFrom(rhsCollection.Value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs.meta
new file mode 100644
index 00000000..e0a122e8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCopy.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 820324be5b6a927469519df54a9bbad0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs
new file mode 100644
index 00000000..81a4d221
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs
@@ -0,0 +1,25 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Number of items in the collection
+ ///
+ [CommandInfo("Collection",
+ "Count",
+ "Number of items in the collection")]
+ [CommandInfo("Collection",
+ "Length",
+ "Number of items in the collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandCount : CollectionBaseIntCommand
+ {
+ protected override void OnEnterInner()
+ {
+ integer.Value = collection.Value.Count;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs.meta
new file mode 100644
index 00000000..d264f4a0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandCount.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 31765259d3ac50e4993fd654cd7ea78b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs
new file mode 100644
index 00000000..81831411
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs
@@ -0,0 +1,53 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Get or Set, an element in a collection
+ ///
+ [CommandInfo("Collection",
+ "Element",
+ "Get or Set, an element in a collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandElement : CollectionBaseVarCommand
+ {
+ public enum GetSet
+ {
+ Get,
+ Set,
+ }
+
+ [SerializeField]
+ protected IntegerData index;
+
+ [SerializeField]
+ protected GetSet getset = GetSet.Get;
+
+ protected override void OnEnterInner()
+ {
+ if (index.Value >= 0 && index.Value < collection.Value.Count)
+ {
+ if (getset == GetSet.Get)
+ {
+ collection.Value.Get(index.Value, ref variableToUse);
+ }
+ else
+ {
+ collection.Value.Set(index.Value, variableToUse);
+ }
+ }
+ else
+ {
+ throw new System.ArgumentOutOfRangeException();
+ }
+ }
+
+ public override string GetSummary()
+ {
+ return base.GetSummary() + " " + getset.ToString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs.meta
new file mode 100644
index 00000000..d2b11379
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandElement.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: bf40659a274400d40856f146223798ac
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs
new file mode 100644
index 00000000..dcc396b8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs
@@ -0,0 +1,24 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Remove all items from collection that are also in RHS and add all the items in RHS that are not already
+ /// in target. Similar to a xor
+ ///
+ [CommandInfo("Collection",
+ "Exclusive",
+ "Remove all items from collection that are also in RHS and add all the items in RHS that are not already in target. " +
+ "Similar to a xor")]
+ [AddComponentMenu("")]
+ public class CollectionCommandExclusive : CollectionBaseTwoCollectionCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.Exclusive(rhsCollection.Value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs.meta
new file mode 100644
index 00000000..e4730cf8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandExclusive.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 824e24d12ca84774ea135507417e94a1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs
new file mode 100644
index 00000000..b4927e6b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs
@@ -0,0 +1,41 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Find an item in a collection
+ ///
+ [CommandInfo("Collection",
+ "Find",
+ "Find an item in a collection")]
+ [CommandInfo("Collection",
+ "IndexOf",
+ "Find an item in a collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandFind : CollectionBaseVarAndIntCommand
+ {
+ [Tooltip("If true, will find the last occurance rather than first occurance.")]
+ [SerializeField]
+ protected BooleanData lastInsteadOfFirst = new BooleanData(false);
+
+ protected override void OnEnterInner()
+ {
+ integer.Value = !lastInsteadOfFirst.Value ?
+ collection.Value.IndexOf(variableToUse)
+ : collection.Value.LastIndexOf(variableToUse);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return lastInsteadOfFirst.booleanRef == variable || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ return base.GetSummary() + (lastInsteadOfFirst.Value ? " Last" : "");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs.meta
new file mode 100644
index 00000000..cc1ad6b8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandFind.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 59afe81b26e37ea4ea10dd91dfeee937
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs
new file mode 100644
index 00000000..9a4fe83b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Add at a specific location in the collection
+ ///
+ [CommandInfo("Collection",
+ "Insert",
+ "Add at a specific location in the collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandInsert : CollectionBaseVarAndIntCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.Insert(integer.Value, variableToUse);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs.meta
new file mode 100644
index 00000000..6623d389
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandInsert.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: dd126ef47d8264a4d8a6aac5b4f3fb12
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs
new file mode 100644
index 00000000..433560e9
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Remove all items from collection that aren't also in RHS, similar to an overlap.
+ ///
+ [CommandInfo("Collection",
+ "Intersection",
+ "Remove all items from collection that aren't also in RHS, similar to an overlap.")]
+ [AddComponentMenu("")]
+ public class CollectionCommandIntersection : CollectionBaseTwoCollectionCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.Intersection(rhsCollection.Value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs.meta
new file mode 100644
index 00000000..6fefadb5
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandIntersection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 586c189d813b1b045ba358c612f4a6eb
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs
new file mode 100644
index 00000000..da2034bd
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// How many occurrences of a given variable exist in a target collection
+ ///
+ [CommandInfo("Collection",
+ "Occurrences",
+ "How many occurrences of a given variable exist in a target collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandOccurrences : CollectionBaseVarAndIntCommand
+ {
+ protected override void OnEnterInner()
+ {
+ integer.Value = collection.Value.Occurrences(variableToUse);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs.meta
new file mode 100644
index 00000000..b1b5323f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandOccurrences.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 75a3711bc9cd44e429e15e10f6029fae
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs
new file mode 100644
index 00000000..48506878
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs
@@ -0,0 +1,39 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Remove an item to a collection
+ ///
+ [CommandInfo("Collection",
+ "Remove",
+ "Remove an item to a collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandRemove : CollectionBaseVarCommand
+ {
+ [Tooltip("Should it remove ALL occurances of variable")]
+ [SerializeField]
+ protected BooleanData allOccurances = new BooleanData(false);
+
+ protected override void OnEnterInner()
+ {
+ if (allOccurances.Value)
+ collection.Value.RemoveAll(variableToUse);
+ else
+ collection.Value.Remove(variableToUse);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return allOccurances.booleanRef == variable || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ return base.GetSummary() + (allOccurances.Value ? " ALL" : "");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs.meta
new file mode 100644
index 00000000..6eb78967
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemove.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6e2313a05ce56ea49bbf1922b58d793a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs
new file mode 100644
index 00000000..729f8eec
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Remove all items in given rhs collection to target collection
+ ///
+ [CommandInfo("Collection",
+ "Remove All Of",
+ "Remove all items in given rhs collection to target collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandRemoveAllOf : CollectionBaseTwoCollectionCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.RemoveAll(rhsCollection);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs.meta
new file mode 100644
index 00000000..ea63a58b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAllOf.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2bb49f43c99a0af4db604a1770b31e83
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs
new file mode 100644
index 00000000..2464277c
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Remove item at given index
+ ///
+ [CommandInfo("Collection",
+ "Remove At",
+ "Remove item at given index")]
+ [AddComponentMenu("")]
+ public class CollectionCommandRemoveAt : CollectionBaseIntCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.RemoveAt(integer.Value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs.meta
new file mode 100644
index 00000000..d2f4ff50
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandRemoveAt.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c8ee8f64433f29a4f82b03a8e6550ae2
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs
new file mode 100644
index 00000000..71c287d9
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Reserve space for given number of items in the collection
+ ///
+ [CommandInfo("Collection",
+ "Reserve",
+ "Reserve space for given number of items in the collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandReserve : CollectionBaseIntCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.Reserve(integer.Value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs.meta
new file mode 100644
index 00000000..8c443131
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReserve.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4672406760fa8f340aabac4528f04c1c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs
new file mode 100644
index 00000000..108b37fd
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Resize will grow the collection to be the given size, will not remove items to shrink
+ ///
+ [CommandInfo("Collection",
+ "Resize",
+ "Resize will grow the collection to be the given size, will not remove items to shrink")]
+ [AddComponentMenu("")]
+ public class CollectionCommandResize : CollectionBaseIntCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.Resize(integer.Value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs.meta
new file mode 100644
index 00000000..413f91fe
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandResize.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3ce11d7cce59a3340937a8d112cd4ad5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs
new file mode 100644
index 00000000..6a0623db
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs
@@ -0,0 +1,27 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Reverse the current order of a target collection
+ ///
+ [CommandInfo("Collection",
+ "Reverse",
+ "Reverse the current order of a target collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandReverse : CollectionBaseCommand
+ {
+ public override void OnEnter()
+ {
+ if (collection.Value != null)
+ {
+ collection.Value.Reverse();
+ }
+
+ Continue();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs.meta
new file mode 100644
index 00000000..20b9f67b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandReverse.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d7359fcb744d14a41acae4b3a2e34b73
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs
new file mode 100644
index 00000000..28749926
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs
@@ -0,0 +1,27 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Randomly reorders all elements of a target collection
+ ///
+ [CommandInfo("Collection",
+ "Shuffle",
+ "Randomly reorders all elements of a target collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandShuffle : CollectionBaseCommand
+ {
+ public override void OnEnter()
+ {
+ if (collection.Value != null)
+ {
+ collection.Value.Shuffle();
+ }
+
+ Continue();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs.meta
new file mode 100644
index 00000000..253917e4
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandShuffle.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a15d511e013edfe45a0a4726bda90c8f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs
new file mode 100644
index 00000000..a03926bb
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs
@@ -0,0 +1,27 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Sort a target collection
+ ///
+ [CommandInfo("Collection",
+ "Sort",
+ "Sort a target collection")]
+ [AddComponentMenu("")]
+ public class CollectionCommandSort : CollectionBaseCommand
+ {
+ public override void OnEnter()
+ {
+ if (collection.Value != null)
+ {
+ collection.Value.Sort();
+ }
+
+ Continue();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs.meta
new file mode 100644
index 00000000..69fe1e7a
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandSort.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 00093f39e8583954ba5935bca806f0f1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs
new file mode 100644
index 00000000..40ab2605
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs
@@ -0,0 +1,27 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Removes all duplicates.
+ ///
+ [CommandInfo("Collection",
+ "Unique",
+ "Removes all duplicates.")]
+ [AddComponentMenu("")]
+ public class CollectionCommandUnique : CollectionBaseCommand
+ {
+ public override void OnEnter()
+ {
+ if (collection.Value != null)
+ {
+ collection.Value.Unique();
+ }
+
+ Continue();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs.meta
new file mode 100644
index 00000000..a8c45c32
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionCommandUnique.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 59ae026a39db9cf4d8453309fa6192db
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs
new file mode 100644
index 00000000..2a149cde
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs
@@ -0,0 +1,22 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Use the collection as a source of random selection. Picking a random item each run.
+ ///
+ [CommandInfo("Collection",
+ "RandomItem",
+ "Use the collection as a source of random selection. Picking a random item each run.")]
+ [AddComponentMenu("")]
+ public class CollectionRandom : CollectionBaseVarCommand
+ {
+ protected override void OnEnterInner()
+ {
+ collection.Value.Get(Random.Range(0, collection.Value.Count - 1), ref variableToUse);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs.meta
new file mode 100644
index 00000000..0b589499
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandom.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d58ddca8952c1a149a39835e2eeac9a7
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs
new file mode 100644
index 00000000..3a95c85a
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs
@@ -0,0 +1,80 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Use the collection as a source of random items and turn it into a random bag. Drawing the
+ /// next random item until out of items and then reshuffling them.
+ ///
+ [CommandInfo("Collection",
+ "RandomBag",
+ "Use the collection as a source of random items and turn it into a random bag. " +
+ "Drawing the next random item until out of items and then reshuffling them.")]
+ [AddComponentMenu("")]
+ public class CollectionRandomBag : CollectionBaseVarCommand
+ {
+ [SerializeField]
+ [Tooltip("Will add this many copies to the bag. If you want 5 of everything, you want 4 copies.")]
+ protected IntegerData duplicatesToPutInBag = new IntegerData(0);
+
+ [SerializeField]
+ protected IntegerData currentIndex = new IntegerData(int.MaxValue);
+
+ protected bool isInit = false;
+
+ protected override void OnEnterInner()
+ {
+ if (!isInit)
+ {
+ Init();
+ }
+
+ currentIndex.Value++;
+
+ if (currentIndex.Value >= collection.Value.Count)
+ {
+ Reshuffle();
+ }
+
+ collection.Value.Get(currentIndex.Value, ref variableToUse);
+ }
+
+ protected void Init()
+ {
+ var startingCount = collection.Value.Count;
+ for (int i = 0; i < duplicatesToPutInBag.Value; i++)
+ {
+ for (int j = 0; j < startingCount; j++)
+ {
+ collection.Value.Add(collection.Value.Get(j));
+ }
+ }
+
+ //force invalid index
+ currentIndex.Value = collection.Value.Count;
+
+ isInit = true;
+ }
+
+ protected void Reshuffle()
+ {
+ currentIndex.Value = 0;
+ collection.Value.Shuffle();
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return base.HasReference(variable) || duplicatesToPutInBag.integerRef == variable || currentIndex.integerRef;
+ }
+
+ public override string GetSummary()
+ {
+ return base.GetSummary() +
+ (duplicatesToPutInBag.integerRef != null ? " " + duplicatesToPutInBag.integerRef.Key : "") +
+ (currentIndex.integerRef != null ? " " + currentIndex.integerRef.Key : ""); ;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs.meta
new file mode 100644
index 00000000..2b992196
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/CollectionRandomBag.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 56176eef6b396a442b08b88220304436
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/ForEach.cs b/Assets/Fungus/Scripts/Commands/Collection/ForEach.cs
new file mode 100644
index 00000000..f3f27ce6
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/ForEach.cs
@@ -0,0 +1,90 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Loop over each element in the given collection.
+ ///
+ [CommandInfo("Collection",
+ "For Each",
+ "Loop over each element in the given collection, similar to a foreach but internally uses indicies")]
+ [AddComponentMenu("")]
+ public class ForEach : Condition, ICollectionCompatible
+ {
+ [SerializeField]
+ protected CollectionData collection;
+
+ [SerializeField]
+ [VariableProperty(compatibleVariableName = "collection")]
+ protected Variable item;
+
+ [SerializeField]
+ [Tooltip("Optional")]
+ protected IntegerData curIndex;
+
+ #region Public members
+
+ public override bool IsLooping { get { return true; } }
+
+ protected override void PreEvaluate()
+ {
+ //if we came from the end then we are already looping, if not this is first loop so prep
+ if (ParentBlock.PreviousActiveCommandIndex != endCommand.CommandIndex)
+ {
+ curIndex.Value = -1;
+ }
+ }
+
+ protected override bool EvaluateCondition()
+ {
+ var col = collection.Value;
+ curIndex.Value++;
+ if (curIndex < col.Count)
+ {
+ col.Get(curIndex, ref item);
+ return true;
+ }
+
+ return false;
+ }
+
+ protected override void OnFalse()
+ {
+ MoveToEnd();
+ }
+
+ protected override bool HasNeededProperties()
+ {
+ return collection.Value != null && item != null;
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return collection.collectionRef == variable || item == variable ||
+ base.HasReference(variable);
+ }
+
+ bool ICollectionCompatible.IsVarCompatibleWithCollection(Variable variable, string compatibleWith)
+ {
+ if (compatibleWith == "collection")
+ return collection.Value == null ? false : collection.Value.IsElementCompatible(variable);
+ else
+ return true;
+ }
+
+ public override string GetSummary()
+ {
+ if (item == null)
+ return "Error: No item var";
+ if (collection.Value == null)
+ return "Error: No collection";
+
+ return item.Key + " in " + collection.Value.name;
+ }
+
+ #endregion Public members
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/ForEach.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/ForEach.cs.meta
new file mode 100644
index 00000000..2c7276c4
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/ForEach.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1ce547d5384ce3a41b7142cab8ab41dd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs b/Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs
new file mode 100644
index 00000000..7236defd
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs
@@ -0,0 +1,51 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ [CommandInfo("GameObject",
+ "FindAll",
+ "Find all gameobjects by tag and store in a collection")]
+ [AddComponentMenu("")]
+ public class GameObjectFind : CollectionBaseCommand
+ {
+ [Tooltip("Find all gameobjects of tag")]
+ [SerializeField]
+ protected StringData tagString;
+
+ public override void OnEnter()
+ {
+ var col = collection.Value;
+
+ if (col != null)
+ {
+ var res = GameObject.FindGameObjectsWithTag(tagString.Value);
+
+ for (int i = 0; i < res.Length; i++)
+ {
+ col.Add(res[i]);
+ }
+ }
+
+ Continue();
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == tagString.stringRef || base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ if (!(collection.Value is GameObjectCollection))
+ return "Error: collection is not GameObjectCollection";
+
+ return tagString.Value + " GOs, store in " + collection.Value.name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs.meta
new file mode 100644
index 00000000..7a5bb5c4
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/GameObjectFind.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8509f58e038dd8c46b98cab78d34e06a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs b/Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs
new file mode 100644
index 00000000..84e753d4
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs
@@ -0,0 +1,162 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ [CommandInfo("Physics2D",
+ "Cast2D",
+ "Find all gameobjects hit by given physics shape overlap")]
+ [AddComponentMenu("")]
+ public class Physics2DCast : CollectionBaseCommand
+ {
+ public enum CastType
+ {
+ Box,
+ Capsule,
+ Circle,
+ Line,
+ Ray,
+ }
+
+ [Tooltip("")]
+ [SerializeField]
+ protected CastType castType = CastType.Ray;
+
+ [Tooltip("Starting point or centre of shape")]
+ [SerializeField]
+ protected Vector3Data position1;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected Vector3Data direction;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected FloatData maxDistance = new FloatData(float.PositiveInfinity);
+
+ [Tooltip("CAPSULE & Circle ONLY")]
+ [SerializeField]
+ protected FloatData radius = new FloatData(0.5f);
+
+ [Tooltip("BOX & CAPSULE ONLY")]
+ [SerializeField]
+ protected Vector3Data shapeSize = new Vector3Data(Vector3.one * 0.5f);
+
+ [Tooltip("BOX & CAPSULE ONLY")]
+ [SerializeField]
+ protected FloatData shapeAngle;
+
+ [Tooltip("LINE ONLY")]
+ [SerializeField]
+ protected Vector3Data lineEnd;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected LayerMask layerMask = ~0;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected FloatData minDepth = new FloatData(float.NegativeInfinity), maxDepth = new FloatData(float.PositiveInfinity);
+
+ [SerializeField]
+ protected CapsuleDirection2D capsuleDirection;
+
+ public override void OnEnter()
+ {
+ var col = collection.Value;
+
+ if (col != null)
+ {
+ RaycastHit2D[] resHits = null;
+
+ switch (castType)
+ {
+ case CastType.Box:
+ resHits = Physics2D.BoxCastAll(position1.Value, shapeSize.Value, shapeAngle.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case CastType.Capsule:
+ resHits = Physics2D.CapsuleCastAll(position1.Value, shapeSize.Value, capsuleDirection, shapeAngle.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case CastType.Circle:
+ resHits = Physics2D.CircleCastAll(position1.Value, radius.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case CastType.Line:
+ resHits = Physics2D.LinecastAll(position1.Value, lineEnd.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case CastType.Ray:
+ resHits = Physics2D.RaycastAll(position1.Value, direction.Value, maxDistance.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ default:
+ break;
+ }
+
+ PutCollidersIntoGameObjectCollection(resHits);
+ }
+
+ Continue();
+ }
+
+ protected void PutCollidersIntoGameObjectCollection(RaycastHit2D[] resColliders)
+ {
+ if (resColliders != null)
+ {
+ var col = collection.Value;
+ for (int i = 0; i < resColliders.Length; i++)
+ {
+ col.Add(resColliders[i].collider.gameObject);
+ }
+ }
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == position1.vector3Ref ||
+ variable == radius.floatRef ||
+ variable == shapeSize.vector3Ref ||
+ variable == shapeAngle.floatRef ||
+ variable == minDepth.floatRef ||
+ variable == maxDepth.floatRef ||
+ variable == direction.vector3Ref ||
+ variable == maxDistance.floatRef ||
+ variable == lineEnd.vector3Ref ||
+ base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ //TODO we could support more than just GOs
+ if (!(collection.Value is GameObjectCollection))
+ return "Error: collection is not GameObjectCollection";
+
+ return castType.ToString() + ", store in " + collection.Value.name;
+ }
+
+ public override bool IsPropertyVisible(string propertyName)
+ {
+ if (castType == CastType.Capsule && propertyName == "capsulePosition2")
+ return true;
+
+ if (castType == CastType.Line && propertyName == "lineEnd")
+ return true;
+
+ if ((castType == CastType.Capsule || castType == CastType.Circle) && propertyName == "radius")
+ return true;
+
+ if ((castType == CastType.Capsule || castType == CastType.Box) &&
+ (propertyName == "shapeAngle" || propertyName == "shapeSize"))
+ return true;
+
+ return base.IsPropertyVisible(propertyName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs.meta
new file mode 100644
index 00000000..994c591e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/Physics2DCast.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: da8de59f5960f5c4b9d61002cc912b37
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs b/Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs
new file mode 100644
index 00000000..24da6545
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs
@@ -0,0 +1,154 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ [CommandInfo("Physics2D",
+ "Overlap2D",
+ "Find all gameobjects hit by given physics shape overlap")]
+ [AddComponentMenu("")]
+ public class Physics2DOverlap : CollectionBaseCommand
+ {
+ public enum Shape
+ {
+ Point,
+ Area,
+ Box,
+ Circle,
+ Capsule,
+ }
+
+ [Tooltip("")]
+ [SerializeField]
+ protected Shape shape = Shape.Box;
+
+ [Tooltip("Starting point or centre of shape")]
+ [SerializeField]
+ protected Vector3Data position1;
+
+ [Tooltip("AREA ONLY")]
+ [SerializeField]
+ protected Vector3Data areaEndPosition;
+
+ [Tooltip("CAPSULE & Circle ONLY")]
+ [SerializeField]
+ protected FloatData radius = new FloatData(0.5f);
+
+ [Tooltip("BOX & CAPSULE ONLY")]
+ [SerializeField]
+ protected Vector3Data shapeSize = new Vector3Data(Vector3.one * 0.5f);
+
+ [Tooltip("BOX & CAPSULE ONLY")]
+ [SerializeField]
+ protected FloatData shapeAngle;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected LayerMask layerMask = ~0;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected FloatData minDepth = new FloatData(float.NegativeInfinity), maxDepth = new FloatData(float.PositiveInfinity);
+
+ [SerializeField]
+ protected CapsuleDirection2D capsuleDirection;
+
+ public override void OnEnter()
+ {
+ var col = collection.Value;
+
+ if (col != null)
+ {
+ Collider2D[] resColliders = null;
+
+ switch (shape)
+ {
+ case Shape.Area:
+ resColliders = Physics2D.OverlapAreaAll(position1.Value, areaEndPosition.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case Shape.Box:
+ resColliders = Physics2D.OverlapBoxAll(position1.Value, shapeSize.Value, shapeAngle.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case Shape.Circle:
+ resColliders = Physics2D.OverlapCircleAll(position1.Value, radius.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case Shape.Capsule:
+ resColliders = Physics2D.OverlapCapsuleAll(position1.Value, shapeSize.Value, capsuleDirection, shapeAngle.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ case Shape.Point:
+ resColliders = Physics2D.OverlapPointAll(position1.Value, layerMask.value, minDepth.Value, maxDepth.Value);
+ break;
+
+ default:
+ break;
+ }
+
+ PutCollidersIntoGameObjectCollection(resColliders);
+ }
+
+ Continue();
+ }
+
+ protected void PutCollidersIntoGameObjectCollection(Collider2D[] resColliders)
+ {
+ if (resColliders != null)
+ {
+ var col = collection.Value;
+ for (int i = 0; i < resColliders.Length; i++)
+ {
+ col.Add(resColliders[i].gameObject);
+ }
+ }
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == position1.vector3Ref ||
+ variable == areaEndPosition.vector3Ref ||
+ variable == radius.floatRef ||
+ variable == shapeSize.vector3Ref ||
+ variable == shapeAngle.floatRef ||
+ variable == minDepth.floatRef ||
+ variable == maxDepth.floatRef ||
+ base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ //TODO we could support more than just GOs
+ if (!(collection.Value is GameObjectCollection))
+ return "Error: collection is not GameObjectCollection";
+
+ return shape.ToString() + ", store in " + collection.Value.name;
+ }
+
+ public override bool IsPropertyVisible(string propertyName)
+ {
+ if (shape == Shape.Capsule && propertyName == "capsulePosition2")
+ return true;
+
+ if (shape == Shape.Area && propertyName == "areaEndPosition")
+ return true;
+
+ if ((shape == Shape.Capsule || shape == Shape.Circle) && propertyName == "radius")
+ return true;
+
+ if ((shape == Shape.Capsule || shape == Shape.Box) && propertyName == "shapeAngle")
+ return true;
+
+ if (shape == Shape.Box && (propertyName == "boxHalfExtends" || propertyName == "boxOrientation"))
+ return true;
+
+ return base.IsPropertyVisible(propertyName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs.meta
new file mode 100644
index 00000000..2369aac0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/Physics2DOverlap.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c27aec18d802f45429190093660305e4
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs b/Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs
new file mode 100644
index 00000000..f5b145e7
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs
@@ -0,0 +1,147 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ [CommandInfo("Physics",
+ "Cast",
+ "Find all gameobjects hit by given physics shape cast")]
+ [AddComponentMenu("")]
+ public class PhysicsCast : CollectionBaseCommand
+ {
+ public enum CastType
+ {
+ Box,
+ Capsule,
+ Ray,
+ Sphere,
+ }
+
+ [SerializeField]
+ protected CastType castType = CastType.Ray;
+
+ [Tooltip("Starting point/origin or centre of shape")]
+ [SerializeField]
+ protected Vector3Data position1;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected Vector3Data direction;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected FloatData maxDistance = new FloatData(float.PositiveInfinity);
+
+ [Tooltip("CAPSULE ONLY; end point of the capsule")]
+ [SerializeField]
+ protected Vector3Data capsulePosition2;
+
+ [Tooltip("CAPSULE & SPHERE ONLY")]
+ [SerializeField]
+ protected FloatData radius = new FloatData(0.5f);
+
+ [Tooltip("BOX ONLY")]
+ [SerializeField]
+ protected Vector3Data boxHalfExtends = new Vector3Data(Vector3.one * 0.5f);
+
+ [Tooltip("BOX ONLY")]
+ [SerializeField]
+ protected QuaternionData boxOrientation = new QuaternionData(Quaternion.identity);
+
+ [Tooltip("")]
+ [SerializeField]
+ protected LayerMask layerMask = ~0;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal;
+
+ public override void OnEnter()
+ {
+ var col = collection.Value;
+
+ if (col != null)
+ {
+ RaycastHit[] resHits = null;
+
+ switch (castType)
+ {
+ case CastType.Ray:
+ resHits = Physics.RaycastAll(position1.Value, direction.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
+ break;
+
+ case CastType.Sphere:
+ resHits = Physics.SphereCastAll(position1.Value, radius.Value, direction.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
+ break;
+
+ case CastType.Box:
+ resHits = Physics.BoxCastAll(position1.Value, boxHalfExtends.Value, direction.Value, boxOrientation.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
+ break;
+
+ case CastType.Capsule:
+ resHits = Physics.CapsuleCastAll(position1.Value, capsulePosition2.Value, radius.Value, direction.Value, maxDistance.Value, layerMask.value, queryTriggerInteraction);
+ break;
+
+ default:
+ break;
+ }
+
+ PutCollidersIntoGameObjectCollection(resHits);
+ }
+
+ Continue();
+ }
+
+ protected void PutCollidersIntoGameObjectCollection(RaycastHit[] resHits)
+ {
+ if (resHits != null)
+ {
+ var col = collection.Value;
+ for (int i = 0; i < resHits.Length; i++)
+ {
+ col.Add(resHits[i].collider.gameObject);
+ }
+ }
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == direction.vector3Ref ||
+ variable == maxDistance.floatRef ||
+ variable == position1.vector3Ref ||
+ variable == capsulePosition2.vector3Ref ||
+ variable == radius.floatRef ||
+ variable == boxHalfExtends.vector3Ref ||
+ variable == boxOrientation.quaternionRef ||
+ base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ //TODO we could support more than just GOs
+ if (!(collection.Value is GameObjectCollection))
+ return "Error: collection is not GameObjectCollection";
+
+ return castType.ToString() + ", store in " + collection.Value.name;
+ }
+
+ public override bool IsPropertyVisible(string propertyName)
+ {
+ if (castType == CastType.Capsule && propertyName == "capsulePosition2")
+ return true;
+
+ if ((castType == CastType.Capsule || castType == CastType.Sphere) && propertyName == "radius")
+ return true;
+
+ if (castType == CastType.Box && (propertyName == "boxHalfExtends" || propertyName == "boxOrientation"))
+ return true;
+
+ return base.IsPropertyVisible(propertyName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs.meta
new file mode 100644
index 00000000..272dbd8d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/PhysicsCast.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 44a4b238cb3af004bbae4a6145089ea2
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs b/Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs
new file mode 100644
index 00000000..1cb6e79e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs
@@ -0,0 +1,136 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ ///
+ ///
+ [CommandInfo("Physics",
+ "Overlap",
+ "Find all gameobjects hit by given physics shape overlap")]
+ [AddComponentMenu("")]
+ public class PhysicsOverlap : CollectionBaseCommand
+ {
+ public enum Shape
+ {
+ Box,
+ Capsule,
+ Sphere,
+ }
+
+ [Tooltip("")]
+ [SerializeField]
+ protected Shape shape = Shape.Box;
+
+ [Tooltip("Starting point or centre of shape")]
+ [SerializeField]
+ protected Vector3Data position1;
+
+ [Tooltip("CAPSULE ONLY; end point of the capsule")]
+ [SerializeField]
+ protected Vector3Data capsulePosition2;
+
+ [Tooltip("CAPSULE & SPHERE ONLY")]
+ [SerializeField]
+ protected FloatData radius = new FloatData(0.5f);
+
+ [Tooltip("BOX ONLY")]
+ [SerializeField]
+ protected Vector3Data boxHalfExtends = new Vector3Data(Vector3.one * 0.5f);
+
+ [Tooltip("BOX ONLY")]
+ [SerializeField]
+ protected QuaternionData boxOrientation = new QuaternionData(Quaternion.identity);
+
+ [Tooltip("")]
+ [SerializeField]
+ protected LayerMask layerMask = ~0;
+
+ [Tooltip("")]
+ [SerializeField]
+ protected QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal;
+
+ public override void OnEnter()
+ {
+ var col = collection.Value;
+
+ if (col != null)
+ {
+ Collider[] resColliders = null;
+
+ switch (shape)
+ {
+ case Shape.Box:
+ resColliders = Physics.OverlapBox(position1.Value, boxHalfExtends.Value, boxOrientation.Value, layerMask.value, queryTriggerInteraction);
+ break;
+
+ case Shape.Sphere:
+ resColliders = Physics.OverlapSphere(position1.Value, radius.Value, layerMask.value, queryTriggerInteraction);
+ break;
+
+ case Shape.Capsule:
+ resColliders = Physics.OverlapCapsule(position1.Value, capsulePosition2.Value, radius.Value, layerMask.value, queryTriggerInteraction);
+ break;
+
+ default:
+ break;
+ }
+
+ PutCollidersIntoGameObjectCollection(resColliders);
+ }
+
+ Continue();
+ }
+
+ protected void PutCollidersIntoGameObjectCollection(Collider[] resColliders)
+ {
+ if (resColliders != null)
+ {
+ var col = collection.Value;
+ for (int i = 0; i < resColliders.Length; i++)
+ {
+ col.Add(resColliders[i].gameObject);
+ }
+ }
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == position1.vector3Ref ||
+ variable == capsulePosition2.vector3Ref ||
+ variable == radius.floatRef ||
+ variable == boxHalfExtends.vector3Ref ||
+ variable == boxOrientation.quaternionRef ||
+ base.HasReference(variable);
+ }
+
+ public override string GetSummary()
+ {
+ if (collection.Value == null)
+ return "Error: no collection selected";
+
+ //TODO we could support more than just GOs
+ if (!(collection.Value is GameObjectCollection))
+ return "Error: collection is not GameObjectCollection";
+
+ return shape.ToString() + ", store in " + collection.Value.name;
+ }
+
+ public override bool IsPropertyVisible(string propertyName)
+ {
+ if (shape == Shape.Capsule && propertyName == "capsulePosition2")
+ return true;
+
+ if ((shape == Shape.Capsule || shape == Shape.Sphere) && propertyName == "radius")
+ return true;
+
+ if (shape == Shape.Box && (propertyName == "boxHalfExtends" || propertyName == "boxOrientation"))
+ return true;
+
+ return base.IsPropertyVisible(propertyName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs.meta b/Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs.meta
new file mode 100644
index 00000000..57665f64
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Collection/PhysicsOverlap.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5996bc0e902a19f4fa257341b0691de3
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Comment.cs b/Assets/Fungus/Scripts/Commands/Comment.cs
index 66686c02..ac6bd3f6 100644
--- a/Assets/Fungus/Scripts/Commands/Comment.cs
+++ b/Assets/Fungus/Scripts/Commands/Comment.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Condition.cs b/Assets/Fungus/Scripts/Commands/Condition.cs
index 26e14bc8..5af13b89 100644
--- a/Assets/Fungus/Scripts/Commands/Condition.cs
+++ b/Assets/Fungus/Scripts/Commands/Condition.cs
@@ -1,118 +1,166 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
+ ///
+ /// Base for all Conditional based Commands, Ifs, Loops, and so on.
+ ///
[AddComponentMenu("")]
public abstract class Condition : Command
{
- public static string GetOperatorDescription(CompareOperator compareOperator)
+ protected End endCommand;
+
+ public override void OnEnter()
{
- string summary = "";
- switch (compareOperator)
+ if (ParentBlock == null)
{
- case CompareOperator.Equals:
- summary += "==";
- break;
- case CompareOperator.NotEquals:
- summary += "!=";
- break;
- case CompareOperator.LessThan:
- summary += "<";
- break;
- case CompareOperator.GreaterThan:
- summary += ">";
- break;
- case CompareOperator.LessThanOrEquals:
- summary += "<=";
- break;
- case CompareOperator.GreaterThanOrEquals:
- summary += ">=";
- break;
+ return;
}
- return summary;
- }
-
- #region Public members
-
- public override void OnEnter()
- {
-
- if (ParentBlock == null)
+ //if looping we need the end command in order to work
+ if(IsLooping && !EnsureRequiredEnd())
{
+ Debug.LogError(GetLocationIdentifier() + " is looping but has no matching End command");
+ Continue();
return;
}
- if( !HasNeededProperties() )
+ if ( !HasNeededProperties() )
{
+ Debug.LogError(GetLocationIdentifier() + " cannot run due to missing required properties");
Continue();
return;
}
- if( !this.IsElseIf )
+ //Ensuring we arrived at this elif honestly, not incorrectly due to fall through from a previous command
+ if (this.IsElseIf && !DoesPassElifSanityCheck())
+ {
+ //elif is being asked to run but didn't come from a previously failing if or elif, this isn't allowed
+ MoveToEnd();
+ return;
+ }
+
+ EvaluateAndContinue();
+ }
+
+ public override bool OpenBlock()
+ {
+ return true;
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(253, 253, 150, 255);
+ }
+
+ public virtual bool IsLooping { get { return false; } }
+
+
+ ///
+ /// Moves execution to the closing End of the current command, attempts to locate end if not
+ /// already known and if no closing End exists.
+ ///
+ public virtual void MoveToEnd()
+ {
+ if(endCommand == null)
+ {
+ endCommand = FindOurEndCommand();
+ }
+
+ if (endCommand != null)
{
- EvaluateAndContinue();
+ // Continue at next command after End
+ // and make the end non looping incase it gets run via index etc.
+ endCommand.Loop = false;
+ Continue(endCommand.CommandIndex + 1);
}
else
{
- System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();
- var prevCmdIndent = ParentBlock.GetPreviousActiveCommandIndent();
+ //nowhere to go, so we assume the block wants to stop but is missing and end, this
+ // is also ensures back compat
+ Debug.LogWarning("Condition wants to move to end but no End command found, stopping block. " + GetLocationIdentifier());
+ StopParentBlock();
+ }
+ }
- //handle our matching if or else if in the chain failing and moving to us,
- // need to make sure it is the same indent level
- if (prevCmdIndent == IndentLevel && 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.
+
+ protected End FindOurEndCommand()
+ {
+ return FindMatchingEndCommand(this);
+ }
- // Stop if this is the last command in the list
- if (CommandIndex >= ParentBlock.CommandList.Count - 1)
- {
- StopParentBlock();
- return;
- }
+ ///
+ /// Helper to find the paired End Command for the given command.
+ ///
+ ///
+ /// Mathcing End Command or null if not found
+ public static End FindMatchingEndCommand(Command startCommand)
+ {
+ if (startCommand.ParentBlock == null)
+ return null;
+
+ int indent = startCommand.IndentLevel;
+ for (int i = startCommand.CommandIndex + 1; i < startCommand.ParentBlock.CommandList.Count; ++i)
+ {
+ var command = startCommand.ParentBlock.CommandList[i];
- // 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)
+ if (command.IndentLevel == indent)
+ {
+ if (command is End)
{
- 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;
- }
- }
+ return command as End;
}
-
- // No End command found
- StopParentBlock();
+ }
+ else if (command.IndentLevel < indent)
+ {
+ //managed to be less indent than the inner but not find and end, this shouldn't occur
+ // but may be user error or bad data, makes sense for completeness here
+ return null;
}
}
+
+ return null;
}
- public override bool OpenBlock()
+ ///
+ /// Helper for child classes that require an End command to function. For IsLooping commands
+ /// this also configures the loopback within the End command.
+ ///
+ ///
+ protected virtual bool EnsureRequiredEnd()
{
+ if (endCommand == null)
+ {
+ endCommand = FindOurEndCommand();
+
+ if (endCommand == null)
+ {
+ Debug.LogError( GetLocationIdentifier() + "', could not find closing End command and thus cannot loop.");
+ //StopParentBlock();
+ return false;
+ }
+ }
+
+ if (IsLooping)
+ {
+ // Tell the following end command to loop back
+ endCommand.Loop = true;
+ endCommand.LoopBackIndex = CommandIndex;
+ }
return true;
}
- #endregion
-
+ ///
+ /// Called by OnEnter when the condition is needed to evaluate and continue execution.
+ /// Means child classes do not have to deal with erronuous execution conditions, like fall through.
+ ///
protected virtual void EvaluateAndContinue()
{
+ PreEvaluate();
+
if (EvaluateCondition())
{
OnTrue();
@@ -123,17 +171,23 @@ namespace Fungus
}
}
+ ///
+ /// Called when the condition is run and EvaluateCondition returns true
+ ///
protected virtual void OnTrue()
{
Continue();
}
+ ///
+ /// Called when the condition is run and EvaluateCondition returns false
+ ///
protected virtual void OnFalse()
{
- // Last command in block
- if (CommandIndex >= ParentBlock.CommandList.Count)
+ //looping constructs only care about the end
+ if(IsLooping)
{
- StopParentBlock();
+ MoveToEnd();
return;
}
@@ -177,7 +231,6 @@ namespace Fungus
{
// Execute the Else If command
Continue(i);
-
return;
}
}
@@ -186,10 +239,47 @@ namespace Fungus
StopParentBlock();
}
+ ///
+ /// Sits in the if within EvaluateAndContinue, if returns true, OnTrue will run, if false, OnFalse will run.
+ ///
protected abstract bool EvaluateCondition();
- protected abstract bool HasNeededProperties();
+ ///
+ /// Child classes are required to report if it is possible for them to be evaulated.
+ ///
+ protected virtual bool HasNeededProperties() { return true; }
+ ///
+ /// Declare if the child class is implementing an 'else if' command, which requires some special handling
+ ///
protected virtual bool IsElseIf { get { return false; } }
+
+ ///
+ /// Called before EvaluateCondition, allowing for child classes to gather required data
+ ///
+ protected virtual void PreEvaluate() { }
+
+ ///
+ /// Ensure that this condition didn't come from a non matching if/elif.
+ ///
+ ///
+ protected virtual bool DoesPassElifSanityCheck()
+ {
+ System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();
+ var prevCmdIndent = ParentBlock.GetPreviousActiveCommandIndent();
+ var prevCmd = ParentBlock.GetPreviousActiveCommand();
+
+ //handle our matching if or else if in the chain failing and moving to us,
+ // need to make sure it is the same indent level
+ if (prevCmd == null ||
+ prevCmdIndent != IndentLevel ||
+ !previousCommandType.IsSubclassOf(typeof(Condition)) ||
+ (prevCmd as Condition).IsLooping)
+ {
+ return false;
+ }
+
+ return true;
+ }
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/ControlAudio.cs b/Assets/Fungus/Scripts/Commands/ControlAudio.cs
index d4100ead..ef14850e 100644
--- a/Assets/Fungus/Scripts/Commands/ControlAudio.cs
+++ b/Assets/Fungus/Scripts/Commands/ControlAudio.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ControlStage.cs b/Assets/Fungus/Scripts/Commands/ControlStage.cs
index 0dd9dd87..06ccb027 100644
--- a/Assets/Fungus/Scripts/Commands/ControlStage.cs
+++ b/Assets/Fungus/Scripts/Commands/ControlStage.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs b/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs
index c6df1b3f..3357d456 100644
--- a/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs
+++ b/Assets/Fungus/Scripts/Commands/ControlWithDisplay.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using System;
diff --git a/Assets/Fungus/Scripts/Commands/Conversation.cs b/Assets/Fungus/Scripts/Commands/Conversation.cs
index e7cdbd0c..0b084982 100644
--- a/Assets/Fungus/Scripts/Commands/Conversation.cs
+++ b/Assets/Fungus/Scripts/Commands/Conversation.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/DebugBreak.cs b/Assets/Fungus/Scripts/Commands/DebugBreak.cs
index 785bde0e..2dd31d72 100644
--- a/Assets/Fungus/Scripts/Commands/DebugBreak.cs
+++ b/Assets/Fungus/Scripts/Commands/DebugBreak.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/DebugLog.cs b/Assets/Fungus/Scripts/Commands/DebugLog.cs
index 6c39772b..d67c4c4c 100644
--- a/Assets/Fungus/Scripts/Commands/DebugLog.cs
+++ b/Assets/Fungus/Scripts/Commands/DebugLog.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs
index e9a6e6b5..a1d969db 100644
--- a/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs
+++ b/Assets/Fungus/Scripts/Commands/DeleteSaveKey.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Destroy.cs b/Assets/Fungus/Scripts/Commands/Destroy.cs
index 8288d4b3..27ed738c 100644
--- a/Assets/Fungus/Scripts/Commands/Destroy.cs
+++ b/Assets/Fungus/Scripts/Commands/Destroy.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs b/Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs
new file mode 100644
index 00000000..91e411bf
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs
@@ -0,0 +1,41 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Calls DontDestroyOnLoad on the target gameobject.
+ ///
+ [CommandInfo("Scripting",
+ "DestroyOnLoad",
+ "Calls DontDestroyOnLoad on the target gameobject")]
+ [AddComponentMenu("")]
+ public class DestroyOnLoad : Command
+ {
+ [SerializeField] protected GameObjectData target;
+
+ public override void OnEnter()
+ {
+ DontDestroyOnLoad(target.Value);
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ return target.Value != null ? target.Value.name : "Error: no target set";
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == target.gameObjectRef;
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs.meta b/Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs.meta
new file mode 100644
index 00000000..957b0417
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/DestroyOnLoad.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 779fdb236b4ca6343a6d631108388e42
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Else.cs b/Assets/Fungus/Scripts/Commands/Else.cs
index be8843ee..dd311268 100644
--- a/Assets/Fungus/Scripts/Commands/Else.cs
+++ b/Assets/Fungus/Scripts/Commands/Else.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -18,38 +18,18 @@ namespace Fungus
public override void OnEnter()
{
- if (ParentBlock == null)
+ // Find the next End command at the same indent level as this Else command
+ var matchingEnd = Condition.FindMatchingEndCommand(this);
+ if (matchingEnd != null)
{
- return;
+ // Execute command immediately after the EndIf command
+ Continue(matchingEnd.CommandIndex + 1);
}
-
- // Stop if this is the last command in the list
- if (CommandIndex >= ParentBlock.CommandList.Count - 1)
+ else
{
+ // No End command found
StopParentBlock();
- return;
- }
-
- // Find the next End command at the same indent level as this Else 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 EndIf command
- Continue(command.CommandIndex + 1);
- return;
- }
- }
}
-
- // No End command found
- StopParentBlock();
}
public override bool OpenBlock()
diff --git a/Assets/Fungus/Scripts/Commands/ElseIf.cs b/Assets/Fungus/Scripts/Commands/ElseIf.cs
index eee6ab14..c5df382f 100644
--- a/Assets/Fungus/Scripts/Commands/ElseIf.cs
+++ b/Assets/Fungus/Scripts/Commands/ElseIf.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -18,21 +18,11 @@ namespace Fungus
#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
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/End.cs b/Assets/Fungus/Scripts/Commands/End.cs
index 0ac0c45f..1258bacf 100644
--- a/Assets/Fungus/Scripts/Commands/End.cs
+++ b/Assets/Fungus/Scripts/Commands/End.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -16,23 +16,22 @@ namespace Fungus
{
#region Public members
+ ///
+ /// Set to true by looping constructs to allow for loops to occur
+ ///
public virtual bool Loop { get; set; }
+ ///
+ /// Set to the index of the owning looping construct
+ ///
+ public virtual int LoopBackIndex { get; set; }
+
public override void OnEnter()
{
if (Loop)
{
- for (int i = CommandIndex - 1; i >= 0; --i)
- {
- var command = ParentBlock.CommandList[i];
-
- if (command.IndentLevel == IndentLevel &&
- command.GetType() == typeof(While))
- {
- Continue(i);
- return;
- }
- }
+ Continue(LoopBackIndex);
+ return;
}
Continue();
diff --git a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs
index cf538c75..8f1c058c 100644
--- a/Assets/Fungus/Scripts/Commands/ExecuteLua.cs
+++ b/Assets/Fungus/Scripts/Commands/ExecuteLua.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/FadeScreen.cs b/Assets/Fungus/Scripts/Commands/FadeScreen.cs
index 2f6d82c7..a84fb483 100644
--- a/Assets/Fungus/Scripts/Commands/FadeScreen.cs
+++ b/Assets/Fungus/Scripts/Commands/FadeScreen.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -31,6 +31,8 @@ namespace Fungus
[Tooltip("Optional texture to use when rendering the fullscreen fade effect.")]
[SerializeField] protected Texture2D fadeTexture;
+ [SerializeField] protected LeanTweenType fadeTweenType = LeanTweenType.easeInOutQuad;
+
#region Public members
public override void OnEnter()
@@ -51,7 +53,7 @@ namespace Fungus
{
Continue();
}
- });
+ }, fadeTweenType);
if (!waitUntilFinished)
{
diff --git a/Assets/Fungus/Scripts/Commands/FadeSprite.cs b/Assets/Fungus/Scripts/Commands/FadeSprite.cs
index af68b7b5..8c8dadd7 100644
--- a/Assets/Fungus/Scripts/Commands/FadeSprite.cs
+++ b/Assets/Fungus/Scripts/Commands/FadeSprite.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/FadeToView.cs b/Assets/Fungus/Scripts/Commands/FadeToView.cs
index 3d1de7dc..5af59d37 100644
--- a/Assets/Fungus/Scripts/Commands/FadeToView.cs
+++ b/Assets/Fungus/Scripts/Commands/FadeToView.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -35,6 +35,11 @@ namespace Fungus
[Tooltip("Camera to use for the fade. Will use main camera if set to none.")]
[SerializeField] protected Camera targetCamera;
+ [SerializeField] protected LeanTweenType fadeTweenType = LeanTweenType.easeInOutQuad;
+ [SerializeField] protected LeanTweenType orthoSizeTweenType = LeanTweenType.easeInOutQuad;
+ [SerializeField] protected LeanTweenType posTweenType = LeanTweenType.easeInOutQuad;
+ [SerializeField] protected LeanTweenType rotTweenType = LeanTweenType.easeInOutQuad;
+
protected virtual void Start()
{
AcquireCamera();
@@ -87,7 +92,7 @@ namespace Fungus
{
Continue();
}
- });
+ }, fadeTweenType, orthoSizeTweenType, posTweenType, rotTweenType);
if (!waitUntilFinished)
{
diff --git a/Assets/Fungus/Scripts/Commands/FadeUI.cs b/Assets/Fungus/Scripts/Commands/FadeUI.cs
index 0c47f735..2124a2a0 100644
--- a/Assets/Fungus/Scripts/Commands/FadeUI.cs
+++ b/Assets/Fungus/Scripts/Commands/FadeUI.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/FromString.cs b/Assets/Fungus/Scripts/Commands/FromString.cs
index 5caff060..6ce83169 100644
--- a/Assets/Fungus/Scripts/Commands/FromString.cs
+++ b/Assets/Fungus/Scripts/Commands/FromString.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Fullscreen.cs b/Assets/Fungus/Scripts/Commands/Fullscreen.cs
index 88244026..487faab0 100644
--- a/Assets/Fungus/Scripts/Commands/Fullscreen.cs
+++ b/Assets/Fungus/Scripts/Commands/Fullscreen.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/GetText.cs b/Assets/Fungus/Scripts/Commands/GetText.cs
index f6c01b59..affcc895 100644
--- a/Assets/Fungus/Scripts/Commands/GetText.cs
+++ b/Assets/Fungus/Scripts/Commands/GetText.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/GetToggleState.cs b/Assets/Fungus/Scripts/Commands/GetToggleState.cs
index 17ad1242..e8761184 100644
--- a/Assets/Fungus/Scripts/Commands/GetToggleState.cs
+++ b/Assets/Fungus/Scripts/Commands/GetToggleState.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/If.cs b/Assets/Fungus/Scripts/Commands/If.cs
index c8d15fb0..efeb8507 100644
--- a/Assets/Fungus/Scripts/Commands/If.cs
+++ b/Assets/Fungus/Scripts/Commands/If.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -14,13 +14,5 @@ namespace Fungus
[AddComponentMenu("")]
public class If : VariableCondition
{
- #region Public members
-
- public override Color GetButtonColor()
- {
- return new Color32(253, 253, 150, 255);
- }
-
- #endregion
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Input/GetAxis.cs b/Assets/Fungus/Scripts/Commands/Input/GetAxis.cs
index 644ecbb2..364271a3 100644
--- a/Assets/Fungus/Scripts/Commands/Input/GetAxis.cs
+++ b/Assets/Fungus/Scripts/Commands/Input/GetAxis.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Input/GetKey.cs b/Assets/Fungus/Scripts/Commands/Input/GetKey.cs
index 341fd99d..4a7f31f8 100644
--- a/Assets/Fungus/Scripts/Commands/Input/GetKey.cs
+++ b/Assets/Fungus/Scripts/Commands/Input/GetKey.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs b/Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs
new file mode 100644
index 00000000..d2325f34
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs
@@ -0,0 +1,89 @@
+using UnityEngine;
+
+namespace Fungus
+{
+ //
+ /// Store Input.mousePosition and mouse screen conversions in a variable(s)
+ ///
+ [CommandInfo("Input",
+ "Get Mouse Position",
+ "Store various interpretations of Input.mousePosition")]
+ [AddComponentMenu("")]
+ public class GetMousePosition : Command
+ {
+ [VariableProperty(typeof(Vector2Variable))]
+ [SerializeField]
+ protected Vector2Variable screenPosition;
+
+ [Tooltip("If null, Camera.main is used")]
+ protected Camera castCamera;
+
+ [VariableProperty(typeof(Vector2Variable))]
+ [SerializeField]
+ protected Vector2Variable viewPosition;
+
+ [VariableProperty(typeof(Vector3Variable))]
+ [SerializeField]
+ protected Vector3Variable worldPosition;
+
+ [VariableProperty(typeof(Vector3Variable))]
+ [SerializeField]
+ protected Vector3Variable worldDirection;
+
+ public override void OnEnter()
+ {
+ if (castCamera == null)
+ {
+ castCamera = Camera.main;
+ }
+
+ if (screenPosition != null)
+ {
+ screenPosition.Value = Input.mousePosition;
+ }
+
+ if (viewPosition != null)
+ {
+ viewPosition.Value = castCamera.ScreenToViewportPoint(Input.mousePosition);
+ }
+
+ if (worldPosition != null)
+ {
+ var screenWithZ = Input.mousePosition;
+ screenWithZ.z = castCamera.nearClipPlane;
+ worldPosition.Value = castCamera.ScreenToWorldPoint(screenWithZ);
+ }
+
+ if (worldDirection != null)
+ {
+ var screenWithZ = Input.mousePosition;
+ screenWithZ.z = castCamera.nearClipPlane;
+ worldDirection.Value = castCamera.ScreenPointToRay(screenWithZ).direction;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ return (screenPosition != null ? screenPosition.Key + " " : "") +
+ (castCamera != null ? castCamera.name + " " : "MainCam") +
+ (viewPosition != null ? viewPosition.Key + " " : "") +
+ (worldPosition != null ? worldPosition.Key + " " : "") +
+ (worldDirection != null ? worldDirection.Key + " " : "");
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return (screenPosition == variable ||
+ viewPosition == variable ||
+ worldPosition == variable ||
+ worldDirection == variable);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs.meta b/Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs.meta
new file mode 100644
index 00000000..8ac89118
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Input/GetMousePosition.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fb32240870e5bf545a0dafba446d3990
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs
index 6cdc5bee..f84465c1 100644
--- a/Assets/Fungus/Scripts/Commands/InvokeEvent.cs
+++ b/Assets/Fungus/Scripts/Commands/InvokeEvent.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs
index ac438271..22328be5 100644
--- a/Assets/Fungus/Scripts/Commands/InvokeMethod.cs
+++ b/Assets/Fungus/Scripts/Commands/InvokeMethod.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Jump.cs b/Assets/Fungus/Scripts/Commands/Jump.cs
index 340841ce..64e448b3 100644
--- a/Assets/Fungus/Scripts/Commands/Jump.cs
+++ b/Assets/Fungus/Scripts/Commands/Jump.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Label.cs b/Assets/Fungus/Scripts/Commands/Label.cs
index dc64bc96..cb4fa83f 100644
--- a/Assets/Fungus/Scripts/Commands/Label.cs
+++ b/Assets/Fungus/Scripts/Commands/Label.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs b/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs
index 9607eb0f..ddac35ec 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/BaseLeanTweenCommand.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
using UnityEngine.Serialization;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs
index 1ab79b07..81d77534 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/MoveLean.cs
@@ -1,4 +1,6 @@
-
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// 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;
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs
index ed8c7975..5a631cd0 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/RotateLean.cs
@@ -1,4 +1,6 @@
-
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// 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;
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs
index 603869e7..7a6d470c 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/ScaleLean.cs
@@ -1,4 +1,6 @@
-
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// 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;
diff --git a/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs b/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs
index 24957c7d..bd9ce129 100644
--- a/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs
+++ b/Assets/Fungus/Scripts/Commands/LeanTween/StopTweensLean.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/LoadScene.cs b/Assets/Fungus/Scripts/Commands/LoadScene.cs
index e99660b5..fd1c6f5c 100644
--- a/Assets/Fungus/Scripts/Commands/LoadScene.cs
+++ b/Assets/Fungus/Scripts/Commands/LoadScene.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/LoadVariable.cs b/Assets/Fungus/Scripts/Commands/LoadVariable.cs
index 8e4f45ea..06380227 100644
--- a/Assets/Fungus/Scripts/Commands/LoadVariable.cs
+++ b/Assets/Fungus/Scripts/Commands/LoadVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/LookFrom.cs b/Assets/Fungus/Scripts/Commands/LookFrom.cs
index 875f7d35..fe02c69a 100644
--- a/Assets/Fungus/Scripts/Commands/LookFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/LookFrom.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/LookTo.cs b/Assets/Fungus/Scripts/Commands/LookTo.cs
index f5a7ca59..0c29038c 100644
--- a/Assets/Fungus/Scripts/Commands/LookTo.cs
+++ b/Assets/Fungus/Scripts/Commands/LookTo.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/LoopRange.cs b/Assets/Fungus/Scripts/Commands/LoopRange.cs
new file mode 100644
index 00000000..645e11b9
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/LoopRange.cs
@@ -0,0 +1,84 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus) 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
+{
+ ///
+ /// Loop over a fixed integer range, similar to a common for loop.
+ ///
+ [CommandInfo("Flow",
+ "Loop Range",
+ "Loop over a fixed integer range, similar to a common for loop.")]
+ [CommandInfo("Flow",
+ "For",
+ "Loop over a fixed integer range, similar to a common for loop.")]
+ [AddComponentMenu("")]
+ public class LoopRange : Condition
+ {
+ [Tooltip("Starting value for the counter variable")]
+ [SerializeField]
+ protected IntegerData startingValue;
+
+ [Tooltip("End value for the counter variable, exclusive")]
+ [SerializeField]
+ protected IntegerData endValue;
+
+ [Tooltip("Optional int var to hold the current loop counter.")]
+ [SerializeField]
+ protected IntegerData counter;
+
+ [Tooltip("Step size for the counter, how much does it go up by each loop. Default 1")]
+ [SerializeField]
+ protected IntegerData step = new IntegerData(1);
+
+ #region Public members
+
+ public override bool IsLooping { get { return true; } }
+
+ protected override void PreEvaluate()
+ {
+ //if we came from the end then we are already looping, if not this is first loop so prep
+ if (ParentBlock.PreviousActiveCommandIndex != endCommand.CommandIndex)
+ {
+ counter.Value = startingValue.Value;
+ }
+ else
+ {
+ counter.Value += (startingValue.Value <= endValue.Value ? step.Value : -step.Value);
+ }
+ }
+
+ protected override bool EvaluateCondition()
+ {
+ return (startingValue.Value <= endValue.Value ?
+ counter.Value < endValue.Value :
+ counter.Value > endValue.Value);
+ }
+
+ protected override void OnFalse()
+ {
+ MoveToEnd();
+ }
+
+ public override void OnValidate()
+ {
+ // no infinite loops
+ if (step.Value == 0)
+ step.Value = 1;
+
+ //no negative steps, we do that automatically
+ step.Value = Mathf.Abs(step.Value);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return startingValue.integerRef == variable || endValue.integerRef == variable ||
+ counter.integerRef == variable || step.integerRef == variable ||
+ base.HasReference(variable);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/LoopRange.cs.meta b/Assets/Fungus/Scripts/Commands/LoopRange.cs.meta
new file mode 100644
index 00000000..ca43b9d8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/LoopRange.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b0eebb5bf2fc1e542a35e2e5332e60d4
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/LuaCondition.cs b/Assets/Fungus/Scripts/Commands/LuaCondition.cs
index 7bd7d81d..5495015f 100644
--- a/Assets/Fungus/Scripts/Commands/LuaCondition.cs
+++ b/Assets/Fungus/Scripts/Commands/LuaCondition.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -60,7 +63,7 @@ namespace Fungus
}
// Cache a descriptive name to use in Lua error messages
- friendlyName = gameObject.name + "." + ParentBlock.BlockName + "." + this.GetType().ToString() + " #" + CommandIndex.ToString();
+ friendlyName = GetLocationIdentifier();
Flowchart flowchart = GetFlowchart();
@@ -110,17 +113,6 @@ namespace Fungus
return luaCompareString;
}
-
- public override bool OpenBlock()
- {
- return true;
- }
-
- public override Color GetButtonColor()
- {
- return new Color32(253, 253, 150, 255);
- }
-
#endregion
}
}
diff --git a/Assets/Fungus/Scripts/Commands/LuaElseIf.cs b/Assets/Fungus/Scripts/Commands/LuaElseIf.cs
index c7a647a5..440c125e 100644
--- a/Assets/Fungus/Scripts/Commands/LuaElseIf.cs
+++ b/Assets/Fungus/Scripts/Commands/LuaElseIf.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -18,21 +18,11 @@ namespace Fungus
#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
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/LuaIf.cs b/Assets/Fungus/Scripts/Commands/LuaIf.cs
index 0a69e412..5787a9e2 100644
--- a/Assets/Fungus/Scripts/Commands/LuaIf.cs
+++ b/Assets/Fungus/Scripts/Commands/LuaIf.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -15,11 +15,6 @@ namespace Fungus
public class LuaIf : LuaCondition
{
#region Public members
-
- public override Color GetButtonColor()
- {
- return new Color32(253, 253, 150, 255);
- }
#endregion
}
diff --git a/Assets/Fungus/Scripts/Commands/Math/Abs.cs b/Assets/Fungus/Scripts/Commands/Math/Abs.cs
index 0859907b..a62fadf9 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Abs.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Abs.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs b/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
index 4a59709b..6c45908e 100644
--- a/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/Clamp.cs b/Assets/Fungus/Scripts/Commands/Math/Clamp.cs
index 181e3bf5..345994e3 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Clamp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Clamp.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Math/Curve.cs b/Assets/Fungus/Scripts/Commands/Math/Curve.cs
index 9d15bece..6e754f10 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Curve.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Curve.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/Exp.cs b/Assets/Fungus/Scripts/Commands/Math/Exp.cs
index 5489c1a6..4454361a 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Exp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Exp.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/Inv.cs b/Assets/Fungus/Scripts/Commands/Math/Inv.cs
index 029761c3..a900cf53 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Inv.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Inv.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs b/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
index a0f86c83..1932999c 100644
--- a/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Math/Lerp.cs b/Assets/Fungus/Scripts/Commands/Math/Lerp.cs
index e98055ae..2bcae56b 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Lerp.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Lerp.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Math/Log.cs b/Assets/Fungus/Scripts/Commands/Math/Log.cs
index 8875f974..fa85bfc5 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Log.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Log.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/Map.cs b/Assets/Fungus/Scripts/Commands/Math/Map.cs
index 3f653ad4..d7cba733 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Map.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Map.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Math/MinMax.cs b/Assets/Fungus/Scripts/Commands/Math/MinMax.cs
index 7294454f..28a1d36a 100644
--- a/Assets/Fungus/Scripts/Commands/Math/MinMax.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/MinMax.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Math/Neg.cs b/Assets/Fungus/Scripts/Commands/Math/Neg.cs
index 1f063868..85ab31b9 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Neg.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Neg.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/Pow.cs b/Assets/Fungus/Scripts/Commands/Math/Pow.cs
index 586c43c5..52a480c8 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Pow.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Pow.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Math/Round.cs b/Assets/Fungus/Scripts/Commands/Math/Round.cs
index d7ddc301..2a969905 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Round.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Round.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/Sign.cs b/Assets/Fungus/Scripts/Commands/Math/Sign.cs
index 89fea7b8..771d6d14 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Sign.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Sign.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs b/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
index d8e9485c..71633f4c 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Commands/Math/ToInt.cs b/Assets/Fungus/Scripts/Commands/Math/ToInt.cs
index cf8596ca..1231e2e1 100644
--- a/Assets/Fungus/Scripts/Commands/Math/ToInt.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/ToInt.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Math/Trig.cs b/Assets/Fungus/Scripts/Commands/Math/Trig.cs
index 2ef5b78a..881b0391 100644
--- a/Assets/Fungus/Scripts/Commands/Math/Trig.cs
+++ b/Assets/Fungus/Scripts/Commands/Math/Trig.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/Menu.cs b/Assets/Fungus/Scripts/Commands/Menu.cs
index 692c26c1..b9993ffe 100644
--- a/Assets/Fungus/Scripts/Commands/Menu.cs
+++ b/Assets/Fungus/Scripts/Commands/Menu.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/MenuShuffle.cs b/Assets/Fungus/Scripts/Commands/MenuShuffle.cs
index fcaf0082..f198318f 100644
--- a/Assets/Fungus/Scripts/Commands/MenuShuffle.cs
+++ b/Assets/Fungus/Scripts/Commands/MenuShuffle.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/MenuTimer.cs b/Assets/Fungus/Scripts/Commands/MenuTimer.cs
index 6808229c..a8542c90 100644
--- a/Assets/Fungus/Scripts/Commands/MenuTimer.cs
+++ b/Assets/Fungus/Scripts/Commands/MenuTimer.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/MoveAdd.cs b/Assets/Fungus/Scripts/Commands/MoveAdd.cs
index 0d7f2352..cabb8b37 100644
--- a/Assets/Fungus/Scripts/Commands/MoveAdd.cs
+++ b/Assets/Fungus/Scripts/Commands/MoveAdd.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/MoveFrom.cs b/Assets/Fungus/Scripts/Commands/MoveFrom.cs
index f6912477..a6453028 100644
--- a/Assets/Fungus/Scripts/Commands/MoveFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/MoveFrom.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/MoveTo.cs b/Assets/Fungus/Scripts/Commands/MoveTo.cs
index 33ba70cc..80a6a7a5 100644
--- a/Assets/Fungus/Scripts/Commands/MoveTo.cs
+++ b/Assets/Fungus/Scripts/Commands/MoveTo.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/MoveToView.cs b/Assets/Fungus/Scripts/Commands/MoveToView.cs
index 3f9e4a2b..19bf5c2f 100644
--- a/Assets/Fungus/Scripts/Commands/MoveToView.cs
+++ b/Assets/Fungus/Scripts/Commands/MoveToView.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -26,7 +26,11 @@ namespace Fungus
[Tooltip("Camera to use for the pan. Will use main camera if set to none.")]
[SerializeField] protected Camera targetCamera;
-
+
+ [SerializeField] protected LeanTweenType orthoSizeTweenType = LeanTweenType.easeInOutQuad;
+ [SerializeField] protected LeanTweenType posTweenType = LeanTweenType.easeInOutQuad;
+ [SerializeField] protected LeanTweenType rotTweenType = LeanTweenType.easeInOutQuad;
+
protected virtual void AcquireCamera()
{
if (targetCamera != null)
@@ -69,7 +73,7 @@ namespace Fungus
{
Continue();
}
- });
+ }, orthoSizeTweenType, posTweenType, rotTweenType);
if (!waitUntilFinished)
{
diff --git a/Assets/Fungus/Scripts/Commands/OpenURL.cs b/Assets/Fungus/Scripts/Commands/OpenURL.cs
index f9d67987..b7190e33 100644
--- a/Assets/Fungus/Scripts/Commands/OpenURL.cs
+++ b/Assets/Fungus/Scripts/Commands/OpenURL.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PlayAmbianceSound.cs b/Assets/Fungus/Scripts/Commands/PlayAmbianceSound.cs
index de01f162..7f3b5e63 100644
--- a/Assets/Fungus/Scripts/Commands/PlayAmbianceSound.cs
+++ b/Assets/Fungus/Scripts/Commands/PlayAmbianceSound.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs
index 4738a515..a94472dd 100644
--- a/Assets/Fungus/Scripts/Commands/PlayAnimState.cs
+++ b/Assets/Fungus/Scripts/Commands/PlayAnimState.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PlayMusic.cs b/Assets/Fungus/Scripts/Commands/PlayMusic.cs
index bed4be71..806c64d6 100644
--- a/Assets/Fungus/Scripts/Commands/PlayMusic.cs
+++ b/Assets/Fungus/Scripts/Commands/PlayMusic.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PlayRandomSound.cs b/Assets/Fungus/Scripts/Commands/PlayRandomSound.cs
index 3b1e2daf..7eb7c63f 100644
--- a/Assets/Fungus/Scripts/Commands/PlayRandomSound.cs
+++ b/Assets/Fungus/Scripts/Commands/PlayRandomSound.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PlaySound.cs b/Assets/Fungus/Scripts/Commands/PlaySound.cs
index bb96c728..c5607856 100644
--- a/Assets/Fungus/Scripts/Commands/PlaySound.cs
+++ b/Assets/Fungus/Scripts/Commands/PlaySound.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs
index c1eacfdd..74360719 100644
--- a/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs
+++ b/Assets/Fungus/Scripts/Commands/PlayUsfxrSound.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using System;
@@ -14,7 +14,7 @@ using UnityEngine.Serialization;
"Play Usfxr Sound",
"Plays a usfxr synth sound. Use the usfxr editor [Tools > Fungus > Utilities > Generate usfxr Sound Effects] to create the SettingsString. Set a ParentTransform if using positional sound. See https://github.com/zeh/usfxr for more information about usfxr.")]
[AddComponentMenu("")]
- [ExecuteInEditMode]
+ //[ExecuteInEditMode]
public class PlayUsfxrSound : Command
{
[Tooltip("Transform to use for positional audio")]
@@ -29,9 +29,9 @@ using UnityEngine.Serialization;
protected SfxrSynth _synth = new SfxrSynth();
//Call this if the settings have changed
- protected virtual void UpdateCache()
+ protected virtual void UpdateCache()
{
- if (_SettingsString.Value != null)
+ if (!string.IsNullOrEmpty(_SettingsString.Value))
{
_synth.parameters.SetSettingsString(_SettingsString.Value);
_synth.CacheSound();
@@ -103,6 +103,12 @@ using UnityEngine.Serialization;
}
}
+ public override void OnValidate()
+ {
+ OnEnable();
+ base.OnValidate();
+ }
+
#endregion
}
}
diff --git a/Assets/Fungus/Scripts/Commands/Portrait.cs b/Assets/Fungus/Scripts/Commands/Portrait.cs
index 5d2bc731..0b3b1afa 100644
--- a/Assets/Fungus/Scripts/Commands/Portrait.cs
+++ b/Assets/Fungus/Scripts/Commands/Portrait.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -116,7 +116,7 @@ namespace Fungus
if (stage == null)
{
// If no default specified, try to get any portrait stage in the scene
- stage = FindObjectOfType();
+ stage = Stage.GetActiveStage();
// If portrait stage does not exist, do nothing
if (stage == null)
{
diff --git a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs
index 69df8bd8..eaf6dfd6 100644
--- a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs
+++ b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityCount.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -7,7 +10,7 @@ namespace Fungus
///
/// Copy the value of the Priority Count to a local IntegerVariable, intended primarily to assist with debugging use of Priority.
///
- [CommandInfo("Priority Signals",
+ [CommandInfo("PrioritySignals",
"Get Priority Count",
"Copy the value of the Priority Count to a local IntegerVariable, intended primarily to assist with debugging use of Priority.")]
public class FungusPriorityCount : Command
diff --git a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityDecrease.cs b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityDecrease.cs
index 8461eaee..43ddea37 100644
--- a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityDecrease.cs
+++ b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityDecrease.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -8,7 +11,7 @@ namespace Fungus
/// Decrease the FungusPriority count, causing the related FungusPrioritySignals to fire.
/// Intended to be used to notify external systems that fungus is doing something important and they should perhaps resume.
///
- [CommandInfo("Priority Signals",
+ [CommandInfo("PrioritySignals",
"Priority Down",
"Decrease the FungusPriority count, causing the related FungusPrioritySignals to fire. " +
"Intended to be used to notify external systems that fungus is doing something important and they should perhaps resume.")]
diff --git a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityIncrease.cs b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityIncrease.cs
index 40282e32..0be68bf5 100644
--- a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityIncrease.cs
+++ b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityIncrease.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -8,7 +11,7 @@ namespace Fungus
/// Increases the FungusPriority count, causing the related FungusPrioritySignals to fire.
/// Intended to be used to notify external systems that fungus is doing something important and they should perhaps pause.
///
- [CommandInfo("Priority Signals",
+ [CommandInfo("PrioritySignals",
"Priority Up",
"Increases the FungusPriority count, causing the related FungusPrioritySignals to fire. " +
"Intended to be used to notify external systems that fungus is doing something important and they should perhaps pause.")]
diff --git a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityReset.cs b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityReset.cs
index d854f388..0ebc39e0 100644
--- a/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityReset.cs
+++ b/Assets/Fungus/Scripts/Commands/Priority/FungusPriorityReset.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -7,7 +10,7 @@ namespace Fungus
///
/// Resets the FungusPriority count to zero. Useful if you are among logic that is hard to have matching increase and decreases.
///
- [CommandInfo("Priority Signals",
+ [CommandInfo("PrioritySignals",
"Priority Reset",
"Resets the FungusPriority count to zero. Useful if you are among logic that is hard to have matching increase and decreases.")]
public class FungusPriorityReset : Command
diff --git a/Assets/Fungus/Scripts/Commands/Property.meta b/Assets/Fungus/Scripts/Commands/Property.meta
new file mode 100644
index 00000000..7d2d156d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 8a1a00144f44775449d32d39b5a7185a
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs b/Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs
new file mode 100644
index 00000000..c5be2d18
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs
@@ -0,0 +1,296 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Animator component
+ ///
+ [CommandInfo("Property",
+ "Animator",
+ "Get or Set a property of a Animator component")]
+ [AddComponentMenu("")]
+ public class AnimatorProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ IsOptimizable,
+ IsHuman,
+ HasRootMotion,
+ HumanScale,
+ IsInitialized,
+ DeltaPosition,
+ DeltaRotation,
+ Velocity,
+ AngularVelocity,
+ RootPosition,
+ RootRotation,
+ ApplyRootMotion,
+ HasTransformHierarchy,
+ GravityWeight,
+ BodyPosition,
+ BodyRotation,
+ StabilizeFeet,
+ LayerCount,
+ ParameterCount,
+ FeetPivotActive,
+ PivotWeight,
+ PivotPosition,
+ IsMatchingTarget,
+ Speed,
+ TargetPosition,
+ TargetRotation,
+ PlaybackTime,
+ RecorderStartTime,
+ RecorderStopTime,
+ HasBoundPlayables,
+ LayersAffectMassCenter,
+ LeftFeetBottomHeight,
+ RightFeetBottomHeight,
+ LogWarnings,
+ FireEvents,
+ KeepAnimatorControllerStateOnDisable,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(AnimatorVariable))]
+ protected AnimatorVariable animatorVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(BooleanVariable),
+ typeof(FloatVariable),
+ typeof(Vector3Variable),
+ typeof(QuaternionVariable),
+ typeof(IntegerVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iob = inOutVar as BooleanVariable;
+ var iof = inOutVar as FloatVariable;
+ var iov = inOutVar as Vector3Variable;
+ var ioq = inOutVar as QuaternionVariable;
+ var ioi = inOutVar as IntegerVariable;
+
+
+ var target = animatorVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.IsOptimizable:
+ iob.Value = target.isOptimizable;
+ break;
+ case Property.IsHuman:
+ iob.Value = target.isHuman;
+ break;
+ case Property.HasRootMotion:
+ iob.Value = target.hasRootMotion;
+ break;
+ case Property.HumanScale:
+ iof.Value = target.humanScale;
+ break;
+ case Property.IsInitialized:
+ iob.Value = target.isInitialized;
+ break;
+ case Property.DeltaPosition:
+ iov.Value = target.deltaPosition;
+ break;
+ case Property.DeltaRotation:
+ ioq.Value = target.deltaRotation;
+ break;
+ case Property.Velocity:
+ iov.Value = target.velocity;
+ break;
+ case Property.AngularVelocity:
+ iov.Value = target.angularVelocity;
+ break;
+ case Property.RootPosition:
+ iov.Value = target.rootPosition;
+ break;
+ case Property.RootRotation:
+ ioq.Value = target.rootRotation;
+ break;
+ case Property.ApplyRootMotion:
+ iob.Value = target.applyRootMotion;
+ break;
+ case Property.HasTransformHierarchy:
+ iob.Value = target.hasTransformHierarchy;
+ break;
+ case Property.GravityWeight:
+ iof.Value = target.gravityWeight;
+ break;
+ case Property.BodyPosition:
+ iov.Value = target.bodyPosition;
+ break;
+ case Property.BodyRotation:
+ ioq.Value = target.bodyRotation;
+ break;
+ case Property.StabilizeFeet:
+ iob.Value = target.stabilizeFeet;
+ break;
+ case Property.LayerCount:
+ ioi.Value = target.layerCount;
+ break;
+ case Property.ParameterCount:
+ ioi.Value = target.parameterCount;
+ break;
+ case Property.FeetPivotActive:
+ iof.Value = target.feetPivotActive;
+ break;
+ case Property.PivotWeight:
+ iof.Value = target.pivotWeight;
+ break;
+ case Property.PivotPosition:
+ iov.Value = target.pivotPosition;
+ break;
+ case Property.IsMatchingTarget:
+ iob.Value = target.isMatchingTarget;
+ break;
+ case Property.Speed:
+ iof.Value = target.speed;
+ break;
+ case Property.TargetPosition:
+ iov.Value = target.targetPosition;
+ break;
+ case Property.TargetRotation:
+ ioq.Value = target.targetRotation;
+ break;
+ case Property.PlaybackTime:
+ iof.Value = target.playbackTime;
+ break;
+ case Property.RecorderStartTime:
+ iof.Value = target.recorderStartTime;
+ break;
+ case Property.RecorderStopTime:
+ iof.Value = target.recorderStopTime;
+ break;
+ case Property.HasBoundPlayables:
+ iob.Value = target.hasBoundPlayables;
+ break;
+ case Property.LayersAffectMassCenter:
+ iob.Value = target.layersAffectMassCenter;
+ break;
+ case Property.LeftFeetBottomHeight:
+ iof.Value = target.leftFeetBottomHeight;
+ break;
+ case Property.RightFeetBottomHeight:
+ iof.Value = target.rightFeetBottomHeight;
+ break;
+ case Property.LogWarnings:
+ iob.Value = target.logWarnings;
+ break;
+ case Property.FireEvents:
+ iob.Value = target.fireEvents;
+ break;
+#if UNITY_2019_2_OR_NEWER
+ case Property.KeepAnimatorControllerStateOnDisable:
+ iob.Value = target.keepAnimatorControllerStateOnDisable;
+ break;
+#endif
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.RootPosition:
+ target.rootPosition = iov.Value;
+ break;
+ case Property.RootRotation:
+ target.rootRotation = ioq.Value;
+ break;
+ case Property.ApplyRootMotion:
+ target.applyRootMotion = iob.Value;
+ break;
+ case Property.BodyPosition:
+ target.bodyPosition = iov.Value;
+ break;
+ case Property.BodyRotation:
+ target.bodyRotation = ioq.Value;
+ break;
+ case Property.StabilizeFeet:
+ target.stabilizeFeet = iob.Value;
+ break;
+ case Property.FeetPivotActive:
+ target.feetPivotActive = iof.Value;
+ break;
+ case Property.Speed:
+ target.speed = iof.Value;
+ break;
+ case Property.PlaybackTime:
+ target.playbackTime = iof.Value;
+ break;
+ case Property.RecorderStartTime:
+ target.recorderStartTime = iof.Value;
+ break;
+ case Property.RecorderStopTime:
+ target.recorderStopTime = iof.Value;
+ break;
+ case Property.LayersAffectMassCenter:
+ target.layersAffectMassCenter = iob.Value;
+ break;
+ case Property.LogWarnings:
+ target.logWarnings = iob.Value;
+ break;
+ case Property.FireEvents:
+ target.fireEvents = iob.Value;
+ break;
+#if UNITY_2019_2_OR_NEWER
+ case Property.KeepAnimatorControllerStateOnDisable:
+ target.keepAnimatorControllerStateOnDisable = iob.Value;
+ break;
+#endif
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (animatorVar == null)
+ {
+ return "Error: no animatorVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (animatorVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs.meta
new file mode 100644
index 00000000..ee1ea325
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e4616a794b2245d46970401b3acc492f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs b/Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs
new file mode 100644
index 00000000..3cca2be8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs
@@ -0,0 +1,261 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a AudioSource component
+ ///
+ [CommandInfo("Property",
+ "AudioSource",
+ "Get or Set a property of a AudioSource component")]
+ [AddComponentMenu("")]
+ public class AudioSourceProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Volume,
+ Pitch,
+ Time,
+ TimeSamples,
+ IsPlaying,
+ IsVirtual,
+ Loop,
+ IgnoreListenerVolume,
+ PlayOnAwake,
+ IgnoreListenerPause,
+ PanStereo,
+ SpatialBlend,
+ Spatialize,
+ SpatializePostEffects,
+ ReverbZoneMix,
+ BypassEffects,
+ BypassListenerEffects,
+ BypassReverbZones,
+ DopplerLevel,
+ Spread,
+ Priority,
+ Mute,
+ MinDistance,
+ MaxDistance,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(AudioSourceVariable))]
+ protected AudioSourceVariable audioSourceVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(IntegerVariable),
+ typeof(BooleanVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var ioi = inOutVar as IntegerVariable;
+ var iob = inOutVar as BooleanVariable;
+
+
+ var target = audioSourceVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Volume:
+ iof.Value = target.volume;
+ break;
+ case Property.Pitch:
+ iof.Value = target.pitch;
+ break;
+ case Property.Time:
+ iof.Value = target.time;
+ break;
+ case Property.TimeSamples:
+ ioi.Value = target.timeSamples;
+ break;
+ case Property.IsPlaying:
+ iob.Value = target.isPlaying;
+ break;
+ case Property.IsVirtual:
+ iob.Value = target.isVirtual;
+ break;
+ case Property.Loop:
+ iob.Value = target.loop;
+ break;
+ case Property.IgnoreListenerVolume:
+ iob.Value = target.ignoreListenerVolume;
+ break;
+ case Property.PlayOnAwake:
+ iob.Value = target.playOnAwake;
+ break;
+ case Property.IgnoreListenerPause:
+ iob.Value = target.ignoreListenerPause;
+ break;
+ case Property.PanStereo:
+ iof.Value = target.panStereo;
+ break;
+ case Property.SpatialBlend:
+ iof.Value = target.spatialBlend;
+ break;
+ case Property.Spatialize:
+ iob.Value = target.spatialize;
+ break;
+ case Property.SpatializePostEffects:
+ iob.Value = target.spatializePostEffects;
+ break;
+ case Property.ReverbZoneMix:
+ iof.Value = target.reverbZoneMix;
+ break;
+ case Property.BypassEffects:
+ iob.Value = target.bypassEffects;
+ break;
+ case Property.BypassListenerEffects:
+ iob.Value = target.bypassListenerEffects;
+ break;
+ case Property.BypassReverbZones:
+ iob.Value = target.bypassReverbZones;
+ break;
+ case Property.DopplerLevel:
+ iof.Value = target.dopplerLevel;
+ break;
+ case Property.Spread:
+ iof.Value = target.spread;
+ break;
+ case Property.Priority:
+ ioi.Value = target.priority;
+ break;
+ case Property.Mute:
+ iob.Value = target.mute;
+ break;
+ case Property.MinDistance:
+ iof.Value = target.minDistance;
+ break;
+ case Property.MaxDistance:
+ iof.Value = target.maxDistance;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Volume:
+ target.volume = iof.Value;
+ break;
+ case Property.Pitch:
+ target.pitch = iof.Value;
+ break;
+ case Property.Time:
+ target.time = iof.Value;
+ break;
+ case Property.TimeSamples:
+ target.timeSamples = ioi.Value;
+ break;
+ case Property.Loop:
+ target.loop = iob.Value;
+ break;
+ case Property.IgnoreListenerVolume:
+ target.ignoreListenerVolume = iob.Value;
+ break;
+ case Property.PlayOnAwake:
+ target.playOnAwake = iob.Value;
+ break;
+ case Property.IgnoreListenerPause:
+ target.ignoreListenerPause = iob.Value;
+ break;
+ case Property.PanStereo:
+ target.panStereo = iof.Value;
+ break;
+ case Property.SpatialBlend:
+ target.spatialBlend = iof.Value;
+ break;
+ case Property.Spatialize:
+ target.spatialize = iob.Value;
+ break;
+ case Property.SpatializePostEffects:
+ target.spatializePostEffects = iob.Value;
+ break;
+ case Property.ReverbZoneMix:
+ target.reverbZoneMix = iof.Value;
+ break;
+ case Property.BypassEffects:
+ target.bypassEffects = iob.Value;
+ break;
+ case Property.BypassListenerEffects:
+ target.bypassListenerEffects = iob.Value;
+ break;
+ case Property.BypassReverbZones:
+ target.bypassReverbZones = iob.Value;
+ break;
+ case Property.DopplerLevel:
+ target.dopplerLevel = iof.Value;
+ break;
+ case Property.Spread:
+ target.spread = iof.Value;
+ break;
+ case Property.Priority:
+ target.priority = ioi.Value;
+ break;
+ case Property.Mute:
+ target.mute = iob.Value;
+ break;
+ case Property.MinDistance:
+ target.minDistance = iof.Value;
+ break;
+ case Property.MaxDistance:
+ target.maxDistance = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (audioSourceVar == null)
+ {
+ return "Error: no audioSourceVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (audioSourceVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs.meta
new file mode 100644
index 00000000..533d3d7f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/AudioSourceProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2250cfac690a2b74f8f9dd9be91985c6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs b/Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs
new file mode 100644
index 00000000..08792f4c
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs
@@ -0,0 +1,125 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Collection component
+ ///
+ [CommandInfo("Property",
+ "Collection",
+ "Get or Set a property of a Collection component")]
+ [AddComponentMenu("")]
+ public class CollectionProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Capacity,
+ Count,
+ IsFixedSize,
+ IsReadOnly,
+ IsSynchronized,
+ Name,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected CollectionData collectionData;
+
+ [SerializeField]
+ [VariableProperty(typeof(IntegerVariable),
+ typeof(BooleanVariable),
+ typeof(StringVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var ioi = inOutVar as IntegerVariable;
+ var iob = inOutVar as BooleanVariable;
+ var ios = inOutVar as StringVariable;
+
+
+ var target = collectionData.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Capacity:
+ ioi.Value = target.Capacity;
+ break;
+ case Property.Count:
+ ioi.Value = target.Count;
+ break;
+ case Property.IsFixedSize:
+ iob.Value = target.IsFixedSize;
+ break;
+ case Property.IsReadOnly:
+ iob.Value = target.IsReadOnly;
+ break;
+ case Property.IsSynchronized:
+ iob.Value = target.IsSynchronized;
+ break;
+ case Property.Name:
+ ios.Value = target.Name;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Capacity:
+ target.Capacity = ioi.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (collectionData.Value == null)
+ {
+ return "Error: no collection set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (collectionData.collectionRef == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs.meta
new file mode 100644
index 00000000..acc59187
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/CollectionProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6f03dcf7e7a1d2e418e5588731888b5a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs b/Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs
new file mode 100644
index 00000000..4a8e4640
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs
@@ -0,0 +1,153 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Collider2D component
+ ///
+ [CommandInfo("Property",
+ "Collider2D",
+ "Get or Set a property of a Collider2D component")]
+ [AddComponentMenu("")]
+ public class Collider2DProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Density,
+ IsTrigger,
+ UsedByEffector,
+ UsedByComposite,
+ Offset,
+ AttachedRigidbody,
+ ShapeCount,
+ Friction,
+ Bounciness,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected Collider2DData collider2DData;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(BooleanVariable),
+ typeof(Vector2Variable),
+ typeof(Rigidbody2DVariable),
+ typeof(IntegerVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var iob = inOutVar as BooleanVariable;
+ var iov2 = inOutVar as Vector2Variable;
+ var iorb2d = inOutVar as Rigidbody2DVariable;
+ var ioi = inOutVar as IntegerVariable;
+
+
+ var target = collider2DData.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Density:
+ iof.Value = target.density;
+ break;
+ case Property.IsTrigger:
+ iob.Value = target.isTrigger;
+ break;
+ case Property.UsedByEffector:
+ iob.Value = target.usedByEffector;
+ break;
+ case Property.UsedByComposite:
+ iob.Value = target.usedByComposite;
+ break;
+ case Property.Offset:
+ iov2.Value = target.offset;
+ break;
+ case Property.AttachedRigidbody:
+ iorb2d.Value = target.attachedRigidbody;
+ break;
+ case Property.ShapeCount:
+ ioi.Value = target.shapeCount;
+ break;
+ case Property.Friction:
+ iof.Value = target.friction;
+ break;
+ case Property.Bounciness:
+ iof.Value = target.bounciness;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Density:
+ target.density = iof.Value;
+ break;
+ case Property.IsTrigger:
+ target.isTrigger = iob.Value;
+ break;
+ case Property.UsedByEffector:
+ target.usedByEffector = iob.Value;
+ break;
+ case Property.UsedByComposite:
+ target.usedByComposite = iob.Value;
+ break;
+ case Property.Offset:
+ target.offset = iov2.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (collider2DData.Value == null)
+ {
+ return "Error: no collider2D set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (collider2DData.collider2DRef == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs.meta
new file mode 100644
index 00000000..b4d91cc7
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Collider2DProperty.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: c5d345b268622414c9bb53e05f4580ed
+timeCreated: 1517559095
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs b/Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs
new file mode 100644
index 00000000..2272ea61
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs
@@ -0,0 +1,123 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Collider component
+ ///
+ [CommandInfo("Property",
+ "Collider",
+ "Get or Set a property of a Collider component")]
+ [AddComponentMenu("")]
+ public class ColliderProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Enabled,
+ AttachedRigidbody,
+ IsTrigger,
+ ContactOffset,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected ColliderData colliderData;
+
+ [SerializeField]
+ [VariableProperty(typeof(BooleanVariable),
+ typeof(RigidbodyVariable),
+ typeof(FloatVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iob = inOutVar as BooleanVariable;
+ var iorb = inOutVar as RigidbodyVariable;
+ var iof = inOutVar as FloatVariable;
+
+
+ var target = colliderData.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Enabled:
+ iob.Value = target.enabled;
+ break;
+ case Property.AttachedRigidbody:
+ iorb.Value = target.attachedRigidbody;
+ break;
+ case Property.IsTrigger:
+ iob.Value = target.isTrigger;
+ break;
+ case Property.ContactOffset:
+ iof.Value = target.contactOffset;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Enabled:
+ target.enabled = iob.Value;
+ break;
+ case Property.IsTrigger:
+ target.isTrigger = iob.Value;
+ break;
+ case Property.ContactOffset:
+ target.contactOffset = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (colliderData.Value == null)
+ {
+ return "Error: no collider set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (colliderData.colliderRef == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs.meta
new file mode 100644
index 00000000..b037186d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/ColliderProperty.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: ca6e05b34c44a734988887ef775a1a1b
+timeCreated: 1517559091
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs b/Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs
new file mode 100644
index 00000000..df506178
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs
@@ -0,0 +1,147 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Collision2D component
+ ///
+ [CommandInfo("Property",
+ "Collision2D",
+ "Get or Set a property of a Collision2D component")]
+ [AddComponentMenu("")]
+ public class Collision2DProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Rigidbody,
+ OtherRigidbody,
+ Transform,
+ GameObject,
+ RelativeVelocity,
+ Enabled,
+ Collider,
+ OtherCollider,
+ ContactCount,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(Collision2DVariable))]
+ protected Collision2DVariable collision2DVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(Collider2DVariable),
+ typeof(Rigidbody2DVariable),
+ typeof(TransformVariable),
+ typeof(GameObjectVariable),
+ typeof(Vector2Variable),
+ typeof(BooleanVariable),
+ typeof(IntegerVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var ioc2d = inOutVar as Collider2DVariable;
+ var iorb2d = inOutVar as Rigidbody2DVariable;
+ var iot = inOutVar as TransformVariable;
+ var iogo = inOutVar as GameObjectVariable;
+ var iov2 = inOutVar as Vector2Variable;
+ var iob = inOutVar as BooleanVariable;
+#if UNITY_2019_2_OR_NEWER
+ var ioi = inOutVar as IntegerVariable;
+#endif
+
+
+ var target = collision2DVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Collider:
+ ioc2d.Value = target.collider;
+ break;
+ case Property.OtherCollider:
+ ioc2d.Value = target.otherCollider;
+ break;
+ case Property.Rigidbody:
+ iorb2d.Value = target.rigidbody;
+ break;
+ case Property.OtherRigidbody:
+ iorb2d.Value = target.otherRigidbody;
+ break;
+ case Property.Transform:
+ iot.Value = target.transform;
+ break;
+ case Property.GameObject:
+ iogo.Value = target.gameObject;
+ break;
+ case Property.RelativeVelocity:
+ iov2.Value = target.relativeVelocity;
+ break;
+ case Property.Enabled:
+ iob.Value = target.enabled;
+ break;
+#if UNITY_2019_2_OR_NEWER
+ case Property.ContactCount:
+ ioi.Value = target.contactCount;
+ break;
+#endif
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (collision2DVar == null)
+ {
+ return "Error: no collision2DVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (collision2DVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs.meta
new file mode 100644
index 00000000..e13e15dd
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 8556e15e3a9145740815675ae531a7cd
+timeCreated: 1517559039
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/CollisionProperty.cs b/Assets/Fungus/Scripts/Commands/Property/CollisionProperty.cs
new file mode 100644
index 00000000..6343654e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/CollisionProperty.cs
@@ -0,0 +1,127 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Collision component
+ ///
+ [CommandInfo("Property",
+ "Collision",
+ "Get or Set a property of a Collision component")]
+ [AddComponentMenu("")]
+ public class CollisionProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ RelativeVelocity,
+ Rigidbody,
+ Collider,
+ Transform,
+ GameObject,
+ Impulse,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(CollisionVariable))]
+ protected CollisionVariable collisionVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(Vector3Variable),
+ typeof(RigidbodyVariable),
+ typeof(ColliderVariable),
+ typeof(TransformVariable),
+ typeof(GameObjectVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iov = inOutVar as Vector3Variable;
+ var iorb = inOutVar as RigidbodyVariable;
+ var ioc = inOutVar as ColliderVariable;
+ var iot = inOutVar as TransformVariable;
+ var iogo = inOutVar as GameObjectVariable;
+
+
+ var target = collisionVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.RelativeVelocity:
+ iov.Value = target.relativeVelocity;
+ break;
+ case Property.Rigidbody:
+ iorb.Value = target.rigidbody;
+ break;
+ case Property.Collider:
+ ioc.Value = target.collider;
+ break;
+ case Property.Transform:
+ iot.Value = target.transform;
+ break;
+ case Property.GameObject:
+ iogo.Value = target.gameObject;
+ break;
+ case Property.Impulse:
+ iov.Value = target.impulse;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (collisionVar == null)
+ {
+ return "Error: no collisionVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (collisionVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/CollisionProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/CollisionProperty.cs.meta
new file mode 100644
index 00000000..9f3fc58f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/CollisionProperty.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 5d7861de0e23aac439a4959cd06b3d09
+timeCreated: 1517559033
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/ColorProperty.cs b/Assets/Fungus/Scripts/Commands/Property/ColorProperty.cs
new file mode 100644
index 00000000..0046f028
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/ColorProperty.cs
@@ -0,0 +1,137 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Color component
+ ///
+ [CommandInfo("Property",
+ "Color",
+ "Get or Set a property of a Color component")]
+ [AddComponentMenu("")]
+ public class ColorProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ R,
+ G,
+ B,
+ A,
+ Grayscale,
+ Linear,
+ Gamma,
+ MaxColorComponent,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(ColorVariable))]
+ protected ColorVariable colorVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(ColorVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var iocol = inOutVar as ColorVariable;
+
+
+ var target = colorVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.R:
+ iof.Value = target.r;
+ break;
+ case Property.G:
+ iof.Value = target.g;
+ break;
+ case Property.B:
+ iof.Value = target.b;
+ break;
+ case Property.A:
+ iof.Value = target.a;
+ break;
+ case Property.Grayscale:
+ iof.Value = target.grayscale;
+ break;
+ case Property.Linear:
+ iocol.Value = target.linear;
+ break;
+ case Property.Gamma:
+ iocol.Value = target.gamma;
+ break;
+ case Property.MaxColorComponent:
+ iof.Value = target.maxColorComponent;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.R:
+ target.r = iof.Value;
+ break;
+ case Property.G:
+ target.g = iof.Value;
+ break;
+ case Property.B:
+ target.b = iof.Value;
+ break;
+ case Property.A:
+ target.a = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (colorVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/ColorProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/ColorProperty.cs.meta
new file mode 100644
index 00000000..e74334c9
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/ColorProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8c9c405ac7b91be439696c5607bddb01
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/ControllerColliderHitProperty.cs b/Assets/Fungus/Scripts/Commands/Property/ControllerColliderHitProperty.cs
new file mode 100644
index 00000000..7be49bbe
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/ControllerColliderHitProperty.cs
@@ -0,0 +1,137 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a ControllerColliderHit component
+ ///
+ [CommandInfo("Property",
+ "ControllerColliderHit",
+ "Get or Set a property of a ControllerColliderHit component")]
+ [AddComponentMenu("")]
+ public class ControllerColliderHitProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Collider,
+ Rigidbody,
+ GameObject,
+ Transform,
+ Point,
+ Normal,
+ MoveDirection,
+ MoveLength,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(ControllerColliderHitVariable))]
+ protected ControllerColliderHitVariable controllerColliderHitVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(ColliderVariable),
+ typeof(RigidbodyVariable),
+ typeof(GameObjectVariable),
+ typeof(TransformVariable),
+ typeof(Vector3Variable),
+ typeof(FloatVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var ioc = inOutVar as ColliderVariable;
+ var iorb = inOutVar as RigidbodyVariable;
+ var iogo = inOutVar as GameObjectVariable;
+ var iot = inOutVar as TransformVariable;
+ var iov = inOutVar as Vector3Variable;
+ var iof = inOutVar as FloatVariable;
+
+
+ var target = controllerColliderHitVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Collider:
+ ioc.Value = target.collider;
+ break;
+ case Property.Rigidbody:
+ iorb.Value = target.rigidbody;
+ break;
+ case Property.GameObject:
+ iogo.Value = target.gameObject;
+ break;
+ case Property.Transform:
+ iot.Value = target.transform;
+ break;
+ case Property.Point:
+ iov.Value = target.point;
+ break;
+ case Property.Normal:
+ iov.Value = target.normal;
+ break;
+ case Property.MoveDirection:
+ iov.Value = target.moveDirection;
+ break;
+ case Property.MoveLength:
+ iof.Value = target.moveLength;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (controllerColliderHitVar == null)
+ {
+ return "Error: no controllerColliderHitVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (controllerColliderHitVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/ControllerColliderHitProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/ControllerColliderHitProperty.cs.meta
new file mode 100644
index 00000000..49532f48
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/ControllerColliderHitProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 706c416dcce1daf4188e35d5981ac45f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/GameObjectProperty.cs b/Assets/Fungus/Scripts/Commands/Property/GameObjectProperty.cs
new file mode 100644
index 00000000..6d669fc0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/GameObjectProperty.cs
@@ -0,0 +1,140 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a GameObject component
+ ///
+ [CommandInfo("Property",
+ "GameObject",
+ "Get or Set a property of a GameObject component")]
+ [AddComponentMenu("")]
+ public class GameObjectProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Transform,
+ Layer,
+ ActiveSelf,
+ ActiveInHierarchy,
+ IsStatic,
+ Tag,
+ GameObject,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(GameObjectVariable))]
+ protected GameObjectVariable gameObjectVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(TransformVariable),
+ typeof(IntegerVariable),
+ typeof(BooleanVariable),
+ typeof(StringVariable),
+ typeof(GameObjectVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iot = inOutVar as TransformVariable;
+ var ioi = inOutVar as IntegerVariable;
+ var iob = inOutVar as BooleanVariable;
+ var ios = inOutVar as StringVariable;
+ var iogo = inOutVar as GameObjectVariable;
+
+
+ var target = gameObjectVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Transform:
+ iot.Value = target.transform;
+ break;
+ case Property.Layer:
+ ioi.Value = target.layer;
+ break;
+ case Property.ActiveSelf:
+ iob.Value = target.activeSelf;
+ break;
+ case Property.ActiveInHierarchy:
+ iob.Value = target.activeInHierarchy;
+ break;
+ case Property.IsStatic:
+ iob.Value = target.isStatic;
+ break;
+ case Property.Tag:
+ ios.Value = target.tag;
+ break;
+ case Property.GameObject:
+ iogo.Value = target.gameObject;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Layer:
+ target.layer = ioi.Value;
+ break;
+ case Property.IsStatic:
+ target.isStatic = iob.Value;
+ break;
+ case Property.Tag:
+ target.tag = ios.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (gameObjectVar == null)
+ {
+ return "Error: no gameObjectVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (gameObjectVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/GameObjectProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/GameObjectProperty.cs.meta
new file mode 100644
index 00000000..94d39dae
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/GameObjectProperty.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 121c2a4d38c149443adb81911f0fdd61
+timeCreated: 1517613000
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/MaterialProperty.cs b/Assets/Fungus/Scripts/Commands/Property/MaterialProperty.cs
new file mode 100644
index 00000000..be1a846c
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/MaterialProperty.cs
@@ -0,0 +1,156 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Material component
+ ///
+ [CommandInfo("Property",
+ "Material",
+ "Get or Set a property of a Material component")]
+ [AddComponentMenu("")]
+ public class MaterialProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Color,
+ MainTexture,
+ MainTextureOffset,
+ MainTextureScale,
+ RenderQueue,
+ DoubleSidedGI,
+ EnableInstancing,
+ PassCount,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(MaterialVariable))]
+ protected MaterialVariable materialVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(ColorVariable),
+ typeof(TextureVariable),
+ typeof(Vector2Variable),
+ typeof(IntegerVariable),
+ typeof(BooleanVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iocol = inOutVar as ColorVariable;
+ var iotex = inOutVar as TextureVariable;
+ var iov2 = inOutVar as Vector2Variable;
+ var ioi = inOutVar as IntegerVariable;
+ var iob = inOutVar as BooleanVariable;
+
+
+ var target = materialVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Color:
+ iocol.Value = target.color;
+ break;
+ case Property.MainTexture:
+ iotex.Value = target.mainTexture;
+ break;
+ case Property.MainTextureOffset:
+ iov2.Value = target.mainTextureOffset;
+ break;
+ case Property.MainTextureScale:
+ iov2.Value = target.mainTextureScale;
+ break;
+ case Property.RenderQueue:
+ ioi.Value = target.renderQueue;
+ break;
+ case Property.DoubleSidedGI:
+ iob.Value = target.doubleSidedGI;
+ break;
+ case Property.EnableInstancing:
+ iob.Value = target.enableInstancing;
+ break;
+ case Property.PassCount:
+ ioi.Value = target.passCount;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Color:
+ target.color = iocol.Value;
+ break;
+ case Property.MainTexture:
+ target.mainTexture = iotex.Value;
+ break;
+ case Property.MainTextureOffset:
+ target.mainTextureOffset = iov2.Value;
+ break;
+ case Property.MainTextureScale:
+ target.mainTextureScale = iov2.Value;
+ break;
+ case Property.RenderQueue:
+ target.renderQueue = ioi.Value;
+ break;
+ case Property.DoubleSidedGI:
+ target.doubleSidedGI = iob.Value;
+ break;
+ case Property.EnableInstancing:
+ target.enableInstancing = iob.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (materialVar == null)
+ {
+ return "Error: no materialVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (materialVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/MaterialProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/MaterialProperty.cs.meta
new file mode 100644
index 00000000..65888d7f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/MaterialProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 363b2ba6b0053774884b097fb9312a46
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/Matrix4x4Property.cs b/Assets/Fungus/Scripts/Commands/Property/Matrix4x4Property.cs
new file mode 100644
index 00000000..78b7db07
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Matrix4x4Property.cs
@@ -0,0 +1,234 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Matrix4x4 component
+ ///
+ [CommandInfo("Property",
+ "Matrix4x4",
+ "Get or Set a property of a Matrix4x4 component")]
+ [AddComponentMenu("")]
+ public class Matrix4x4Property : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ M00,
+ M10,
+ M20,
+ M30,
+ M01,
+ M11,
+ M21,
+ M31,
+ M02,
+ M12,
+ M22,
+ M32,
+ M03,
+ M13,
+ M23,
+ M33,
+ Inverse,
+ Transpose,
+ Rotation,
+ LossyScale,
+ IsIdentity,
+ Determinant,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected Matrix4x4Data matrix4x4Data;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(QuaternionVariable),
+ typeof(Vector3Variable),
+ typeof(BooleanVariable),
+ typeof(Matrix4x4Variable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var ioq = inOutVar as QuaternionVariable;
+ var iov = inOutVar as Vector3Variable;
+ var iob = inOutVar as BooleanVariable;
+ var iom4 = inOutVar as Matrix4x4Variable;
+
+
+ var target = matrix4x4Data.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.M00:
+ iof.Value = target.m00;
+ break;
+ case Property.M10:
+ iof.Value = target.m10;
+ break;
+ case Property.M20:
+ iof.Value = target.m20;
+ break;
+ case Property.M30:
+ iof.Value = target.m30;
+ break;
+ case Property.M01:
+ iof.Value = target.m01;
+ break;
+ case Property.M11:
+ iof.Value = target.m11;
+ break;
+ case Property.M21:
+ iof.Value = target.m21;
+ break;
+ case Property.M31:
+ iof.Value = target.m31;
+ break;
+ case Property.M02:
+ iof.Value = target.m02;
+ break;
+ case Property.M12:
+ iof.Value = target.m12;
+ break;
+ case Property.M22:
+ iof.Value = target.m22;
+ break;
+ case Property.M32:
+ iof.Value = target.m32;
+ break;
+ case Property.M03:
+ iof.Value = target.m03;
+ break;
+ case Property.M13:
+ iof.Value = target.m13;
+ break;
+ case Property.M23:
+ iof.Value = target.m23;
+ break;
+ case Property.M33:
+ iof.Value = target.m33;
+ break;
+ case Property.Rotation:
+ ioq.Value = target.rotation;
+ break;
+ case Property.LossyScale:
+ iov.Value = target.lossyScale;
+ break;
+ case Property.IsIdentity:
+ iob.Value = target.isIdentity;
+ break;
+ case Property.Determinant:
+ iof.Value = target.determinant;
+ break;
+ case Property.Inverse:
+ iom4.Value = target.inverse;
+ break;
+ case Property.Transpose:
+ iom4.Value = target.transpose;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.M00:
+ target.m00 = iof.Value;
+ break;
+ case Property.M10:
+ target.m10 = iof.Value;
+ break;
+ case Property.M20:
+ target.m20 = iof.Value;
+ break;
+ case Property.M30:
+ target.m30 = iof.Value;
+ break;
+ case Property.M01:
+ target.m01 = iof.Value;
+ break;
+ case Property.M11:
+ target.m11 = iof.Value;
+ break;
+ case Property.M21:
+ target.m21 = iof.Value;
+ break;
+ case Property.M31:
+ target.m31 = iof.Value;
+ break;
+ case Property.M02:
+ target.m02 = iof.Value;
+ break;
+ case Property.M12:
+ target.m12 = iof.Value;
+ break;
+ case Property.M22:
+ target.m22 = iof.Value;
+ break;
+ case Property.M32:
+ target.m32 = iof.Value;
+ break;
+ case Property.M03:
+ target.m03 = iof.Value;
+ break;
+ case Property.M13:
+ target.m13 = iof.Value;
+ break;
+ case Property.M23:
+ target.m23 = iof.Value;
+ break;
+ case Property.M33:
+ target.m33 = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (matrix4x4Data.matrix4x4Ref == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/Matrix4x4Property.cs.meta b/Assets/Fungus/Scripts/Commands/Property/Matrix4x4Property.cs.meta
new file mode 100644
index 00000000..cd528c70
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Matrix4x4Property.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 37ada407c7c9fab46abba0d40c27fa96
+timeCreated: 1513287480
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs b/Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs
new file mode 100644
index 00000000..fabf624c
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs
@@ -0,0 +1,137 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Quaternion component
+ ///
+ [CommandInfo("Property",
+ "Quaternion",
+ "Get or Set a property of a Quaternion component")]
+ [AddComponentMenu("")]
+ public class QuaternionProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ X,
+ Y,
+ Z,
+ W,
+ EulerAngles,
+ Normalized,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected QuaternionData quaternionData;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(Vector3Variable),
+ typeof(QuaternionVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var iov = inOutVar as Vector3Variable;
+#if UNITY_2019_2_OR_NEWER
+ var ioq = inOutVar as QuaternionVariable;
+#endif
+
+
+ var target = quaternionData.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.X:
+ iof.Value = target.x;
+ break;
+ case Property.Y:
+ iof.Value = target.y;
+ break;
+ case Property.Z:
+ iof.Value = target.z;
+ break;
+ case Property.W:
+ iof.Value = target.w;
+ break;
+ case Property.EulerAngles:
+ iov.Value = target.eulerAngles;
+ break;
+#if UNITY_2019_2_OR_NEWER
+ case Property.Normalized:
+ ioq.Value = target.normalized;
+ break;
+#endif
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.X:
+ target.x = iof.Value;
+ break;
+ case Property.Y:
+ target.y = iof.Value;
+ break;
+ case Property.Z:
+ target.z = iof.Value;
+ break;
+ case Property.W:
+ target.w = iof.Value;
+ break;
+ case Property.EulerAngles:
+ target.eulerAngles = iov.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (quaternionData.quaternionRef == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs.meta
new file mode 100644
index 00000000..7fc4480f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 1082e9a99a168824583a459d59a448a0
+timeCreated: 1513287464
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/Rigidbody2DProperty.cs b/Assets/Fungus/Scripts/Commands/Property/Rigidbody2DProperty.cs
new file mode 100644
index 00000000..fd52a104
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Rigidbody2DProperty.cs
@@ -0,0 +1,213 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Rigidbody2D component
+ ///
+ [CommandInfo("Property",
+ "Rigidbody2D",
+ "Get or Set a property of a Rigidbody2D component")]
+ [AddComponentMenu("")]
+ public class Rigidbody2DProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Position,
+ Rotation,
+ Velocity,
+ AngularVelocity,
+ UseAutoMass,
+ Mass,
+ CenterOfMass,
+ WorldCenterOfMass,
+ Inertia,
+ Drag,
+ AngularDrag,
+ GravityScale,
+ UseFullKinematicContacts,
+ IsKinematic,
+ FreezeRotation,
+ Simulated,
+ AttachedColliderCount,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected Rigidbody2DData rigidbody2DData;
+
+ [SerializeField]
+ [VariableProperty(typeof(Vector2Variable),
+ typeof(FloatVariable),
+ typeof(BooleanVariable),
+ typeof(IntegerVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iov2 = inOutVar as Vector2Variable;
+ var iof = inOutVar as FloatVariable;
+ var iob = inOutVar as BooleanVariable;
+ var ioi = inOutVar as IntegerVariable;
+
+
+ var target = rigidbody2DData.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Position:
+ iov2.Value = target.position;
+ break;
+ case Property.Rotation:
+ iof.Value = target.rotation;
+ break;
+ case Property.Velocity:
+ iov2.Value = target.velocity;
+ break;
+ case Property.AngularVelocity:
+ iof.Value = target.angularVelocity;
+ break;
+ case Property.UseAutoMass:
+ iob.Value = target.useAutoMass;
+ break;
+ case Property.Mass:
+ iof.Value = target.mass;
+ break;
+ case Property.CenterOfMass:
+ iov2.Value = target.centerOfMass;
+ break;
+ case Property.WorldCenterOfMass:
+ iov2.Value = target.worldCenterOfMass;
+ break;
+ case Property.Inertia:
+ iof.Value = target.inertia;
+ break;
+ case Property.Drag:
+ iof.Value = target.drag;
+ break;
+ case Property.AngularDrag:
+ iof.Value = target.angularDrag;
+ break;
+ case Property.GravityScale:
+ iof.Value = target.gravityScale;
+ break;
+ case Property.UseFullKinematicContacts:
+ iob.Value = target.useFullKinematicContacts;
+ break;
+ case Property.IsKinematic:
+ iob.Value = target.isKinematic;
+ break;
+ case Property.FreezeRotation:
+ iob.Value = target.freezeRotation;
+ break;
+ case Property.Simulated:
+ iob.Value = target.simulated;
+ break;
+ case Property.AttachedColliderCount:
+ ioi.Value = target.attachedColliderCount;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Position:
+ target.position = iov2.Value;
+ break;
+ case Property.Rotation:
+ target.rotation = iof.Value;
+ break;
+ case Property.Velocity:
+ target.velocity = iov2.Value;
+ break;
+ case Property.AngularVelocity:
+ target.angularVelocity = iof.Value;
+ break;
+ case Property.UseAutoMass:
+ target.useAutoMass = iob.Value;
+ break;
+ case Property.Mass:
+ target.mass = iof.Value;
+ break;
+ case Property.CenterOfMass:
+ target.centerOfMass = iov2.Value;
+ break;
+ case Property.Inertia:
+ target.inertia = iof.Value;
+ break;
+ case Property.Drag:
+ target.drag = iof.Value;
+ break;
+ case Property.AngularDrag:
+ target.angularDrag = iof.Value;
+ break;
+ case Property.GravityScale:
+ target.gravityScale = iof.Value;
+ break;
+ case Property.UseFullKinematicContacts:
+ target.useFullKinematicContacts = iob.Value;
+ break;
+ case Property.IsKinematic:
+ target.isKinematic = iob.Value;
+ break;
+ case Property.FreezeRotation:
+ target.freezeRotation = iob.Value;
+ break;
+ case Property.Simulated:
+ target.simulated = iob.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (rigidbody2DData.Value == null)
+ {
+ return "Error: no rigidbody2D set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (rigidbody2DData.rigidbody2DRef == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/Rigidbody2DProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/Rigidbody2DProperty.cs.meta
new file mode 100644
index 00000000..2cda84a5
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Rigidbody2DProperty.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 3e16d7fb8c3b00d4c969c48110fc69c2
+timeCreated: 1517559027
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/RigidbodyProperty.cs b/Assets/Fungus/Scripts/Commands/Property/RigidbodyProperty.cs
new file mode 100644
index 00000000..1506cb40
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/RigidbodyProperty.cs
@@ -0,0 +1,239 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Rigidbody component
+ ///
+ [CommandInfo("Property",
+ "Rigidbody",
+ "Get or Set a property of a Rigidbody component")]
+ [AddComponentMenu("")]
+ public class RigidbodyProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Velocity,
+ AngularVelocity,
+ Drag,
+ AngularDrag,
+ Mass,
+ UseGravity,
+ MaxDepenetrationVelocity,
+ IsKinematic,
+ FreezeRotation,
+ CenterOfMass,
+ WorldCenterOfMass,
+ InertiaTensorRotation,
+ InertiaTensor,
+ DetectCollisions,
+ Position,
+ Rotation,
+ SolverIterations,
+ SolverVelocityIterations,
+ SleepThreshold,
+ MaxAngularVelocity,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected RigidbodyData rigidbodyData;
+
+ [SerializeField]
+ [VariableProperty(typeof(Vector3Variable),
+ typeof(FloatVariable),
+ typeof(BooleanVariable),
+ typeof(QuaternionVariable),
+ typeof(IntegerVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iov = inOutVar as Vector3Variable;
+ var iof = inOutVar as FloatVariable;
+ var iob = inOutVar as BooleanVariable;
+ var ioq = inOutVar as QuaternionVariable;
+ var ioi = inOutVar as IntegerVariable;
+
+
+ var target = rigidbodyData.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Velocity:
+ iov.Value = target.velocity;
+ break;
+ case Property.AngularVelocity:
+ iov.Value = target.angularVelocity;
+ break;
+ case Property.Drag:
+ iof.Value = target.drag;
+ break;
+ case Property.AngularDrag:
+ iof.Value = target.angularDrag;
+ break;
+ case Property.Mass:
+ iof.Value = target.mass;
+ break;
+ case Property.UseGravity:
+ iob.Value = target.useGravity;
+ break;
+ case Property.MaxDepenetrationVelocity:
+ iof.Value = target.maxDepenetrationVelocity;
+ break;
+ case Property.IsKinematic:
+ iob.Value = target.isKinematic;
+ break;
+ case Property.FreezeRotation:
+ iob.Value = target.freezeRotation;
+ break;
+ case Property.CenterOfMass:
+ iov.Value = target.centerOfMass;
+ break;
+ case Property.WorldCenterOfMass:
+ iov.Value = target.worldCenterOfMass;
+ break;
+ case Property.InertiaTensorRotation:
+ ioq.Value = target.inertiaTensorRotation;
+ break;
+ case Property.InertiaTensor:
+ iov.Value = target.inertiaTensor;
+ break;
+ case Property.DetectCollisions:
+ iob.Value = target.detectCollisions;
+ break;
+ case Property.Position:
+ iov.Value = target.position;
+ break;
+ case Property.Rotation:
+ ioq.Value = target.rotation;
+ break;
+ case Property.SolverIterations:
+ ioi.Value = target.solverIterations;
+ break;
+ case Property.SleepThreshold:
+ iof.Value = target.sleepThreshold;
+ break;
+ case Property.MaxAngularVelocity:
+ iof.Value = target.maxAngularVelocity;
+ break;
+ case Property.SolverVelocityIterations:
+ ioi.Value = target.solverVelocityIterations;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Velocity:
+ target.velocity = iov.Value;
+ break;
+ case Property.AngularVelocity:
+ target.angularVelocity = iov.Value;
+ break;
+ case Property.Drag:
+ target.drag = iof.Value;
+ break;
+ case Property.AngularDrag:
+ target.angularDrag = iof.Value;
+ break;
+ case Property.Mass:
+ target.mass = iof.Value;
+ break;
+ case Property.UseGravity:
+ target.useGravity = iob.Value;
+ break;
+ case Property.MaxDepenetrationVelocity:
+ target.maxDepenetrationVelocity = iof.Value;
+ break;
+ case Property.IsKinematic:
+ target.isKinematic = iob.Value;
+ break;
+ case Property.FreezeRotation:
+ target.freezeRotation = iob.Value;
+ break;
+ case Property.CenterOfMass:
+ target.centerOfMass = iov.Value;
+ break;
+ case Property.InertiaTensorRotation:
+ target.inertiaTensorRotation = ioq.Value;
+ break;
+ case Property.InertiaTensor:
+ target.inertiaTensor = iov.Value;
+ break;
+ case Property.DetectCollisions:
+ target.detectCollisions = iob.Value;
+ break;
+ case Property.Position:
+ target.position = iov.Value;
+ break;
+ case Property.Rotation:
+ target.rotation = ioq.Value;
+ break;
+ case Property.SolverIterations:
+ target.solverIterations = ioi.Value;
+ break;
+ case Property.SleepThreshold:
+ target.sleepThreshold = iof.Value;
+ break;
+ case Property.MaxAngularVelocity:
+ target.maxAngularVelocity = iof.Value;
+ break;
+ case Property.SolverVelocityIterations:
+ target.solverVelocityIterations = ioi.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (rigidbodyData.Value == null)
+ {
+ return "Error: no rigidbody set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (rigidbodyData.rigidbodyRef == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/RigidbodyProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/RigidbodyProperty.cs.meta
new file mode 100644
index 00000000..c554411e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/RigidbodyProperty.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: cdf9b24957fec22439bac2223dd88461
+timeCreated: 1517558732
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/SpriteProperty.cs b/Assets/Fungus/Scripts/Commands/Property/SpriteProperty.cs
new file mode 100644
index 00000000..f9f62689
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/SpriteProperty.cs
@@ -0,0 +1,121 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Sprite component
+ ///
+ [CommandInfo("Property",
+ "Sprite",
+ "Get or Set a property of a Sprite component")]
+ [AddComponentMenu("")]
+ public class SpriteProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Border,
+ PixelsPerUnit,
+ Pivot,
+ Packed,
+ TextureRectOffset,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(SpriteVariable))]
+ protected SpriteVariable spriteVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(Vector4Variable),
+ typeof(FloatVariable),
+ typeof(Vector2Variable),
+ typeof(BooleanVariable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iov4 = inOutVar as Vector4Variable;
+ var iof = inOutVar as FloatVariable;
+ var iov2 = inOutVar as Vector2Variable;
+ var iob = inOutVar as BooleanVariable;
+
+
+ var target = spriteVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Border:
+ iov4.Value = target.border;
+ break;
+ case Property.PixelsPerUnit:
+ iof.Value = target.pixelsPerUnit;
+ break;
+ case Property.Pivot:
+ iov2.Value = target.pivot;
+ break;
+ case Property.Packed:
+ iob.Value = target.packed;
+ break;
+ case Property.TextureRectOffset:
+ iov2.Value = target.textureRectOffset;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (spriteVar == null)
+ {
+ return "Error: no spriteVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (spriteVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/SpriteProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/SpriteProperty.cs.meta
new file mode 100644
index 00000000..6702eb7f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/SpriteProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c95150ec5d3a0374ba617655d4603934
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs b/Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs
new file mode 100644
index 00000000..9a293cdf
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs
@@ -0,0 +1,141 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Texture component
+ ///
+ [CommandInfo("Property",
+ "Texture",
+ "Get or Set a property of a Texture component")]
+ [AddComponentMenu("")]
+ public class TextureProperty : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ Width,
+ Height,
+ IsReadable,
+ AnisoLevel,
+ MipMapBias,
+ TexelSize,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(TextureVariable))]
+ protected TextureVariable textureVar;
+
+ [SerializeField]
+ [VariableProperty(typeof(IntegerVariable),
+ typeof(BooleanVariable),
+ typeof(FloatVariable),
+ typeof(Vector2Variable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var ioi = inOutVar as IntegerVariable;
+#if UNITY_2019_2_OR_NEWER
+ var iob = inOutVar as BooleanVariable;
+#endif
+ var iof = inOutVar as FloatVariable;
+ var iov2 = inOutVar as Vector2Variable;
+
+
+ var target = textureVar.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.Width:
+ ioi.Value = target.width;
+ break;
+ case Property.Height:
+ ioi.Value = target.height;
+ break;
+#if UNITY_2019_2_OR_NEWER
+ case Property.IsReadable:
+ iob.Value = target.isReadable;
+ break;
+#endif
+ case Property.AnisoLevel:
+ ioi.Value = target.anisoLevel;
+ break;
+ case Property.MipMapBias:
+ iof.Value = target.mipMapBias;
+ break;
+ case Property.TexelSize:
+ iov2.Value = target.texelSize;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.Width:
+ target.width = ioi.Value;
+ break;
+ case Property.Height:
+ target.height = ioi.Value;
+ break;
+ case Property.AnisoLevel:
+ target.anisoLevel = ioi.Value;
+ break;
+ case Property.MipMapBias:
+ target.mipMapBias = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (textureVar == null)
+ {
+ return "Error: no textureVar set";
+ }
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (textureVar == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs.meta
new file mode 100644
index 00000000..3da4179b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 31b49af150726234597bd728285c18f9
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Transform/TransformProperty.cs b/Assets/Fungus/Scripts/Commands/Property/TransformProperty.cs
similarity index 52%
rename from Assets/Fungus/Scripts/Commands/Transform/TransformProperty.cs
rename to Assets/Fungus/Scripts/Commands/Property/TransformProperty.cs
index 32c2850c..af51c0c2 100644
--- a/Assets/Fungus/Scripts/Commands/Transform/TransformProperty.cs
+++ b/Assets/Fungus/Scripts/Commands/Property/TransformProperty.cs
@@ -1,48 +1,48 @@
-using System.Collections;
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fungus
{
//
- /// Get or Set a property of a transform component
+ /// Get or Set a property of a Transform component
///
- [CommandInfo("Transform",
- "Property",
- "Get or Set a property of a transform component")]
+ [CommandInfo("Property",
+ "Transform",
+ "Get or Set a property of a Transform component")]
[AddComponentMenu("")]
- public class TransformProperty : Command
+ public class TransformProperty : BaseVariableProperty
{
- public enum GetSet
- {
- Get,
- Set,
+ //generated property
+ public enum Property
+ {
+ ChildCount,
+ EulerAngles,
+ Forward,
+ HasChanged,
+ HierarchyCapacity,
+ HierarchyCount,
+ LocalEulerAngles,
+ LocalPosition,
+ LocalScale,
+ LossyScale,
+ Parent,
+ Position,
+ Right,
+ Root,
+ Up,
+ Rotation,
+ LocalRotation,
+ WorldToLocalMatrix,
+ LocalToWorldMatrix,
}
- 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;
@@ -50,124 +50,136 @@ namespace Fungus
protected TransformData transformData;
[SerializeField]
- [VariableProperty(typeof(BooleanVariable),
+ [VariableProperty(typeof(Vector3Variable),
+ typeof(QuaternionVariable),
+ typeof(TransformVariable),
+ typeof(Matrix4x4Variable),
typeof(IntegerVariable),
- typeof(Vector3Variable),
- typeof(TransformVariable))]
+ typeof(BooleanVariable))]
protected Variable inOutVar;
public override void OnEnter()
{
- var iob = inOutVar as BooleanVariable;
- var ioi = inOutVar as IntegerVariable;
var iov = inOutVar as Vector3Variable;
+ var ioq = inOutVar as QuaternionVariable;
var iot = inOutVar as TransformVariable;
+ var iom4 = inOutVar as Matrix4x4Variable;
+ var ioi = inOutVar as IntegerVariable;
+ var iob = inOutVar as BooleanVariable;
- var t = transformData.Value;
+ var target = transformData.Value;
switch (getOrSet)
{
case GetSet.Get:
switch (property)
{
- case Property.ChildCount:
- ioi.Value = t.childCount;
+ case Property.Position:
+ iov.Value = target.position;
+ break;
+ case Property.LocalPosition:
+ iov.Value = target.localPosition;
break;
case Property.EulerAngles:
- iov.Value = t.eulerAngles;
+ iov.Value = target.eulerAngles;
break;
- case Property.Forward:
- iov.Value = t.forward;
+ case Property.LocalEulerAngles:
+ iov.Value = target.localEulerAngles;
break;
- case Property.HasChanged:
- iob.Value = t.hasChanged;
+ case Property.Right:
+ iov.Value = target.right;
break;
- case Property.HierarchyCapacity:
- ioi.Value = t.hierarchyCapacity;
+ case Property.Up:
+ iov.Value = target.up;
break;
- case Property.HierarchyCount:
- ioi.Value = t.hierarchyCount;
+ case Property.Forward:
+ iov.Value = target.forward;
break;
- case Property.LocalEulerAngles:
- iov.Value = t.localEulerAngles;
+ case Property.Rotation:
+ ioq.Value = target.rotation;
break;
- case Property.LocalPosition:
- iov.Value = t.localPosition;
+ case Property.LocalRotation:
+ ioq.Value = target.localRotation;
break;
case Property.LocalScale:
- iov.Value = t.localScale;
- break;
- case Property.LossyScale:
- iov.Value = t.lossyScale;
+ iov.Value = target.localScale;
break;
case Property.Parent:
- iot.Value = t.parent;
+ iot.Value = target.parent;
break;
- case Property.Position:
- iov.Value = t.position;
+ case Property.WorldToLocalMatrix:
+ iom4.Value = target.worldToLocalMatrix;
break;
- case Property.Right:
- iov.Value = t.right;
+ case Property.LocalToWorldMatrix:
+ iom4.Value = target.localToWorldMatrix;
break;
case Property.Root:
- iot.Value = t.parent;
+ iot.Value = target.root;
break;
- case Property.Up:
- iov.Value = t.up;
+ case Property.ChildCount:
+ ioi.Value = target.childCount;
+ break;
+ case Property.LossyScale:
+ iov.Value = target.lossyScale;
+ break;
+ case Property.HasChanged:
+ iob.Value = target.hasChanged;
+ break;
+ case Property.HierarchyCapacity:
+ ioi.Value = target.hierarchyCapacity;
+ break;
+ case Property.HierarchyCount:
+ ioi.Value = target.hierarchyCount;
break;
default:
+ Debug.Log("Unsupported get or set attempted");
break;
}
break;
case GetSet.Set:
switch (property)
{
- case Property.ChildCount:
- Debug.LogWarning("Cannot Set childCount, it is read only");
+ case Property.Position:
+ target.position = iov.Value;
+ break;
+ case Property.LocalPosition:
+ target.localPosition = iov.Value;
break;
case Property.EulerAngles:
- t.eulerAngles = iov.Value;
+ target.eulerAngles = iov.Value;
break;
- case Property.Forward:
- t.forward = iov.Value;
+ case Property.LocalEulerAngles:
+ target.localEulerAngles = iov.Value;
break;
- case Property.HasChanged:
- t.hasChanged = iob.Value;
+ case Property.Right:
+ target.right = iov.Value;
break;
- case Property.HierarchyCapacity:
- t.hierarchyCapacity = ioi.Value;
+ case Property.Up:
+ target.up = iov.Value;
break;
- case Property.HierarchyCount:
- Debug.LogWarning("Cannot Set HierarchyCount, it is read only");
+ case Property.Forward:
+ target.forward = iov.Value;
break;
- case Property.LocalEulerAngles:
- t.localEulerAngles = iov.Value;
+ case Property.Rotation:
+ target.rotation = ioq.Value;
break;
- case Property.LocalPosition:
- t.localPosition = iov.Value;
+ case Property.LocalRotation:
+ target.localRotation = ioq.Value;
break;
case Property.LocalScale:
- t.localScale = iov.Value;
- break;
- case Property.LossyScale:
- Debug.LogWarning("Cannot Set LossyScale, it is read only");
+ target.localScale = iov.Value;
break;
case Property.Parent:
- t.parent = iot.Value;
- break;
- case Property.Position:
- t.position = iov.Value;
+ target.parent = iot.Value;
break;
- case Property.Right:
- t.right = iov.Value;
- break;
- case Property.Root:
- Debug.LogWarning("Cannot Set Root, it is read only");
+ case Property.HasChanged:
+ target.hasChanged = iob.Value;
break;
- case Property.Up:
- t.up = iov.Value;
+ case Property.HierarchyCapacity:
+ target.hierarchyCapacity = ioi.Value;
break;
default:
+ Debug.Log("Unsupported get or set attempted");
break;
}
break;
@@ -184,13 +196,7 @@ namespace Fungus
{
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)
+ if (inOutVar == null)
{
return "Error: no variable set to push or pull data to or from";
}
diff --git a/Assets/Fungus/Scripts/Commands/Transform/TransformProperty.cs.meta b/Assets/Fungus/Scripts/Commands/Property/TransformProperty.cs.meta
similarity index 100%
rename from Assets/Fungus/Scripts/Commands/Transform/TransformProperty.cs.meta
rename to Assets/Fungus/Scripts/Commands/Property/TransformProperty.cs.meta
diff --git a/Assets/Fungus/Scripts/Commands/Property/Vector2Property.cs b/Assets/Fungus/Scripts/Commands/Property/Vector2Property.cs
new file mode 100644
index 00000000..2d2c4573
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Vector2Property.cs
@@ -0,0 +1,119 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Vector2 component
+ ///
+ [CommandInfo("Property",
+ "Vector2",
+ "Get or Set a property of a Vector2 component")]
+ [AddComponentMenu("")]
+ public class Vector2Property : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ X,
+ Y,
+ Normalized,
+ Magnitude,
+ SqrMagnitude,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(Vector2Variable))]
+ protected Vector2Variable vector2Var;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(Vector2Variable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var iov2 = inOutVar as Vector2Variable;
+
+
+ var target = vector2Var.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.X:
+ iof.Value = target.x;
+ break;
+ case Property.Y:
+ iof.Value = target.y;
+ break;
+ case Property.Normalized:
+ iov2.Value = target.normalized;
+ break;
+ case Property.Magnitude:
+ iof.Value = target.magnitude;
+ break;
+ case Property.SqrMagnitude:
+ iof.Value = target.sqrMagnitude;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.X:
+ target.x = iof.Value;
+ break;
+ case Property.Y:
+ target.y = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (vector2Var == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/Vector2Property.cs.meta b/Assets/Fungus/Scripts/Commands/Property/Vector2Property.cs.meta
new file mode 100644
index 00000000..3f9cb9c6
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Vector2Property.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a7015dec6a71cdd4ba95bb85217200b5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/Vector3Property.cs b/Assets/Fungus/Scripts/Commands/Property/Vector3Property.cs
new file mode 100644
index 00000000..bfd3bd0b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Vector3Property.cs
@@ -0,0 +1,126 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Vector3 component
+ ///
+ [CommandInfo("Property",
+ "Vector3",
+ "Get or Set a property of a Vector3 component")]
+ [AddComponentMenu("")]
+ public class Vector3Property : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ X,
+ Y,
+ Z,
+ Normalized,
+ Magnitude,
+ SqrMagnitude,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof(Vector3Variable))]
+ protected Vector3Variable vector3Var;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(Vector3Variable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var iov = inOutVar as Vector3Variable;
+
+
+ var target = vector3Var.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.X:
+ iof.Value = target.x;
+ break;
+ case Property.Y:
+ iof.Value = target.y;
+ break;
+ case Property.Z:
+ iof.Value = target.z;
+ break;
+ case Property.Normalized:
+ iov.Value = target.normalized;
+ break;
+ case Property.Magnitude:
+ iof.Value = target.magnitude;
+ break;
+ case Property.SqrMagnitude:
+ iof.Value = target.sqrMagnitude;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.X:
+ target.x = iof.Value;
+ break;
+ case Property.Y:
+ target.y = iof.Value;
+ break;
+ case Property.Z:
+ target.z = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (vector3Var == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/Vector3Property.cs.meta b/Assets/Fungus/Scripts/Commands/Property/Vector3Property.cs.meta
new file mode 100644
index 00000000..79e8c09a
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Vector3Property.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c9d421d283ce7de459ab56214f315618
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/Property/Vector4Property.cs b/Assets/Fungus/Scripts/Commands/Property/Vector4Property.cs
new file mode 100644
index 00000000..edfa07aa
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Vector4Property.cs
@@ -0,0 +1,132 @@
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+
+namespace Fungus
+{
+ //
+ /// Get or Set a property of a Vector4 component
+ ///
+ [CommandInfo("Property",
+ "Vector4",
+ "Get or Set a property of a Vector4 component")]
+ [AddComponentMenu("")]
+ public class Vector4Property : BaseVariableProperty
+ {
+ //generated property
+ public enum Property
+ {
+ X,
+ Y,
+ Z,
+ W,
+ Magnitude,
+ SqrMagnitude,
+ Normalized,
+ }
+
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected Vector4Data vector4Data;
+
+ [SerializeField]
+ [VariableProperty(typeof(FloatVariable),
+ typeof(Vector4Variable))]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {
+ var iof = inOutVar as FloatVariable;
+ var iov4 = inOutVar as Vector4Variable;
+
+
+ var target = vector4Data.Value;
+
+ switch (getOrSet)
+ {
+ case GetSet.Get:
+ switch (property)
+ {
+ case Property.X:
+ iof.Value = target.x;
+ break;
+ case Property.Y:
+ iof.Value = target.y;
+ break;
+ case Property.Z:
+ iof.Value = target.z;
+ break;
+ case Property.W:
+ iof.Value = target.w;
+ break;
+ case Property.Normalized:
+ iov4.Value = target.normalized;
+ break;
+ case Property.Magnitude:
+ iof.Value = target.magnitude;
+ break;
+ case Property.SqrMagnitude:
+ iof.Value = target.sqrMagnitude;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ case GetSet.Set:
+ switch (property)
+ {
+ case Property.X:
+ target.x = iof.Value;
+ break;
+ case Property.Y:
+ target.y = iof.Value;
+ break;
+ case Property.Z:
+ target.z = iof.Value;
+ break;
+ case Property.W:
+ target.w = iof.Value;
+ break;
+ default:
+ Debug.Log("Unsupported get or set attempted");
+ break;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (inOutVar == null)
+ {
+ return "Error: no variable set to push or pull data to or from";
+ }
+
+ return getOrSet.ToString() + " " + property.ToString();
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(235, 191, 217, 255);
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ if (vector4Data.vector4Ref == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Property/Vector4Property.cs.meta b/Assets/Fungus/Scripts/Commands/Property/Vector4Property.cs.meta
new file mode 100644
index 00000000..a60ca09f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/Property/Vector4Property.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 218837ae2b5d9ad4cb51c47575ce1ffc
+timeCreated: 1517559329
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/PunchPosition.cs b/Assets/Fungus/Scripts/Commands/PunchPosition.cs
index ff7b0b0a..f2250c24 100644
--- a/Assets/Fungus/Scripts/Commands/PunchPosition.cs
+++ b/Assets/Fungus/Scripts/Commands/PunchPosition.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PunchRotation.cs b/Assets/Fungus/Scripts/Commands/PunchRotation.cs
index 71fec5b9..1a04d3de 100644
--- a/Assets/Fungus/Scripts/Commands/PunchRotation.cs
+++ b/Assets/Fungus/Scripts/Commands/PunchRotation.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/PunchScale.cs b/Assets/Fungus/Scripts/Commands/PunchScale.cs
index 7523520e..2d642988 100644
--- a/Assets/Fungus/Scripts/Commands/PunchScale.cs
+++ b/Assets/Fungus/Scripts/Commands/PunchScale.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Quit.cs b/Assets/Fungus/Scripts/Commands/Quit.cs
index 7720b105..c017275b 100644
--- a/Assets/Fungus/Scripts/Commands/Quit.cs
+++ b/Assets/Fungus/Scripts/Commands/Quit.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/RandomFloat.cs b/Assets/Fungus/Scripts/Commands/RandomFloat.cs
index 1cfd5527..6eec2237 100644
--- a/Assets/Fungus/Scripts/Commands/RandomFloat.cs
+++ b/Assets/Fungus/Scripts/Commands/RandomFloat.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/RandomInteger.cs b/Assets/Fungus/Scripts/Commands/RandomInteger.cs
index aa201df5..f90b307c 100644
--- a/Assets/Fungus/Scripts/Commands/RandomInteger.cs
+++ b/Assets/Fungus/Scripts/Commands/RandomInteger.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ReadTextFile.cs b/Assets/Fungus/Scripts/Commands/ReadTextFile.cs
index 8c503ba6..10f58bb7 100644
--- a/Assets/Fungus/Scripts/Commands/ReadTextFile.cs
+++ b/Assets/Fungus/Scripts/Commands/ReadTextFile.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Reset.cs b/Assets/Fungus/Scripts/Commands/Reset.cs
index 6cda41f0..2dce3a3b 100644
--- a/Assets/Fungus/Scripts/Commands/Reset.cs
+++ b/Assets/Fungus/Scripts/Commands/Reset.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs
index baf3b277..56ef1806 100644
--- a/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs
+++ b/Assets/Fungus/Scripts/Commands/ResetAnimTrigger.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs b/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs
index bedb42a4..626124b6 100644
--- a/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs
+++ b/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddForce2D.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs b/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs
index 59c2b3a3..bfc2304d 100644
--- a/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs
+++ b/Assets/Fungus/Scripts/Commands/Rigidbody2D/AddTorque2D.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs b/Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs
index ef4c0e31..6f5f92b9 100644
--- a/Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs
+++ b/Assets/Fungus/Scripts/Commands/Rigidbody2D/StopMotionRigidBody2D.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/RotateAdd.cs b/Assets/Fungus/Scripts/Commands/RotateAdd.cs
index cf35b0dd..7bf7ae32 100644
--- a/Assets/Fungus/Scripts/Commands/RotateAdd.cs
+++ b/Assets/Fungus/Scripts/Commands/RotateAdd.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/RotateFrom.cs b/Assets/Fungus/Scripts/Commands/RotateFrom.cs
index 46224268..c5fc5564 100644
--- a/Assets/Fungus/Scripts/Commands/RotateFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/RotateFrom.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/RotateTo.cs b/Assets/Fungus/Scripts/Commands/RotateTo.cs
index 7f5bcf74..4420af13 100644
--- a/Assets/Fungus/Scripts/Commands/RotateTo.cs
+++ b/Assets/Fungus/Scripts/Commands/RotateTo.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SavePoint.cs b/Assets/Fungus/Scripts/Commands/SavePoint.cs
index 8f259749..2060f661 100644
--- a/Assets/Fungus/Scripts/Commands/SavePoint.cs
+++ b/Assets/Fungus/Scripts/Commands/SavePoint.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
diff --git a/Assets/Fungus/Scripts/Commands/SaveVariable.cs b/Assets/Fungus/Scripts/Commands/SaveVariable.cs
index 4a5522d9..08b3e949 100644
--- a/Assets/Fungus/Scripts/Commands/SaveVariable.cs
+++ b/Assets/Fungus/Scripts/Commands/SaveVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Say.cs b/Assets/Fungus/Scripts/Commands/Say.cs
index b86af519..451a002f 100644
--- a/Assets/Fungus/Scripts/Commands/Say.cs
+++ b/Assets/Fungus/Scripts/Commands/Say.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs
index be4e56f2..29dbd950 100644
--- a/Assets/Fungus/Scripts/Commands/ScaleAdd.cs
+++ b/Assets/Fungus/Scripts/Commands/ScaleAdd.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs
index 7c317f2a..335196fb 100644
--- a/Assets/Fungus/Scripts/Commands/ScaleFrom.cs
+++ b/Assets/Fungus/Scripts/Commands/ScaleFrom.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ScaleTo.cs b/Assets/Fungus/Scripts/Commands/ScaleTo.cs
index 3a80d57a..939176ad 100644
--- a/Assets/Fungus/Scripts/Commands/ScaleTo.cs
+++ b/Assets/Fungus/Scripts/Commands/ScaleTo.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs b/Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs
index 76161593..86f62a11 100644
--- a/Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs
+++ b/Assets/Fungus/Scripts/Commands/Scene/ReloadScene.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
diff --git a/Assets/Fungus/Scripts/Commands/SendMessage.cs b/Assets/Fungus/Scripts/Commands/SendMessage.cs
index 995fc09c..75024e85 100644
--- a/Assets/Fungus/Scripts/Commands/SendMessage.cs
+++ b/Assets/Fungus/Scripts/Commands/SendMessage.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetActive.cs b/Assets/Fungus/Scripts/Commands/SetActive.cs
index bafc947e..9013baee 100644
--- a/Assets/Fungus/Scripts/Commands/SetActive.cs
+++ b/Assets/Fungus/Scripts/Commands/SetActive.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs
index 26a7a778..88aae8ec 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimBool.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimBool.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs
index 5aa66f55..244d64f5 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimFloat.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs
index cb4e8076..3429b326 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimInteger.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs
index a3d190cc..c8c1e049 100644
--- a/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAnimTrigger.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs b/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs
index 6053d27a..e13af16a 100644
--- a/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAudioPitch.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs b/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs
index be9c9d75..80a7362a 100644
--- a/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs
+++ b/Assets/Fungus/Scripts/Commands/SetAudioVolume.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs
index 29a59de9..c63e4ec1 100644
--- a/Assets/Fungus/Scripts/Commands/SetClickable2D.cs
+++ b/Assets/Fungus/Scripts/Commands/SetClickable2D.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Scripts/Commands/SetCollider.cs
index 2cca14f8..d5a947db 100644
--- a/Assets/Fungus/Scripts/Commands/SetCollider.cs
+++ b/Assets/Fungus/Scripts/Commands/SetCollider.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs
index 3b8ac1ef..0f24ecde 100644
--- a/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs
+++ b/Assets/Fungus/Scripts/Commands/SetDraggable2D.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetInteractable.cs b/Assets/Fungus/Scripts/Commands/SetInteractable.cs
index ea2d0912..d6680a41 100644
--- a/Assets/Fungus/Scripts/Commands/SetInteractable.cs
+++ b/Assets/Fungus/Scripts/Commands/SetInteractable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetLanguage.cs b/Assets/Fungus/Scripts/Commands/SetLanguage.cs
index 9efc8867..f1c069a0 100644
--- a/Assets/Fungus/Scripts/Commands/SetLanguage.cs
+++ b/Assets/Fungus/Scripts/Commands/SetLanguage.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs b/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs
index 4eb82244..9e4e312f 100644
--- a/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs
+++ b/Assets/Fungus/Scripts/Commands/SetLayerOrder.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs b/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs
index 04ac2fc8..df5c1357 100644
--- a/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs
+++ b/Assets/Fungus/Scripts/Commands/SetMenuDialog.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs b/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs
index cc75ff6f..bb67c57f 100644
--- a/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs
+++ b/Assets/Fungus/Scripts/Commands/SetMouseCursor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs b/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs
index 2fa8f357..22552f84 100644
--- a/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs
+++ b/Assets/Fungus/Scripts/Commands/SetSaveProfile.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetSayDialog.cs b/Assets/Fungus/Scripts/Commands/SetSayDialog.cs
index 57e6bf64..8297b2dd 100644
--- a/Assets/Fungus/Scripts/Commands/SetSayDialog.cs
+++ b/Assets/Fungus/Scripts/Commands/SetSayDialog.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs
index f80b06c9..a3e3d930 100644
--- a/Assets/Fungus/Scripts/Commands/SetSliderValue.cs
+++ b/Assets/Fungus/Scripts/Commands/SetSliderValue.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetSprite.cs b/Assets/Fungus/Scripts/Commands/SetSprite.cs
index 8a2d7cdd..1968fc9d 100644
--- a/Assets/Fungus/Scripts/Commands/SetSprite.cs
+++ b/Assets/Fungus/Scripts/Commands/SetSprite.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
// Snippet added by ducksonthewater, 2019-01-03 - www.ducks-on-the-water.com
diff --git a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs
index fb811b6b..a233f4d0 100644
--- a/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs
+++ b/Assets/Fungus/Scripts/Commands/SetSpriteOrder.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetText.cs b/Assets/Fungus/Scripts/Commands/SetText.cs
index 500dd011..25918059 100644
--- a/Assets/Fungus/Scripts/Commands/SetText.cs
+++ b/Assets/Fungus/Scripts/Commands/SetText.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetToggleState.cs b/Assets/Fungus/Scripts/Commands/SetToggleState.cs
index d93a0262..361f9d40 100644
--- a/Assets/Fungus/Scripts/Commands/SetToggleState.cs
+++ b/Assets/Fungus/Scripts/Commands/SetToggleState.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetUIImage.cs b/Assets/Fungus/Scripts/Commands/SetUIImage.cs
index b30939e1..5a811bd2 100644
--- a/Assets/Fungus/Scripts/Commands/SetUIImage.cs
+++ b/Assets/Fungus/Scripts/Commands/SetUIImage.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SetVariable.cs b/Assets/Fungus/Scripts/Commands/SetVariable.cs
index 50ca8588..f9e7cfe5 100644
--- a/Assets/Fungus/Scripts/Commands/SetVariable.cs
+++ b/Assets/Fungus/Scripts/Commands/SetVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -13,399 +13,219 @@ namespace Fungus
"Set Variable",
"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.")]
[AddComponentMenu("")]
- public class SetVariable : Command
+ public class SetVariable : Command, ISerializationCallbackReceiver
{
- [Tooltip("The variable whos value will be set")]
- [VariableProperty(typeof(BooleanVariable),
- typeof(IntegerVariable),
- typeof(FloatVariable),
- typeof(StringVariable),
- typeof(AnimatorVariable),
- typeof(AudioSourceVariable),
- typeof(ColorVariable),
- typeof(GameObjectVariable),
- typeof(MaterialVariable),
- typeof(ObjectVariable),
- typeof(Rigidbody2DVariable),
- typeof(SpriteVariable),
- typeof(TextureVariable),
- typeof(TransformVariable),
- typeof(Vector2Variable),
- typeof(Vector3Variable))]
- [SerializeField] protected Variable variable;
-
+ [SerializeField] protected AnyVariableAndDataPair anyVar = new AnyVariableAndDataPair();
+
[Tooltip("The type of math operation to be performed")]
[SerializeField] protected SetOperator setOperator;
+
+ protected virtual void DoSetOperation()
+ {
+ if (anyVar.variable == null)
+ {
+ return;
+ }
+
+ anyVar.SetOp(setOperator);
+ }
+
+ #region Public members
- [Tooltip("Boolean value to set with")]
+ ///
+ /// The type of math operation to be performed.
+ ///
+ public virtual SetOperator _SetOperator { get { return setOperator; } }
+
+ public override void OnEnter()
+ {
+ DoSetOperation();
+
+ Continue();
+ }
+
+ public override string GetSummary()
+ {
+ if (anyVar.variable == null)
+ {
+ return "Error: Variable not selected";
+ }
+
+ string description = anyVar.variable.Key;
+ description += " " + VariableUtil.GetSetOperatorDescription(setOperator) + " ";
+ description += anyVar.GetDataDescription();
+
+
+ return description;
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return anyVar.HasReference(variable);
+ }
+
+ public override Color GetButtonColor()
+ {
+ return new Color32(253, 253, 150, 255);
+ }
+
+ #endregion
+
+ #region backwards compat
+
+
+ [Tooltip("Variable to use in expression")]
+ [VariableProperty(AllVariableTypes.VariableAny.Any)]
+ [SerializeField] protected Variable variable;
+
+ [Tooltip("Boolean value to compare against")]
[SerializeField] protected BooleanData booleanData;
- [Tooltip("Integer value to set with")]
+ [Tooltip("Integer value to compare against")]
[SerializeField] protected IntegerData integerData;
- [Tooltip("Float value to set with")]
+ [Tooltip("Float value to compare against")]
[SerializeField] protected FloatData floatData;
- [Tooltip("String value to set with")]
+ [Tooltip("String value to compare against")]
[SerializeField] protected StringDataMulti stringData;
- [Tooltip("Animator value to set with")]
+ [Tooltip("Animator value to compare against")]
[SerializeField] protected AnimatorData animatorData;
- [Tooltip("AudioSource value to set with")]
+ [Tooltip("AudioSource value to compare against")]
[SerializeField] protected AudioSourceData audioSourceData;
- [Tooltip("Color value to set with")]
+ [Tooltip("Color value to compare against")]
[SerializeField] protected ColorData colorData;
- [Tooltip("GameObject value to set with")]
+ [Tooltip("GameObject value to compare against")]
[SerializeField] protected GameObjectData gameObjectData;
- [Tooltip("Material value to set with")]
+ [Tooltip("Material value to compare against")]
[SerializeField] protected MaterialData materialData;
- [Tooltip("Object value to set with")]
+ [Tooltip("Object value to compare against")]
[SerializeField] protected ObjectData objectData;
- [Tooltip("Rigidbody2D value to set with")]
+ [Tooltip("Rigidbody2D value to compare against")]
[SerializeField] protected Rigidbody2DData rigidbody2DData;
- [Tooltip("Sprite value to set with")]
+ [Tooltip("Sprite value to compare against")]
[SerializeField] protected SpriteData spriteData;
- [Tooltip("Texture value to set with")]
+ [Tooltip("Texture value to compare against")]
[SerializeField] protected TextureData textureData;
- [Tooltip("Transform value to set with")]
+ [Tooltip("Transform value to compare against")]
[SerializeField] protected TransformData transformData;
- [Tooltip("Vector2 value to set with")]
+ [Tooltip("Vector2 value to compare against")]
[SerializeField] protected Vector2Data vector2Data;
- [Tooltip("Vector3 value to set with")]
+ [Tooltip("Vector3 value to compare against")]
[SerializeField] protected Vector3Data vector3Data;
- protected virtual void DoSetOperation()
+ public void OnBeforeSerialize()
{
- if (variable == null)
- {
- return;
- }
-
-
- var t = variable.GetType();
-
- if (t == typeof(BooleanVariable))
- {
- BooleanVariable booleanVariable = (variable as BooleanVariable);
- booleanVariable.Apply(setOperator, booleanData.Value);
- }
- else if (t == typeof(IntegerVariable))
- {
- IntegerVariable integerVariable = (variable as IntegerVariable);
- integerVariable.Apply(setOperator, integerData.Value);
- }
- else if (t == typeof(FloatVariable))
- {
- FloatVariable floatVariable = (variable as FloatVariable);
- floatVariable.Apply(setOperator, floatData.Value);
- }
- else if (t == typeof(StringVariable))
- {
- StringVariable stringVariable = (variable as StringVariable);
- var flowchart = GetFlowchart();
- stringVariable.Apply(setOperator, flowchart.SubstituteVariables(stringData.Value));
- }
- else if (t == typeof(AnimatorVariable))
- {
- AnimatorVariable animatorVariable = (variable as AnimatorVariable);
- animatorVariable.Apply(setOperator, animatorData.Value);
- }
- else if (t == typeof(AudioSourceVariable))
- {
- AudioSourceVariable audioSourceVariable = (variable as AudioSourceVariable);
- audioSourceVariable.Apply(setOperator, audioSourceData.Value);
- }
- else if (t == typeof(ColorVariable))
- {
- ColorVariable colorVariable = (variable as ColorVariable);
- colorVariable.Apply(setOperator, colorData.Value);
- }
- else if (t == typeof(GameObjectVariable))
- {
- GameObjectVariable gameObjectVariable = (variable as GameObjectVariable);
- gameObjectVariable.Apply(setOperator, gameObjectData.Value);
- }
- else if (t == typeof(MaterialVariable))
- {
- MaterialVariable materialVariable = (variable as MaterialVariable);
- materialVariable.Apply(setOperator, materialData.Value);
- }
- else if (t == typeof(ObjectVariable))
- {
- ObjectVariable objectVariable = (variable as ObjectVariable);
- objectVariable.Apply(setOperator, objectData.Value);
- }
- else if (t == typeof(Rigidbody2DVariable))
- {
- Rigidbody2DVariable rigidbody2DVariable = (variable as Rigidbody2DVariable);
- rigidbody2DVariable.Apply(setOperator, rigidbody2DData.Value);
- }
- else if (t == typeof(SpriteVariable))
- {
- SpriteVariable spriteVariable = (variable as SpriteVariable);
- spriteVariable.Apply(setOperator, spriteData.Value);
- }
- else if (t == typeof(TextureVariable))
- {
- TextureVariable textureVariable = (variable as TextureVariable);
- textureVariable.Apply(setOperator, textureData.Value);
- }
- else if (t == typeof(TransformVariable))
- {
- TransformVariable transformVariable = (variable as TransformVariable);
- transformVariable.Apply(setOperator, transformData.Value);
- }
- else if (t == typeof(Vector2Variable))
- {
- Vector2Variable vector2Variable = (variable as Vector2Variable);
- vector2Variable.Apply(setOperator, vector2Data.Value);
- }
- else if (t == typeof(Vector3Variable))
- {
- Vector3Variable vector3Variable = (variable as Vector3Variable);
- vector3Variable.Apply(setOperator, vector3Data.Value);
- }
- }
-
- #region Public members
-
- public static readonly Dictionary operatorsByVariableType = new Dictionary() {
- { typeof(BooleanVariable), BooleanVariable.setOperators },
- { typeof(IntegerVariable), IntegerVariable.setOperators },
- { typeof(FloatVariable), FloatVariable.setOperators },
- { typeof(StringVariable), StringVariable.setOperators },
- { typeof(AnimatorVariable), AnimatorVariable.setOperators },
- { typeof(AudioSourceVariable), AudioSourceVariable.setOperators },
- { typeof(ColorVariable), ColorVariable.setOperators },
- { typeof(GameObjectVariable), GameObjectVariable.setOperators },
- { typeof(MaterialVariable), MaterialVariable.setOperators },
- { typeof(ObjectVariable), ObjectVariable.setOperators },
- { typeof(Rigidbody2DVariable), Rigidbody2DVariable.setOperators },
- { typeof(SpriteVariable), SpriteVariable.setOperators },
- { typeof(TextureVariable), TextureVariable.setOperators },
- { typeof(TransformVariable), TransformVariable.setOperators },
- { typeof(Vector2Variable), Vector2Variable.setOperators },
- { typeof(Vector3Variable), Vector3Variable.setOperators }
- };
-
- ///
- /// The type of math operation to be performed.
- ///
- public virtual SetOperator _SetOperator { get { return setOperator; } }
-
- public override void OnEnter()
- {
- DoSetOperation();
-
- Continue();
}
- public override string GetSummary()
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
{
if (variable == null)
{
- return "Error: Variable not selected";
- }
-
- string description = variable.Key;
-
- switch (setOperator)
- {
- default:
- case SetOperator.Assign:
- description += " = ";
- break;
- case SetOperator.Negate:
- description += " =! ";
- break;
- case SetOperator.Add:
- description += " += ";
- break;
- case SetOperator.Subtract:
- description += " -= ";
- break;
- case SetOperator.Multiply:
- description += " *= ";
- break;
- case SetOperator.Divide:
- description += " /= ";
- break;
- }
-
- var t = variable.GetType();
-
- if (t == typeof(BooleanVariable))
- {
- description += booleanData.GetDescription();
- }
- else if (t == typeof(IntegerVariable))
- {
- description += integerData.GetDescription();
- }
- else if (t == typeof(FloatVariable))
- {
- description += floatData.GetDescription();
- }
- else if (t == typeof(StringVariable))
- {
- description += stringData.GetDescription();
- }
- else if (t == typeof(AnimatorVariable))
- {
- description += animatorData.GetDescription();
- }
- else if (t == typeof(AudioSourceVariable))
- {
- description += audioSourceData.GetDescription();
- }
- else if (t == typeof(ColorVariable))
- {
- description += colorData.GetDescription();
- }
- else if (t == typeof(GameObjectVariable))
- {
- description += gameObjectData.GetDescription();
- }
- else if (t == typeof(MaterialVariable))
- {
- description += materialData.GetDescription();
- }
- else if (t == typeof(ObjectVariable))
- {
- description += objectData.GetDescription();
- }
- else if (t == typeof(Rigidbody2DVariable))
- {
- description += rigidbody2DData.GetDescription();
- }
- else if (t == typeof(SpriteVariable))
- {
- description += spriteData.GetDescription();
- }
- else if (t == typeof(TextureVariable))
- {
- description += textureData.GetDescription();
- }
- else if (t == typeof(TransformVariable))
- {
- description += transformData.GetDescription();
- }
- else if (t == typeof(Vector2Variable))
- {
- description += vector2Data.GetDescription();
+ return;
}
- else if (t == typeof(Vector3Variable))
+ else
{
- description += vector3Data.GetDescription();
+ anyVar.variable = variable;
}
- return description;
- }
-
- public override bool HasReference(Variable variable)
- {
- bool retval = (variable == this.variable) || base.HasReference(variable);
-
- var t = variable.GetType();
-
- //this is a nightmare
- if (t == typeof(BooleanVariable))
+ if (variable.GetType() == typeof(BooleanVariable) && !booleanData.Equals(new BooleanData()))
{
- retval |= booleanData.booleanRef == variable;
+ anyVar.data.booleanData = booleanData;
+ booleanData = new BooleanData();
}
- else if (t == typeof(IntegerVariable))
+ else if (variable.GetType() == typeof(IntegerVariable) && !integerData.Equals(new IntegerData()))
{
- retval |= integerData.integerRef == variable;
+ anyVar.data.integerData = integerData;
+ integerData = new IntegerData();
}
- else if (t == typeof(FloatVariable))
+ else if (variable.GetType() == typeof(FloatVariable) && !floatData.Equals(new FloatData()))
{
- retval |= floatData.floatRef == variable;
+ anyVar.data.floatData = floatData;
+ floatData = new FloatData();
}
- else if (t == typeof(StringVariable))
+ else if (variable.GetType() == typeof(StringVariable) && !stringData.Equals(new StringDataMulti()))
{
- retval |= stringData.stringRef == variable;
+ anyVar.data.stringData.stringRef = stringData.stringRef;
+ anyVar.data.stringData.stringVal = stringData.stringVal;
+ stringData = new StringDataMulti();
}
- else if (t == typeof(AnimatorVariable))
+ else if (variable.GetType() == typeof(AnimatorVariable) && !animatorData.Equals(new AnimatorData()))
{
- retval |= animatorData.animatorRef == variable;
+ anyVar.data.animatorData = animatorData;
+ animatorData = new AnimatorData();
}
- else if (t == typeof(AudioSourceVariable))
+ else if (variable.GetType() == typeof(AudioSourceVariable) && !audioSourceData.Equals(new AudioSourceData()))
{
- retval |= audioSourceData.audioSourceRef == variable;
+ anyVar.data.audioSourceData = audioSourceData;
+ audioSourceData = new AudioSourceData();
}
- else if (t == typeof(ColorVariable))
+ else if (variable.GetType() == typeof(ColorVariable) && !colorData.Equals(new ColorData()))
{
- retval |= colorData.colorRef == variable;
+ anyVar.data.colorData = colorData;
+ colorData = new ColorData();
}
- else if (t == typeof(GameObjectVariable))
+ else if (variable.GetType() == typeof(GameObjectVariable) && !gameObjectData.Equals(new GameObjectData()))
{
- retval |= gameObjectData.gameObjectRef == variable;
+ anyVar.data.gameObjectData = gameObjectData;
+ gameObjectData = new GameObjectData();
}
- else if (t == typeof(MaterialVariable))
+ else if (variable.GetType() == typeof(MaterialVariable) && !materialData.Equals(new MaterialData()))
{
- retval |= materialData.materialRef == variable;
+ anyVar.data.materialData = materialData;
+ materialData = new MaterialData();
}
- else if (t == typeof(ObjectVariable))
+ else if (variable.GetType() == typeof(ObjectVariable) && !objectData.Equals(new ObjectData()))
{
- retval |= objectData.objectRef == variable;
+ anyVar.data.objectData = objectData;
+ objectData = new ObjectData();
}
- else if (t == typeof(Rigidbody2DVariable))
+ else if (variable.GetType() == typeof(Rigidbody2DVariable) && !rigidbody2DData.Equals(new Rigidbody2DData()))
{
- retval |= rigidbody2DData.rigidbody2DRef == variable;
+ anyVar.data.rigidbody2DData = rigidbody2DData;
+ rigidbody2DData = new Rigidbody2DData();
}
- else if (t == typeof(SpriteVariable))
+ else if (variable.GetType() == typeof(SpriteVariable) && !spriteData.Equals(new SpriteData()))
{
- retval |= spriteData.spriteRef == variable;
+ anyVar.data.spriteData = spriteData;
+ spriteData = new SpriteData();
}
- else if (t == typeof(TextureVariable))
+ else if (variable.GetType() == typeof(TextureVariable) && !textureData.Equals(new TextureData()))
{
- retval |= textureData.textureRef == variable;
+ anyVar.data.textureData = textureData;
+ textureData = new TextureData();
}
- else if (t == typeof(TransformVariable))
+ else if (variable.GetType() == typeof(TransformVariable) && !transformData.Equals(new TransformData()))
{
- retval |= transformData.transformRef == variable;
+ anyVar.data.transformData = transformData;
+ transformData = new TransformData();
}
- else if (t == typeof(Vector2Variable))
+ else if (variable.GetType() == typeof(Vector2Variable) && !vector2Data.Equals(new Vector2Data()))
{
- retval |= vector2Data.vector2Ref == variable;
+ anyVar.data.vector2Data = vector2Data;
+ vector2Data = new Vector2Data();
}
- else if (t == typeof(Vector3Variable))
+ else if (variable.GetType() == typeof(Vector3Variable) && !vector3Data.Equals(new Vector3Data()))
{
- retval |= vector3Data.vector3Ref == variable;
+ anyVar.data.vector3Data = vector3Data;
+ vector3Data = new Vector3Data();
}
- return retval;
- }
-
- public override Color GetButtonColor()
- {
- return new Color32(253, 253, 150, 255);
+ //now converted to new AnyVar storage, remove the legacy.
+ variable = null;
}
-
#endregion
-
- #region Editor caches
-#if UNITY_EDITOR
- protected override void RefreshVariableCache()
- {
- base.RefreshVariableCache();
-
- var f = GetFlowchart();
-
- f.DetermineSubstituteVariables(stringData.Value, referencedVariables);
- }
-#endif
- #endregion Editor caches
}
}
diff --git a/Assets/Fungus/Scripts/Commands/ShakeCamera.cs b/Assets/Fungus/Scripts/Commands/ShakeCamera.cs
index e64249a9..aca845b2 100644
--- a/Assets/Fungus/Scripts/Commands/ShakeCamera.cs
+++ b/Assets/Fungus/Scripts/Commands/ShakeCamera.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ShakePosition.cs b/Assets/Fungus/Scripts/Commands/ShakePosition.cs
index 2388a0b2..86a1c480 100644
--- a/Assets/Fungus/Scripts/Commands/ShakePosition.cs
+++ b/Assets/Fungus/Scripts/Commands/ShakePosition.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs
index ab30c1d8..a5982cd3 100644
--- a/Assets/Fungus/Scripts/Commands/ShakeRotation.cs
+++ b/Assets/Fungus/Scripts/Commands/ShakeRotation.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ShakeScale.cs b/Assets/Fungus/Scripts/Commands/ShakeScale.cs
index c2c0ffca..5bb96b8a 100644
--- a/Assets/Fungus/Scripts/Commands/ShakeScale.cs
+++ b/Assets/Fungus/Scripts/Commands/ShakeScale.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Scripts/Commands/ShowSprite.cs
index ea454a50..ce4b032c 100644
--- a/Assets/Fungus/Scripts/Commands/ShowSprite.cs
+++ b/Assets/Fungus/Scripts/Commands/ShowSprite.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/SpawnObject.cs b/Assets/Fungus/Scripts/Commands/SpawnObject.cs
index 34954d52..7bff6e20 100644
--- a/Assets/Fungus/Scripts/Commands/SpawnObject.cs
+++ b/Assets/Fungus/Scripts/Commands/SpawnObject.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StartSwipe.cs b/Assets/Fungus/Scripts/Commands/StartSwipe.cs
index d20b52f3..23281cf0 100644
--- a/Assets/Fungus/Scripts/Commands/StartSwipe.cs
+++ b/Assets/Fungus/Scripts/Commands/StartSwipe.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Stop.cs b/Assets/Fungus/Scripts/Commands/Stop.cs
index 3dc485b9..02b6cb1f 100644
--- a/Assets/Fungus/Scripts/Commands/Stop.cs
+++ b/Assets/Fungus/Scripts/Commands/Stop.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StopAmbiance.cs b/Assets/Fungus/Scripts/Commands/StopAmbiance.cs
index b3130c06..8aaa4a27 100644
--- a/Assets/Fungus/Scripts/Commands/StopAmbiance.cs
+++ b/Assets/Fungus/Scripts/Commands/StopAmbiance.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StopBlock.cs b/Assets/Fungus/Scripts/Commands/StopBlock.cs
index e226fc8f..7cb31a4c 100644
--- a/Assets/Fungus/Scripts/Commands/StopBlock.cs
+++ b/Assets/Fungus/Scripts/Commands/StopBlock.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StopFlowchart.cs b/Assets/Fungus/Scripts/Commands/StopFlowchart.cs
index d439796f..d28b71ca 100644
--- a/Assets/Fungus/Scripts/Commands/StopFlowchart.cs
+++ b/Assets/Fungus/Scripts/Commands/StopFlowchart.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StopMusic.cs b/Assets/Fungus/Scripts/Commands/StopMusic.cs
index 548fd091..fea8a836 100644
--- a/Assets/Fungus/Scripts/Commands/StopMusic.cs
+++ b/Assets/Fungus/Scripts/Commands/StopMusic.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StopSwipe.cs b/Assets/Fungus/Scripts/Commands/StopSwipe.cs
index 534dcf5b..02012445 100644
--- a/Assets/Fungus/Scripts/Commands/StopSwipe.cs
+++ b/Assets/Fungus/Scripts/Commands/StopSwipe.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StopTween.cs b/Assets/Fungus/Scripts/Commands/StopTween.cs
index f1cd8d11..431c2fd7 100644
--- a/Assets/Fungus/Scripts/Commands/StopTween.cs
+++ b/Assets/Fungus/Scripts/Commands/StopTween.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/StopTweens.cs b/Assets/Fungus/Scripts/Commands/StopTweens.cs
index 3e2bfb17..4615ddcd 100644
--- a/Assets/Fungus/Scripts/Commands/StopTweens.cs
+++ b/Assets/Fungus/Scripts/Commands/StopTweens.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/ThrowException.cs b/Assets/Fungus/Scripts/Commands/ThrowException.cs
new file mode 100644
index 00000000..6d78b8e1
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/ThrowException.cs
@@ -0,0 +1,59 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ [System.Serializable]
+ public class FungusException : System.Exception
+ {
+ public FungusException()
+ {
+ }
+
+ public FungusException(string message) : base(message)
+ {
+ }
+
+ public FungusException(string message, System.Exception inner) : base(message, inner)
+ {
+ }
+
+ protected FungusException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
+ }
+
+ ///
+ /// Throw a Fungus.Exception
+ ///
+ [CommandInfo("Scripting",
+ "Throw Exception",
+ "Throw a fungus exception")]
+ [AddComponentMenu("")]
+ public class ThrowException : Command
+ {
+ [SerializeField]
+ protected StringData message;
+
+ public override void OnEnter()
+ {
+ throw new FungusException(GetLocationIdentifier() + " " + message.Value);
+
+#pragma warning disable CS0162 // Unreachable code detected
+ Continue();
+#pragma warning restore CS0162 // Unreachable code detected
+ }
+
+ public override string GetSummary()
+ {
+ return message.Value;
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return variable == message.stringRef || base.HasReference(variable);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/ThrowException.cs.meta b/Assets/Fungus/Scripts/Commands/ThrowException.cs.meta
new file mode 100644
index 00000000..4fc1e5af
--- /dev/null
+++ b/Assets/Fungus/Scripts/Commands/ThrowException.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8d1a861c2b31cf8488fd9d576d533474
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Commands/ToString.cs b/Assets/Fungus/Scripts/Commands/ToString.cs
index 653a4e7a..60e6dfa8 100644
--- a/Assets/Fungus/Scripts/Commands/ToString.cs
+++ b/Assets/Fungus/Scripts/Commands/ToString.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/TweenUI.cs b/Assets/Fungus/Scripts/Commands/TweenUI.cs
index 1a7e62f0..401f5235 100644
--- a/Assets/Fungus/Scripts/Commands/TweenUI.cs
+++ b/Assets/Fungus/Scripts/Commands/TweenUI.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/VariableCondition.cs b/Assets/Fungus/Scripts/Commands/VariableCondition.cs
index a1ab567a..bf0f64f2 100644
--- a/Assets/Fungus/Scripts/Commands/VariableCondition.cs
+++ b/Assets/Fungus/Scripts/Commands/VariableCondition.cs
@@ -1,33 +1,159 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// 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;
+using System.Text;
+using UnityEngine;
namespace Fungus
{
- public abstract class VariableCondition : Condition
+ ///
+ /// class for a single condition. A list of this is used for multiple conditions.
+ ///
+ [System.Serializable]
+ public class ConditionExpression
{
- [Tooltip("The type of comparison to be performed")]
[SerializeField] protected CompareOperator compareOperator;
+ [SerializeField] protected AnyVariableAndDataPair anyVar;
+
+ public virtual AnyVariableAndDataPair AnyVar { get { return anyVar; } }
+ public virtual CompareOperator CompareOperator { get { return compareOperator; } }
+
+ public ConditionExpression()
+ {
+ }
+
+ public ConditionExpression(CompareOperator op, AnyVariableAndDataPair variablePair)
+ {
+ compareOperator = op;
+ anyVar = variablePair;
+ }
+ }
+
+ public abstract class VariableCondition : Condition, ISerializationCallbackReceiver
+ {
+ public enum AnyOrAll
+ {
+ AnyOf_OR,//Use as a chain of ORs
+ AllOf_AND,//Use as a chain of ANDs
+ }
+
+ [Tooltip("Selecting AnyOf will result in true if at least one of the conditions is true. Selecting AllOF will result in true only when all the conditions are true.")]
+ [SerializeField] protected AnyOrAll anyOrAllConditions;
+
+ [SerializeField] protected List conditions = new List();
+
+ ///
+ /// Called when the script is loaded or a value is changed in the
+ /// inspector (Called in the editor only).
+ ///
+ public override void OnValidate()
+ {
+ base.OnValidate();
+
+ if (conditions == null)
+ {
+ conditions = new List();
+ }
+
+ if (conditions.Count == 0)
+ {
+ conditions.Add(new ConditionExpression());
+ }
+ }
+
+ protected override bool EvaluateCondition()
+ {
+ if (conditions == null || conditions.Count == 0)
+ {
+ return false;
+ }
+
+ bool resultAny = false, resultAll = true;
+ foreach (ConditionExpression condition in conditions)
+ {
+ bool curResult = false;
+ if (condition.AnyVar == null)
+ {
+ resultAll &= curResult;
+ resultAny |= curResult;
+ continue;
+ }
+ condition.AnyVar.Compare(condition.CompareOperator, ref curResult);
+ resultAll &= curResult;
+ resultAny |= curResult;
+ }
+
+ if (anyOrAllConditions == AnyOrAll.AnyOf_OR) return resultAny;
+
+ return resultAll;
+ }
+
+ protected override bool HasNeededProperties()
+ {
+ if (conditions == null || conditions.Count == 0)
+ {
+ return false;
+ }
+
+ foreach (ConditionExpression condition in conditions)
+ {
+ if (condition.AnyVar == null || condition.AnyVar.variable == null)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public override string GetSummary()
+ {
+ if (!this.HasNeededProperties())
+ {
+ return "Error: No variable selected";
+ }
+
+ string connector = "";
+ if (anyOrAllConditions == AnyOrAll.AnyOf_OR)
+ {
+ connector = " OR ";
+ }
+ else
+ {
+ connector = " AND ";
+ }
+
+ StringBuilder summary = new StringBuilder("");
+ for (int i = 0; i < conditions.Count; i++)
+ {
+ summary.Append(conditions[i].AnyVar.variable.Key + " " +
+ VariableUtil.GetCompareOperatorDescription(conditions[i].CompareOperator) + " " +
+ conditions[i].AnyVar.GetDataDescription());
+
+ if (i < conditions.Count - 1)
+ {
+ summary.Append(connector);
+ }
+ }
+ return summary.ToString();
+ }
+
+ public override bool HasReference(Variable variable)
+ {
+ return anyVar.HasReference(variable);
+ }
+
+
+ #region backwards compat
+
+ [HideInInspector]
+ [SerializeField] protected CompareOperator compareOperator;
+
+ [HideInInspector]
+ [SerializeField] protected AnyVariableAndDataPair anyVar;
[Tooltip("Variable to use in expression")]
- [VariableProperty(typeof(BooleanVariable),
- typeof(IntegerVariable),
- typeof(FloatVariable),
- typeof(StringVariable),
- typeof(AnimatorVariable),
- typeof(AudioSourceVariable),
- typeof(ColorVariable),
- typeof(GameObjectVariable),
- typeof(MaterialVariable),
- typeof(ObjectVariable),
- typeof(Rigidbody2DVariable),
- typeof(SpriteVariable),
- typeof(TextureVariable),
- typeof(TransformVariable),
- typeof(Vector2Variable),
- typeof(Vector3Variable))]
+ [VariableProperty(AllVariableTypes.VariableAny.Any)]
[SerializeField] protected Variable variable;
[Tooltip("Boolean value to compare against")]
@@ -78,292 +204,117 @@ namespace Fungus
[Tooltip("Vector3 value to compare against")]
[SerializeField] protected Vector3Data vector3Data;
- protected override bool EvaluateCondition()
- {
- if (variable == null)
- {
- return false;
- }
-
- bool condition = false;
-
- var t = variable.GetType();
-
- if (t == typeof(BooleanVariable))
- {
- BooleanVariable booleanVariable = (variable as BooleanVariable);
- condition = booleanVariable.Evaluate(compareOperator, booleanData.Value);
- }
- else if (t == typeof(IntegerVariable))
- {
- IntegerVariable integerVariable = (variable as IntegerVariable);
- condition = integerVariable.Evaluate(compareOperator, integerData.Value);
- }
- else if (t == typeof(FloatVariable))
- {
- FloatVariable floatVariable = (variable as FloatVariable);
- condition = floatVariable.Evaluate(compareOperator, floatData.Value);
- }
- else if (t == typeof(StringVariable))
- {
- StringVariable stringVariable = (variable as StringVariable);
- condition = stringVariable.Evaluate(compareOperator, stringData.Value);
- }
- else if (t == typeof(AnimatorVariable))
- {
- AnimatorVariable animatorVariable = (variable as AnimatorVariable);
- condition = animatorVariable.Evaluate(compareOperator, animatorData.Value);
- }
- else if (t == typeof(AudioSourceVariable))
- {
- AudioSourceVariable audioSourceVariable = (variable as AudioSourceVariable);
- condition = audioSourceVariable.Evaluate(compareOperator, audioSourceData.Value);
- }
- else if (t == typeof(ColorVariable))
- {
- ColorVariable colorVariable = (variable as ColorVariable);
- condition = colorVariable.Evaluate(compareOperator, colorData.Value);
- }
- else if (t == typeof(GameObjectVariable))
- {
- GameObjectVariable gameObjectVariable = (variable as GameObjectVariable);
- condition = gameObjectVariable.Evaluate(compareOperator, gameObjectData.Value);
- }
- else if (t == typeof(MaterialVariable))
- {
- MaterialVariable materialVariable = (variable as MaterialVariable);
- condition = materialVariable.Evaluate(compareOperator, materialData.Value);
- }
- else if (t == typeof(ObjectVariable))
- {
- ObjectVariable objectVariable = (variable as ObjectVariable);
- condition = objectVariable.Evaluate(compareOperator, objectData.Value);
- }
- else if (t == typeof(Rigidbody2DVariable))
- {
- Rigidbody2DVariable rigidbody2DVariable = (variable as Rigidbody2DVariable);
- condition = rigidbody2DVariable.Evaluate(compareOperator, rigidbody2DData.Value);
- }
- else if (t == typeof(SpriteVariable))
- {
- SpriteVariable spriteVariable = (variable as SpriteVariable);
- condition = spriteVariable.Evaluate(compareOperator, spriteData.Value);
- }
- else if (t == typeof(TextureVariable))
- {
- TextureVariable textureVariable = (variable as TextureVariable);
- condition = textureVariable.Evaluate(compareOperator, textureData.Value);
- }
- else if (t == typeof(TransformVariable))
- {
- TransformVariable transformVariable = (variable as TransformVariable);
- condition = transformVariable.Evaluate(compareOperator, transformData.Value);
- }
- else if (t == typeof(Vector2Variable))
- {
- Vector2Variable vector2Variable = (variable as Vector2Variable);
- condition = vector2Variable.Evaluate(compareOperator, vector2Data.Value);
- }
- else if (t == typeof(Vector3Variable))
- {
- Vector3Variable vector3Variable = (variable as Vector3Variable);
- condition = vector3Variable.Evaluate(compareOperator, vector3Data.Value);
- }
-
- return condition;
- }
-
- protected override bool HasNeededProperties()
+ void ISerializationCallbackReceiver.OnBeforeSerialize()
{
- return (variable != null);
}
- #region Public members
-
- public static readonly Dictionary operatorsByVariableType = new Dictionary() {
- { typeof(BooleanVariable), BooleanVariable.compareOperators },
- { typeof(IntegerVariable), IntegerVariable.compareOperators },
- { typeof(FloatVariable), FloatVariable.compareOperators },
- { typeof(StringVariable), StringVariable.compareOperators },
- { typeof(AnimatorVariable), AnimatorVariable.compareOperators },
- { typeof(AudioSourceVariable), AudioSourceVariable.compareOperators },
- { typeof(ColorVariable), ColorVariable.compareOperators },
- { typeof(GameObjectVariable), GameObjectVariable.compareOperators },
- { typeof(MaterialVariable), MaterialVariable.compareOperators },
- { typeof(ObjectVariable), ObjectVariable.compareOperators },
- { typeof(Rigidbody2DVariable), Rigidbody2DVariable.compareOperators },
- { typeof(SpriteVariable), SpriteVariable.compareOperators },
- { typeof(TextureVariable), TextureVariable.compareOperators },
- { typeof(TransformVariable), TransformVariable.compareOperators },
- { typeof(Vector2Variable), Vector2Variable.compareOperators },
- { typeof(Vector3Variable), Vector3Variable.compareOperators }
- };
-
- ///
- /// The type of comparison operation to be performed.
- ///
- public virtual CompareOperator _CompareOperator { get { return compareOperator; } }
-
- public override string GetSummary()
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
{
- if (variable == null)
- {
- return "Error: No variable selected";
+ if (variable != null)
+ {
+ anyVar.variable = variable;
+
+ if (variable.GetType() == typeof(BooleanVariable) && !booleanData.Equals(new BooleanData()))
+ {
+ anyVar.data.booleanData = booleanData;
+ booleanData = new BooleanData();
+ }
+ else if (variable.GetType() == typeof(IntegerVariable) && !integerData.Equals(new IntegerData()))
+ {
+ anyVar.data.integerData = integerData;
+ integerData = new IntegerData();
+ }
+ else if (variable.GetType() == typeof(FloatVariable) && !floatData.Equals(new FloatData()))
+ {
+ anyVar.data.floatData = floatData;
+ floatData = new FloatData();
+ }
+ else if (variable.GetType() == typeof(StringVariable) && !stringData.Equals(new StringDataMulti()))
+ {
+ anyVar.data.stringData.stringRef = stringData.stringRef;
+ anyVar.data.stringData.stringVal = stringData.stringVal;
+ stringData = new StringDataMulti();
+ }
+ else if (variable.GetType() == typeof(AnimatorVariable) && !animatorData.Equals(new AnimatorData()))
+ {
+ anyVar.data.animatorData = animatorData;
+ animatorData = new AnimatorData();
+ }
+ else if (variable.GetType() == typeof(AudioSourceVariable) && !audioSourceData.Equals(new AudioSourceData()))
+ {
+ anyVar.data.audioSourceData = audioSourceData;
+ audioSourceData = new AudioSourceData();
+ }
+ else if (variable.GetType() == typeof(ColorVariable) && !colorData.Equals(new ColorData()))
+ {
+ anyVar.data.colorData = colorData;
+ colorData = new ColorData();
+ }
+ else if (variable.GetType() == typeof(GameObjectVariable) && !gameObjectData.Equals(new GameObjectData()))
+ {
+ anyVar.data.gameObjectData = gameObjectData;
+ gameObjectData = new GameObjectData();
+ }
+ else if (variable.GetType() == typeof(MaterialVariable) && !materialData.Equals(new MaterialData()))
+ {
+ anyVar.data.materialData = materialData;
+ materialData = new MaterialData();
+ }
+ else if (variable.GetType() == typeof(ObjectVariable) && !objectData.Equals(new ObjectData()))
+ {
+ anyVar.data.objectData = objectData;
+ objectData = new ObjectData();
+ }
+ else if (variable.GetType() == typeof(Rigidbody2DVariable) && !rigidbody2DData.Equals(new Rigidbody2DData()))
+ {
+ anyVar.data.rigidbody2DData = rigidbody2DData;
+ rigidbody2DData = new Rigidbody2DData();
+ }
+ else if (variable.GetType() == typeof(SpriteVariable) && !spriteData.Equals(new SpriteData()))
+ {
+ anyVar.data.spriteData = spriteData;
+ spriteData = new SpriteData();
+ }
+ else if (variable.GetType() == typeof(TextureVariable) && !textureData.Equals(new TextureData()))
+ {
+ anyVar.data.textureData = textureData;
+ textureData = new TextureData();
+ }
+ else if (variable.GetType() == typeof(TransformVariable) && !transformData.Equals(new TransformData()))
+ {
+ anyVar.data.transformData = transformData;
+ transformData = new TransformData();
+ }
+ else if (variable.GetType() == typeof(Vector2Variable) && !vector2Data.Equals(new Vector2Data()))
+ {
+ anyVar.data.vector2Data = vector2Data;
+ vector2Data = new Vector2Data();
+ }
+ else if (variable.GetType() == typeof(Vector3Variable) && !vector3Data.Equals(new Vector3Data()))
+ {
+ anyVar.data.vector3Data = vector3Data;
+ vector3Data = new Vector3Data();
+ }
+
+ //moved to new anyvar storage, clear legacy.
+ variable = null;
+ }
+
+ // just checking for anyVar != null fails here. is any var being reintilaized somewhere?
+
+ if (anyVar != null && anyVar.variable != null)
+ {
+ ConditionExpression c = new ConditionExpression(compareOperator, anyVar);
+ if (!conditions.Contains(c))
+ {
+ conditions.Add(c);
+ }
+
+ anyVar = null;
+ variable = null;
}
-
- var t = variable.GetType();
-
- string summary = variable.Key + " ";
- summary += Condition.GetOperatorDescription(compareOperator) + " ";
-
- if (t == typeof(BooleanVariable))
- {
- summary += booleanData.GetDescription();
- }
- else if (t == typeof(IntegerVariable))
- {
- summary += integerData.GetDescription();
- }
- else if (t == typeof(FloatVariable))
- {
- summary += floatData.GetDescription();
- }
- else if (t == typeof(StringVariable))
- {
- summary += stringData.GetDescription();
- }
- else if (t == typeof(AnimatorVariable))
- {
- summary += animatorData.GetDescription();
- }
- else if (t == typeof(AudioSourceVariable))
- {
- summary += audioSourceData.GetDescription();
- }
- else if (t == typeof(ColorVariable))
- {
- summary += colorData.GetDescription();
- }
- else if (t == typeof(GameObjectVariable))
- {
- summary += gameObjectData.GetDescription();
- }
- else if (t == typeof(MaterialVariable))
- {
- summary += materialData.GetDescription();
- }
- else if (t == typeof(ObjectVariable))
- {
- summary += objectData.GetDescription();
- }
- else if (t == typeof(Rigidbody2DVariable))
- {
- summary += rigidbody2DData.GetDescription();
- }
- else if (t == typeof(SpriteVariable))
- {
- summary += spriteData.GetDescription();
- }
- else if (t == typeof(TextureVariable))
- {
- summary += textureData.GetDescription();
- }
- else if (t == typeof(TransformVariable))
- {
- summary += transformData.GetDescription();
- }
- else if (t == typeof(Vector2Variable))
- {
- summary += vector2Data.GetDescription();
- }
- else if (t == typeof(Vector3Variable))
- {
- summary += vector3Data.GetDescription();
- }
-
- return summary;
- }
-
- public override bool HasReference(Variable variable)
- {
- bool retval = (variable == this.variable) || base.HasReference(variable);
-
- var t = variable.GetType();
-
- //this is a nightmare
- if (t == typeof(BooleanVariable))
- {
- retval |= booleanData.booleanRef == variable;
- }
- else if (t == typeof(IntegerVariable))
- {
- retval |= integerData.integerRef == variable;
- }
- else if (t == typeof(FloatVariable))
- {
- retval |= floatData.floatRef == variable;
- }
- else if (t == typeof(StringVariable))
- {
- retval |= stringData.stringRef == variable;
- }
- else if (t == typeof(AnimatorVariable))
- {
- retval |= animatorData.animatorRef == variable;
- }
- else if (t == typeof(AudioSourceVariable))
- {
- retval |= audioSourceData.audioSourceRef == variable;
- }
- else if (t == typeof(ColorVariable))
- {
- retval |= colorData.colorRef == variable;
- }
- else if (t == typeof(GameObjectVariable))
- {
- retval |= gameObjectData.gameObjectRef == variable;
- }
- else if (t == typeof(MaterialVariable))
- {
- retval |= materialData.materialRef == variable;
- }
- else if (t == typeof(ObjectVariable))
- {
- retval |= objectData.objectRef == variable;
- }
- else if (t == typeof(Rigidbody2DVariable))
- {
- retval |= rigidbody2DData.rigidbody2DRef == variable;
- }
- else if (t == typeof(SpriteVariable))
- {
- retval |= spriteData.spriteRef == variable;
- }
- else if (t == typeof(TextureVariable))
- {
- retval |= textureData.textureRef == variable;
- }
- else if (t == typeof(TransformVariable))
- {
- retval |= transformData.transformRef == variable;
- }
- else if (t == typeof(Vector2Variable))
- {
- retval |= vector2Data.vector2Ref == variable;
- }
- else if (t == typeof(Vector3Variable))
- {
- retval |= vector3Data.vector3Ref == variable;
- }
-
- return retval;
- }
-
- public override Color GetButtonColor()
- {
- return new Color32(253, 253, 150, 255);
}
- #endregion
+ #endregion backwards compat
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Commands/Vector3/Vector3Arithmetic.cs b/Assets/Fungus/Scripts/Commands/Vector3/Vector3Arithmetic.cs
index fe53a530..748002b4 100644
--- a/Assets/Fungus/Scripts/Commands/Vector3/Vector3Arithmetic.cs
+++ b/Assets/Fungus/Scripts/Commands/Vector3/Vector3Arithmetic.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Vector3/Vector3Fields.cs b/Assets/Fungus/Scripts/Commands/Vector3/Vector3Fields.cs
index baafe67f..31db3c9d 100644
--- a/Assets/Fungus/Scripts/Commands/Vector3/Vector3Fields.cs
+++ b/Assets/Fungus/Scripts/Commands/Vector3/Vector3Fields.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Vector3/Vector3Normalise.cs b/Assets/Fungus/Scripts/Commands/Vector3/Vector3Normalise.cs
index f4323e49..344c3ccd 100644
--- a/Assets/Fungus/Scripts/Commands/Vector3/Vector3Normalise.cs
+++ b/Assets/Fungus/Scripts/Commands/Vector3/Vector3Normalise.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Vector3/Vector3ToVector2.cs b/Assets/Fungus/Scripts/Commands/Vector3/Vector3ToVector2.cs
index 9f08b761..e29a7698 100644
--- a/Assets/Fungus/Scripts/Commands/Vector3/Vector3ToVector2.cs
+++ b/Assets/Fungus/Scripts/Commands/Vector3/Vector3ToVector2.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/Wait.cs b/Assets/Fungus/Scripts/Commands/Wait.cs
index 5c506688..a1d15539 100644
--- a/Assets/Fungus/Scripts/Commands/Wait.cs
+++ b/Assets/Fungus/Scripts/Commands/Wait.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/WaitFrames.cs b/Assets/Fungus/Scripts/Commands/WaitFrames.cs
index 5d041945..2a01089b 100644
--- a/Assets/Fungus/Scripts/Commands/WaitFrames.cs
+++ b/Assets/Fungus/Scripts/Commands/WaitFrames.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/While.cs b/Assets/Fungus/Scripts/Commands/While.cs
index 9e4f696c..6f9c6130 100644
--- a/Assets/Fungus/Scripts/Commands/While.cs
+++ b/Assets/Fungus/Scripts/Commands/While.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -16,50 +16,7 @@ namespace Fungus
{
#region Public members
- public override void OnEnter()
- {
- bool execute = true;
- if (variable != null)
- {
- execute = EvaluateCondition();
- }
-
- // Find next End statement at same indent level
- End endCommand = null;
- for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
- {
- End command = ParentBlock.CommandList[i] as End;
-
- if (command != null &&
- command.IndentLevel == indentLevel)
- {
- endCommand = command;
- break;
- }
- }
-
- if (execute)
- {
- // Tell the following end command to loop back
- endCommand.Loop = true;
- Continue();
- }
- else
- {
- // Continue at next command after End
- Continue (endCommand.CommandIndex + 1);
- }
- }
-
- public override bool OpenBlock()
- {
- return true;
- }
-
- public override Color GetButtonColor()
- {
- return new Color32(253, 253, 150, 255);
- }
+ public override bool IsLooping { get { return true; } }
#endregion
}
diff --git a/Assets/Fungus/Scripts/Commands/Write.cs b/Assets/Fungus/Scripts/Commands/Write.cs
index 34ff445e..afd483fe 100644
--- a/Assets/Fungus/Scripts/Commands/Write.cs
+++ b/Assets/Fungus/Scripts/Commands/Write.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs
index b118b303..00b34afe 100644
--- a/Assets/Fungus/Scripts/Commands/iTweenCommand.cs
+++ b/Assets/Fungus/Scripts/Commands/iTweenCommand.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Block.cs b/Assets/Fungus/Scripts/Components/Block.cs
index 2156f2fc..f727cf09 100644
--- a/Assets/Fungus/Scripts/Components/Block.cs
+++ b/Assets/Fungus/Scripts/Components/Block.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -55,6 +55,8 @@ namespace Fungus
///
protected int previousActiveCommandIndex = -1;
+ public int PreviousActiveCommandIndex { get { return previousActiveCommandIndex; } }
+
protected int jumpToCommandIndex = -1;
protected int executionCount;
@@ -124,7 +126,8 @@ namespace Fungus
#endif
//editor only state for speeding up flowchart window drawing
public bool IsSelected { get; set; } //local cache of selectedness
- public bool IsFiltered { get; set; } //local cache of filteredness
+ public enum FilteredState { Full, Partial, None}
+ public FilteredState FilterState { get; set; } //local cache of filteredness
public bool IsControlSelected { get; set; } //local cache of being part of the control exclusion group
#region Public members
@@ -373,6 +376,12 @@ namespace Fungus
public virtual List GetConnectedBlocks()
{
var connectedBlocks = new List();
+ GetConnectedBlocks(ref connectedBlocks);
+ return connectedBlocks;
+ }
+
+ public virtual void GetConnectedBlocks(ref List connectedBlocks)
+ {
for (int i = 0; i < commandList.Count; i++)
{
var command = commandList[i];
@@ -381,7 +390,6 @@ namespace Fungus
command.GetConnectedBlocks(ref connectedBlocks);
}
}
- return connectedBlocks;
}
///
@@ -410,6 +418,17 @@ namespace Fungus
return -1;
}
+ public virtual Command GetPreviousActiveCommand()
+ {
+ if (previousActiveCommandIndex >= 0 &&
+ previousActiveCommandIndex < commandList.Count)
+ {
+ return commandList[previousActiveCommandIndex];
+ }
+
+ return null;
+ }
+
///
/// Recalculate the indent levels for all commands in the list.
///
diff --git a/Assets/Fungus/Scripts/Components/CameraManager.cs b/Assets/Fungus/Scripts/Components/CameraManager.cs
index 0d51528e..30467e64 100644
--- a/Assets/Fungus/Scripts/Components/CameraManager.cs
+++ b/Assets/Fungus/Scripts/Components/CameraManager.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -43,8 +43,7 @@ namespace Fungus
protected Vector3 previousMousePos;
//Coroutine handles for panning and fading commands
- protected IEnumerator panCoroutine;
- protected IEnumerator fadeCoroutine;
+ protected LTDescr fadeTween, sizeTween, camPosTween, camRotTween;
protected class CameraView
{
@@ -89,122 +88,6 @@ namespace Fungus
}
}
- protected virtual IEnumerator FadeInternal(float targetAlpha, float fadeDuration, Action fadeAction)
- {
- float startAlpha = fadeAlpha;
- float timer = 0;
-
- // If already at the target alpha then complete immediately
- if (Mathf.Approximately(startAlpha, targetAlpha))
- {
- yield return null;
- }
- else
- {
- while (timer < fadeDuration)
- {
- float t = timer / fadeDuration;
- timer += Time.deltaTime;
-
- t = Mathf.Clamp01(t);
-
- fadeAlpha = Mathf.Lerp(startAlpha, targetAlpha, t);
- yield return null;
- }
- }
-
- fadeAlpha = targetAlpha;
-
- if (fadeAction != null)
- {
- fadeAction();
- }
- }
-
- protected virtual IEnumerator PanInternal(Camera camera, Vector3 targetPos, Quaternion targetRot, float targetSize, float duration, Action arriveAction)
- {
- if (camera == null)
- {
- Debug.LogWarning("Camera is null");
- yield break;
- }
-
- float timer = 0;
- float startSize = camera.orthographicSize;
- float endSize = targetSize;
- Vector3 startPos = camera.transform.position;
- Vector3 endPos = targetPos;
- Quaternion startRot = camera.transform.rotation;
- Quaternion endRot = targetRot;
-
- bool arrived = false;
- while (!arrived)
- {
- timer += Time.deltaTime;
- if (timer > duration)
- {
- arrived = true;
- timer = duration;
- }
-
- // Apply smoothed lerp to camera position and orthographic size
- float t = 1f;
- if (duration > 0f)
- {
- t = timer / duration;
- }
-
- if (camera != null)
- {
- camera.orthographicSize = Mathf.Lerp(startSize, endSize, Mathf.SmoothStep(0f, 1f, t));
- camera.transform.position = Vector3.Lerp(startPos, endPos, Mathf.SmoothStep(0f, 1f, t));
- camera.transform.rotation = Quaternion.Lerp(startRot, endRot, Mathf.SmoothStep(0f, 1f, t));
-
- SetCameraZ(camera);
- }
-
- if (arrived &&
- arriveAction != null)
- {
- arriveAction();
- }
-
- yield return null;
- }
- }
-
- protected virtual IEnumerator PanToPathInternal(Camera camera, float duration, Action arriveAction, Vector3[] path)
- {
- if (camera == null)
- {
- Debug.LogWarning("Camera is null");
- yield break;
- }
-
- float timer = 0;
-
- while (timer < duration)
- {
- timer += Time.deltaTime;
- timer = Mathf.Min(timer, duration);
- float percent = timer / duration;
-
- Vector3 point = iTween.PointOnPath(path, percent);
-
- camera.transform.position = new Vector3(point.x, point.y, 0);
- camera.orthographicSize = point.z;
-
- SetCameraZ(camera);
-
- yield return null;
- }
-
- if (arriveAction != null)
- {
- arriveAction();
- }
- }
-
protected virtual void SetCameraZ(Camera camera)
{
if (!setCameraZ)
@@ -303,41 +186,7 @@ namespace Fungus
}
#region Public members
-
- ///
- /// Moves camera smoothly through a sequence of Views over a period of time.
- ///
- public virtual void PanToPath(Camera camera, View[] viewList, float duration, Action arriveAction)
- {
- if (camera == null)
- {
- Debug.LogWarning("Camera is null");
- return;
- }
-
- swipePanActive = false;
-
- List pathList = new List();
-
- // Add current camera position as first point in path
- // Note: We use the z coord to tween the camera orthographic size
- Vector3 startPos = new Vector3(camera.transform.position.x,
- camera.transform.position.y,
- camera.orthographicSize);
- pathList.Add(startPos);
-
- for (int i = 0; i < viewList.Length; ++i)
- {
- View view = viewList[i];
-
- Vector3 viewPos = new Vector3(view.transform.position.x,
- view.transform.position.y,
- view.ViewSize);
- pathList.Add(viewPos);
- }
- StartCoroutine(panCoroutine = PanToPathInternal (camera, duration, arriveAction, pathList.ToArray ()));
- }
-
+
///
/// Creates a flat colored texture.
///
@@ -364,15 +213,35 @@ namespace Fungus
///
/// Perform a fullscreen fade over a duration.
///
- public virtual void Fade(float targetAlpha, float fadeDuration, Action fadeAction)
+ public virtual void Fade(float targetAlpha, float fadeDuration, Action fadeAction, LeanTweenType leanTweenType = LeanTweenType.easeInOutQuad)
{
- StartCoroutine(fadeCoroutine = FadeInternal (targetAlpha, fadeDuration, fadeAction));
+ StopFadeTween();
+
+ if (Mathf.Approximately(fadeDuration, 0))
+ {
+ fadeAlpha = targetAlpha;
+ if (fadeAction != null) fadeAction();
+ }
+ else
+ {
+ fadeTween = LeanTween.value(fadeAlpha, targetAlpha, fadeDuration)
+ .setEase(leanTweenType)
+ .setOnUpdate((x) => fadeAlpha = x)
+ .setOnComplete(() =>
+ {
+ fadeAlpha = targetAlpha;
+ if (fadeAction != null) fadeAction();
+ fadeTween = null;
+ });
+ }
}
///
/// Fade out, move camera to view and then fade back in.
///
- public virtual void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, Action fadeAction)
+ public virtual void FadeToView(Camera camera, View view, float fadeDuration, bool fadeOut, Action fadeAction,
+ LeanTweenType fadeType = LeanTweenType.easeInOutQuad, LeanTweenType sizeTweenType = LeanTweenType.easeInOutQuad,
+ LeanTweenType posTweenType = LeanTweenType.easeInOutQuad, LeanTweenType rotTweenType = LeanTweenType.easeInOutQuad)
{
swipePanActive = false;
fadeAlpha = 0f;
@@ -395,7 +264,7 @@ namespace Fungus
Fade(1f, outDuration, delegate {
// Snap to new view
- PanToPosition(camera, view.transform.position, view.transform.rotation, view.ViewSize, 0f, null);
+ PanToPosition(camera, view.transform.position, view.transform.rotation, view.ViewSize, 0f, null, sizeTweenType, posTweenType, rotTweenType);
// Fade in
Fade(0f, inDuration, delegate {
@@ -403,8 +272,8 @@ namespace Fungus
{
fadeAction();
}
- });
- });
+ }, fadeType);
+ }, fadeType);
}
///
@@ -412,15 +281,43 @@ namespace Fungus
///
public virtual void Stop()
{
- StopAllCoroutines();
- panCoroutine = null;
- fadeCoroutine = null;
+ StopFadeTween();
+ StopPosTweens();
+ }
+
+ protected void StopFadeTween()
+ {
+ if (fadeTween != null)
+ {
+ LeanTween.cancel(fadeTween.id, true);
+ fadeTween = null;
+ }
+ }
+
+ protected void StopPosTweens()
+ {
+ if (sizeTween != null)
+ {
+ LeanTween.cancel(sizeTween.id, true);
+ sizeTween = null;
+ }
+ if (camPosTween != null)
+ {
+ LeanTween.cancel(camPosTween.id, true);
+ camPosTween = null;
+ }
+ if (camRotTween != null)
+ {
+ LeanTween.cancel(camRotTween.id, true);
+ camRotTween = null;
+ }
}
///
/// Moves camera from current position to a target position over a period of time.
///
- public virtual void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction)
+ public virtual void PanToPosition(Camera camera, Vector3 targetPosition, Quaternion targetRotation, float targetSize, float duration, Action arriveAction,
+ LeanTweenType sizeTweenType = LeanTweenType.easeInOutQuad, LeanTweenType posTweenType = LeanTweenType.easeInOutQuad, LeanTweenType rotTweenType = LeanTweenType.easeInOutQuad)
{
if (camera == null)
{
@@ -428,11 +325,13 @@ namespace Fungus
return;
}
+ if(setCameraZ)
+ {
+ targetPosition.z = camera.transform.position.z;
+ }
+
// Stop any pan that is currently active
- if (panCoroutine != null) {
- StopCoroutine(panCoroutine);
- panCoroutine = null;
- }
+ StopPosTweens();
swipePanActive = false;
if (Mathf.Approximately(duration, 0f))
@@ -451,7 +350,31 @@ namespace Fungus
}
else
{
- StartCoroutine(panCoroutine = PanInternal(camera, targetPosition, targetRotation, targetSize, duration, arriveAction));
+ sizeTween = LeanTween.value(camera.orthographicSize, targetSize, duration)
+ .setEase(sizeTweenType)
+ .setOnUpdate(x => camera.orthographicSize = x)
+ .setOnComplete(() =>
+ {
+ camera.orthographicSize = targetSize;
+ if (arriveAction != null) arriveAction();
+ sizeTween = null;
+ });
+
+ camPosTween = LeanTween.move(camera.gameObject, targetPosition, duration)
+ .setEase(posTweenType)
+ .setOnComplete(() =>
+ {
+ camera.transform.position = targetPosition;
+ camPosTween = null;
+ });
+
+ camRotTween = LeanTween.rotate(camera.gameObject, targetRotation.eulerAngles, duration)
+ .setEase(rotTweenType)
+ .setOnComplete(() =>
+ {
+ camera.transform.rotation = targetRotation;
+ camRotTween = null;
+ });
}
}
diff --git a/Assets/Fungus/Scripts/Components/Character.cs b/Assets/Fungus/Scripts/Components/Character.cs
index f0743fae..e2c73280 100644
--- a/Assets/Fungus/Scripts/Components/Character.cs
+++ b/Assets/Fungus/Scripts/Components/Character.cs
@@ -1,10 +1,9 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// 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;
-using System;
namespace Fungus
{
@@ -12,7 +11,7 @@ namespace Fungus
/// A Character that can be used in dialogue via the Say, Conversation and Portrait commands.
///
[ExecuteInEditMode]
- public class Character : MonoBehaviour, ILocalizable
+ public class Character : MonoBehaviour, ILocalizable, IComparer
{
[Tooltip("Character name as displayed in Say Dialog.")]
[SerializeField] protected string nameText; // We need a separate name as the object name is used for character variations (e.g. "Smurf Happy", "Smurf Sad")
@@ -45,6 +44,7 @@ namespace Fungus
if (!activeCharacters.Contains(this))
{
activeCharacters.Add(this);
+ activeCharacters.Sort(this);
}
}
@@ -121,6 +121,18 @@ namespace Fungus
|| nameText.StartsWith(matchString, true, System.Globalization.CultureInfo.CurrentCulture);
#endif
}
+
+ public int Compare(Character x, Character y)
+ {
+ if (x == y)
+ return 0;
+ if (y == null)
+ return 1;
+ if (x == null)
+ return -1;
+
+ return x.name.CompareTo(y.name);
+ }
///
/// Looks for a portrait by name on a character
@@ -128,14 +140,14 @@ namespace Fungus
///
public virtual Sprite GetPortrait(string portraitString)
{
- if (String.IsNullOrEmpty(portraitString))
+ if (string.IsNullOrEmpty(portraitString))
{
return null;
}
for (int i = 0; i < portraits.Count; i++)
{
- if (portraits[i] != null && String.Compare(portraits[i].name, portraitString, true) == 0)
+ if (portraits[i] != null && string.Compare(portraits[i].name, portraitString, true) == 0)
{
return portraits[i];
}
@@ -169,5 +181,13 @@ namespace Fungus
}
#endregion
+
+ protected virtual void OnValidate()
+ {
+ if (portraits != null && portraits.Count > 1)
+ {
+ portraits.Sort(PortraitUtil.PortraitCompareTo);
+ }
+ }
}
}
diff --git a/Assets/Fungus/Scripts/Components/Clickable2D.cs b/Assets/Fungus/Scripts/Components/Clickable2D.cs
index a4493525..7f745836 100644
--- a/Assets/Fungus/Scripts/Components/Clickable2D.cs
+++ b/Assets/Fungus/Scripts/Components/Clickable2D.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Command.cs b/Assets/Fungus/Scripts/Components/Command.cs
index 4b3099d8..fca8395e 100644
--- a/Assets/Fungus/Scripts/Components/Command.cs
+++ b/Assets/Fungus/Scripts/Components/Command.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs b/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs
index 720c446d..157ac429 100644
--- a/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs
+++ b/Assets/Fungus/Scripts/Components/CommandCopyBuffer.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/CustomTag.cs b/Assets/Fungus/Scripts/Components/CustomTag.cs
index 537f27f4..f56bbdce 100644
--- a/Assets/Fungus/Scripts/Components/CustomTag.cs
+++ b/Assets/Fungus/Scripts/Components/CustomTag.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/DialogInput.cs b/Assets/Fungus/Scripts/Components/DialogInput.cs
index 24987ab8..514c7e4a 100644
--- a/Assets/Fungus/Scripts/Components/DialogInput.cs
+++ b/Assets/Fungus/Scripts/Components/DialogInput.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Draggable2D.cs b/Assets/Fungus/Scripts/Components/Draggable2D.cs
index 41fee724..73f8b0a7 100644
--- a/Assets/Fungus/Scripts/Components/Draggable2D.cs
+++ b/Assets/Fungus/Scripts/Components/Draggable2D.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -137,7 +137,7 @@ namespace Fungus
for (int i = 0; i < dragCompletedHandlers.Count; i++)
{
var handler = dragCompletedHandlers[i];
- if (handler != null && handler.DraggableObject == this)
+ if (handler != null && handler.DraggableObjects.Contains(this))
{
if (handler.IsOverTarget())
{
diff --git a/Assets/Fungus/Scripts/Components/EventHandler.cs b/Assets/Fungus/Scripts/Components/EventHandler.cs
index ddf64bb6..06653ecd 100644
--- a/Assets/Fungus/Scripts/Components/EventHandler.cs
+++ b/Assets/Fungus/Scripts/Components/EventHandler.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Flowchart.cs b/Assets/Fungus/Scripts/Components/Flowchart.cs
index b4071dad..3743293e 100644
--- a/Assets/Fungus/Scripts/Components/Flowchart.cs
+++ b/Assets/Fungus/Scripts/Components/Flowchart.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -800,6 +800,23 @@ namespace Fungus
return null;
}
+ ///
+ /// Returns a list of variables matching the specified type.
+ ///
+ public virtual List GetVariables() where T: Variable
+ {
+ var varsFound = new List();
+
+ for (int i = 0; i < Variables.Count; i++)
+ {
+ var currentVar = Variables[i];
+ if (currentVar is T)
+ varsFound.Add(currentVar as T);
+ }
+
+ return varsFound;
+ }
+
///
/// Register a new variable with the Flowchart at runtime.
/// The variable should be added as a component on the Flowchart game object.
diff --git a/Assets/Fungus/Scripts/Components/FungusManager.cs b/Assets/Fungus/Scripts/Components/FungusManager.cs
index 7076d4eb..477ef9be 100644
--- a/Assets/Fungus/Scripts/Components/FungusManager.cs
+++ b/Assets/Fungus/Scripts/Components/FungusManager.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/FungusState.cs b/Assets/Fungus/Scripts/Components/FungusState.cs
index bab5c0dd..4d2a351e 100644
--- a/Assets/Fungus/Scripts/Components/FungusState.cs
+++ b/Assets/Fungus/Scripts/Components/FungusState.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Localization.cs b/Assets/Fungus/Scripts/Components/Localization.cs
index d492b7a8..f8c296b9 100644
--- a/Assets/Fungus/Scripts/Components/Localization.cs
+++ b/Assets/Fungus/Scripts/Components/Localization.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/MenuDialog.cs b/Assets/Fungus/Scripts/Components/MenuDialog.cs
index 3c544b6e..f2f2be51 100644
--- a/Assets/Fungus/Scripts/Components/MenuDialog.cs
+++ b/Assets/Fungus/Scripts/Components/MenuDialog.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/MusicManager.cs b/Assets/Fungus/Scripts/Components/MusicManager.cs
index cd929285..781caa24 100644
--- a/Assets/Fungus/Scripts/Components/MusicManager.cs
+++ b/Assets/Fungus/Scripts/Components/MusicManager.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/NarrativeLog.cs b/Assets/Fungus/Scripts/Components/NarrativeLog.cs
index 49435178..393a55f2 100644
--- a/Assets/Fungus/Scripts/Components/NarrativeLog.cs
+++ b/Assets/Fungus/Scripts/Components/NarrativeLog.cs
@@ -1,7 +1,6 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
-using System;
using System.Collections.Generic;
using UnityEngine;
@@ -10,26 +9,20 @@ namespace Fungus
///
/// A single line of dialog
///
- [Serializable]
- public class Line
+ [System.Serializable]
+ public class NarrativeLogEntry
{
[SerializeField] public string name;
[SerializeField] public string text;
-
}
///
/// Serializable object to store Narrative Lines
///
- [Serializable]
+ [System.Serializable]
public class NarrativeData
{
- [SerializeField] public List lines;
-
- public NarrativeData() {
- lines = new List();
- }
-
+ public List entries = new List();
}
///
@@ -37,19 +30,38 @@ namespace Fungus
///
public class NarrativeLog : MonoBehaviour
{
-
///
/// NarrativeAdded signal. Sent when a line is added.
///
public static event NarrativeAddedHandler OnNarrativeAdded;
- public delegate void NarrativeAddedHandler();
- public static void DoNarrativeAdded() { if (OnNarrativeAdded != null) OnNarrativeAdded(); }
+ public delegate void NarrativeAddedHandler(NarrativeLogEntry data);
+ public static void DoNarrativeAdded(NarrativeLogEntry data)
+ {
+ if (OnNarrativeAdded != null)
+ {
+ OnNarrativeAdded(data);
+ }
+ }
+
+ ///
+ /// Signal sent when log history is cleared or loaded
+ ///
+ public static System.Action OnNarrativeLogClear;
+ public static void DoNarrativeCleared()
+ {
+ if (OnNarrativeLogClear != null)
+ {
+ OnNarrativeLogClear();
+ }
+ }
+
NarrativeData history;
protected virtual void Awake()
{
history = new NarrativeData();
+ DoNarrativeCleared();
}
protected virtual void OnEnable()
@@ -67,27 +79,28 @@ namespace Fungus
if (writerState == WriterState.End)
{
var sd = SayDialog.GetSayDialog();
- var from = sd.NameText;
- var line = sd.StoryText;
- AddLine(from, line);
+ if (sd != null)
+ {
+ NarrativeLogEntry entry = new NarrativeLogEntry()
+ {
+ name = sd.NameText,
+ text = sd.StoryText
+ };
+ AddLine(entry);
+ }
}
}
#region Public Methods
-
+
///
/// Add a line of dialog to the Narrative Log
///
- /// Character Name
- /// Narrative Text
- public void AddLine(string name, string text)
+ public void AddLine(NarrativeLogEntry entry)
{
- Line line = new Line();
- line.name = name;
- line.text = text;
- history.lines.Add(line);
- DoNarrativeAdded();
+ history.entries.Add(entry);
+ DoNarrativeAdded(entry);
}
///
@@ -96,7 +109,9 @@ namespace Fungus
///
public void Clear()
{
- history.lines.Clear();
+ history.entries.Clear();
+
+ DoNarrativeCleared();
}
///
@@ -118,12 +133,12 @@ namespace Fungus
string output = "\n ";
int count;
- count = previousOnly ? history.lines.Count - 1: history.lines.Count;
+ count = previousOnly ? history.entries.Count - 1 : history.entries.Count;
for (int i = 0; i < count; i++)
{
- output += "" + history.lines[i].name + "\n";
- output += history.lines[i].text + "\n\n";
+ output += "" + history.entries[i].name + "\n";
+ output += history.entries[i].text + "\n\n";
}
return output;
}
@@ -140,6 +155,8 @@ namespace Fungus
return;
}
history = JsonUtility.FromJson(narrativeData);
+
+ DoNarrativeCleared();
}
#endregion
}
diff --git a/Assets/Fungus/Scripts/Components/NarrativeLogEntryDisplay.cs b/Assets/Fungus/Scripts/Components/NarrativeLogEntryDisplay.cs
new file mode 100644
index 00000000..6ac3b3ac
--- /dev/null
+++ b/Assets/Fungus/Scripts/Components/NarrativeLogEntryDisplay.cs
@@ -0,0 +1,50 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Fungus
+{
+ ///
+ /// Displays Narrative Log Entries in the UI.
+ ///
+ public class NarrativeLogEntryDisplay : MonoBehaviour
+ {
+ [SerializeField] protected Text nameTextField;
+ [SerializeField] protected Text storyTextField;
+ private NarrativeLogEntry toDisplay;
+
+ ///
+ /// The entry that this represents in the UI. The setter here alters this display's UI fields
+ /// to fit the new value.
+ ///
+ public virtual NarrativeLogEntry ToDisplay
+ {
+ get { return toDisplay; }
+ set
+ {
+ toDisplay = value;
+ UpdateDisplays();
+ }
+ }
+
+ ///
+ /// Ensures that the UI components of this display fit the NarrativeLog Entry
+ /// it has... if any.
+ ///
+ protected virtual void UpdateDisplays()
+ {
+ if (ToDisplay == null)
+ {
+ nameTextField.text = "";
+ storyTextField.text = "";
+ }
+ else
+ {
+ nameTextField.text = toDisplay.name;
+ storyTextField.text = toDisplay.text;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Components/NarrativeLogEntryDisplay.cs.meta b/Assets/Fungus/Scripts/Components/NarrativeLogEntryDisplay.cs.meta
new file mode 100644
index 00000000..b1b3eef2
--- /dev/null
+++ b/Assets/Fungus/Scripts/Components/NarrativeLogEntryDisplay.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 824b58b7741a0dd4e9b43693c47b24f7
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Components/NarrativeLogEntryUI.cs b/Assets/Fungus/Scripts/Components/NarrativeLogEntryUI.cs
new file mode 100644
index 00000000..04a72f6d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Components/NarrativeLogEntryUI.cs
@@ -0,0 +1,94 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Manages the UI aspects of the Narrative Log via EntryDisplay objects
+ ///
+ /// Originally contributed by https://github.com/CG-Tespy
+ ///
+ public class NarrativeLogEntryUI : MonoBehaviour
+ {
+ [Tooltip("Contains the overall aesthetic of each entry.")]
+ [SerializeField] protected NarrativeLogEntryDisplay entryDisplayPrefab;
+
+ [SerializeField] protected RectTransform entryHolder;
+ protected CanvasGroup canvasGroup;
+ protected List entryDisplays = new List();
+ protected UnityEngine.UI.ScrollRect scrollRect;
+
+ protected virtual void Awake()
+ {
+ canvasGroup = GetComponent();
+ var tmp = FungusManager.Instance.NarrativeLog;
+ // Make sure to update the UI when new entries are added to or
+ // cleared from the log.
+ //using the fungusmanager to ensure that the narrativeLog is inited
+ NarrativeLog.OnNarrativeAdded += OnNarrativeAdded;
+ NarrativeLog.OnNarrativeLogClear += Clear;
+
+ scrollRect = GetComponentInChildren();
+ }
+
+ public virtual void Clear()
+ {
+ for (int i = 0; i < entryDisplays.Count; i++)
+ {
+ var entryDisplay = entryDisplays[i];
+ Destroy(entryDisplay.gameObject);
+ }
+
+ entryDisplays.Clear();
+ }
+
+ public virtual void Open()
+ {
+ canvasGroup.alpha = 1;
+ canvasGroup.interactable = true;
+ canvasGroup.blocksRaycasts = true;
+ }
+
+ public virtual void Close()
+ {
+ canvasGroup.alpha = 0;
+ canvasGroup.interactable = false;
+ canvasGroup.blocksRaycasts = false;
+ }
+
+ protected virtual void OnNarrativeAdded(NarrativeLogEntry entryAdded)
+ {
+ // Create a display for the new entry, and have it show in the UI.
+ var newEntryDisplay = Instantiate(entryDisplayPrefab);
+ newEntryDisplay.transform.SetParent(entryHolder, false);
+ newEntryDisplay.ToDisplay = entryAdded;
+ entryDisplays.Add(newEntryDisplay);
+ StartCoroutine(ForceToBottom());
+ }
+
+ private System.Collections.IEnumerator ForceToBottom()
+ {
+ yield return null;
+ scrollRect.verticalNormalizedPosition = 0;
+ }
+
+ protected virtual void OnLogCleared()
+ {
+ Clear();
+ }
+
+ protected virtual void OnDestroy()
+ {
+ var fManInst = FungusManager.Instance;
+ // Avoid this responding to signals when being destroyed.
+ if (fManInst != null)
+ {
+ NarrativeLog.OnNarrativeAdded -= OnNarrativeAdded;
+ NarrativeLog.OnNarrativeLogClear -= Clear;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Components/NarrativeLogEntryUI.cs.meta b/Assets/Fungus/Scripts/Components/NarrativeLogEntryUI.cs.meta
new file mode 100644
index 00000000..544e403d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Components/NarrativeLogEntryUI.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fde579c9edfbe7e469349e39e2a87a48
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs b/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs
index cec4d64e..36c42669 100644
--- a/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs
+++ b/Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
@@ -14,6 +14,9 @@ namespace Fungus
///
public class NarrativeLogMenu : MonoBehaviour
{
+ [Tooltip("Contains the overall aesthetic of each entry.")]
+ [SerializeField] protected NarrativeLogEntryDisplay entryDisplayPrefab;
+
[Tooltip("Show the Narrative Log Menu")]
[SerializeField] protected bool showLog = true;
@@ -72,7 +75,6 @@ namespace Fungus
//Clear up the lorem ipsum
UpdateNarrativeLogText();
-
}
protected virtual void OnEnable()
@@ -93,7 +95,7 @@ namespace Fungus
NarrativeLog.OnNarrativeAdded -= OnNarrativeAdded;
}
- protected virtual void OnNarrativeAdded()
+ protected virtual void OnNarrativeAdded(NarrativeLogEntry data)
{
UpdateNarrativeLogText();
}
diff --git a/Assets/Fungus/Scripts/Components/Node.cs b/Assets/Fungus/Scripts/Components/Node.cs
index 16a5294e..fbbdbc1d 100644
--- a/Assets/Fungus/Scripts/Components/Node.cs
+++ b/Assets/Fungus/Scripts/Components/Node.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Parallax.cs b/Assets/Fungus/Scripts/Components/Parallax.cs
index 57f1bf2e..48b5c3c6 100644
--- a/Assets/Fungus/Scripts/Components/Parallax.cs
+++ b/Assets/Fungus/Scripts/Components/Parallax.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/PortraitController.cs b/Assets/Fungus/Scripts/Components/PortraitController.cs
index 20b7324d..1e832733 100644
--- a/Assets/Fungus/Scripts/Components/PortraitController.cs
+++ b/Assets/Fungus/Scripts/Components/PortraitController.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -52,8 +52,13 @@ namespace Fungus
OffsetRight
}
+
+ [AddComponentMenu("")]
///
- /// Controls the Portrait sprites on stage
+ /// Controls the Portrait sprites on stage.
+ ///
+ /// Is only really used via Stage, it's child class. This class continues to exist to support existing API
+ /// dependant code. All functionality is stage dependant.
///
public class PortraitController : MonoBehaviour
{
@@ -104,7 +109,7 @@ namespace Fungus
// if no previous portrait, use default portrait
if (options.character.State.portrait == null)
{
- options.character.State.portrait = options.character.ProfileSprite;
+ options.character.State.SetPortraitImageBySprite(options.character.ProfileSprite);
}
// Selected "use previous portrait"
@@ -184,29 +189,60 @@ namespace Fungus
///
protected virtual void CreatePortraitObject(Character character, float fadeDuration)
{
- // Create a new portrait object
- GameObject portraitObj = new GameObject(character.name,
- typeof(RectTransform),
- typeof(CanvasRenderer),
- typeof(Image));
-
- // Set it to be a child of the stage
- portraitObj.transform.SetParent(stage.PortraitCanvas.transform, true);
-
- // Configure the portrait image
- Image portraitImage = portraitObj.GetComponent();
- portraitImage.preserveAspect = true;
- portraitImage.overrideSprite = character.ProfileSprite;
- portraitImage.color = new Color(1f, 1f, 1f, 0f);
+ if (character.State.holder == null)
+ {
+ character.State.holder = new GameObject(character.name + " holder",
+ typeof(RectTransform)
+ //typeof(CanvasRenderer),
+ //typeof(Image)
+ ).GetComponent();
- // LeanTween doesn't handle 0 duration properly
- float duration = (fadeDuration > 0f) ? fadeDuration : float.Epsilon;
+ // Set it to be a child of the stage
+ character.State.holder.transform.SetParent(stage.PortraitCanvas.transform, false);
- // Fade in character image (first time)
- LeanTween.alpha(portraitImage.transform as RectTransform, 1f, duration).setEase(stage.FadeEaseType).setRecursive(false);
+ SetRectTransform(character.State.holder, stage.DefaultPosition.GetComponent());
+ }
- // Tell character about portrait image
- character.State.portraitImage = portraitImage;
+ if (character.State.allPortraits.Count == 0)
+ {
+ foreach (var item in character.Portraits)
+ {
+ if(item == null)
+ {
+ Debug.LogError("null in portrait list on character " + character.name);
+ continue;
+ }
+ // Create a new portrait object
+ GameObject po = new GameObject(item.name,
+ typeof(RectTransform),
+ typeof(CanvasRenderer),
+ typeof(Image));
+
+ // Set it to be a child of the stage
+ po.transform.SetParent(character.State.holder, false);
+
+ // Configure the portrait image
+ Image pi = po.GetComponent();
+ pi.preserveAspect = true;
+ pi.sprite = item;
+ pi.color = new Color(1f, 1f, 1f, 0f);
+
+ if (item == character.ProfileSprite)
+ {
+ character.State.portraitImage = pi;
+ }
+
+ //expand to fit parent
+ RectTransform rt = po.GetComponent();
+ rt.sizeDelta = Vector2.zero;
+ rt.anchorMin = Vector2.zero;
+ rt.anchorMax = Vector2.one;
+ rt.pivot = Vector2.one * 0.5f;
+ rt.ForceUpdateRectTransforms();
+
+ character.State.allPortraits.Add(pi);
+ }
+ }
}
protected virtual IEnumerator WaitUntilFinished(float duration, Action onComplete = null)
@@ -232,48 +268,42 @@ namespace Fungus
protected virtual void SetupPortrait(PortraitOptions options)
{
- SetRectTransform(options.character.State.portraitImage.rectTransform, options.fromPosition);
+ if (options.character.State.holder == null)
+ return;
+
+ SetRectTransform(options.character.State.holder, options.fromPosition);
if (options.character.State.facing != options.character.PortraitsFace)
{
- options.character.State.portraitImage.rectTransform.localScale = new Vector3(-1f, 1f, 1f);
+ options.character.State.holder.localScale = new Vector3(-1f, 1f, 1f);
}
else
{
- options.character.State.portraitImage.rectTransform.localScale = new Vector3(1f, 1f, 1f);
+ options.character.State.holder.localScale = new Vector3(1f, 1f, 1f);
}
if (options.facing != options.character.PortraitsFace)
{
- options.character.State.portraitImage.rectTransform.localScale = new Vector3(-1f, 1f, 1f);
+ options.character.State.holder.localScale = new Vector3(-1f, 1f, 1f);
}
else
{
- options.character.State.portraitImage.rectTransform.localScale = new Vector3(1f, 1f, 1f);
+ options.character.State.holder.localScale = new Vector3(1f, 1f, 1f);
}
}
- protected virtual void DoMoveTween(Character character, RectTransform fromPosition, RectTransform toPosition, float moveDuration, Boolean waitUntilFinished)
- {
- PortraitOptions options = new PortraitOptions(true);
- options.character = character;
- options.fromPosition = fromPosition;
- options.toPosition = toPosition;
- options.moveDuration = moveDuration;
- options.waitUntilFinished = waitUntilFinished;
-
- DoMoveTween(options);
- }
-
protected virtual void DoMoveTween(PortraitOptions options)
{
CleanPortraitOptions(options);
+ LeanTween.cancel(options.character.State.holder.gameObject);
+
// LeanTween doesn't handle 0 duration properly
float duration = (options.moveDuration > 0f) ? options.moveDuration : float.Epsilon;
// LeanTween.move uses the anchoredPosition, so all position images must have the same anchor position
- LeanTween.move(options.character.State.portraitImage.gameObject, options.toPosition.position, duration).setEase(stage.FadeEaseType);
+ LeanTween.move(options.character.State.holder.gameObject, options.toPosition.position, duration)
+ .setEase(stage.FadeEaseType);
if (options.waitUntilFinished)
{
@@ -281,22 +311,20 @@ namespace Fungus
}
}
- #region Public members
-
///
/// Performs a deep copy of all values from one RectTransform to another.
///
- public static void SetRectTransform(RectTransform oldRectTransform, RectTransform newRectTransform)
+ public static void SetRectTransform(RectTransform target, RectTransform from)
{
- oldRectTransform.eulerAngles = newRectTransform.eulerAngles;
- oldRectTransform.position = newRectTransform.position;
- oldRectTransform.rotation = newRectTransform.rotation;
- oldRectTransform.anchoredPosition = newRectTransform.anchoredPosition;
- oldRectTransform.sizeDelta = newRectTransform.sizeDelta;
- oldRectTransform.anchorMax = newRectTransform.anchorMax;
- oldRectTransform.anchorMin = newRectTransform.anchorMin;
- oldRectTransform.pivot = newRectTransform.pivot;
- oldRectTransform.localScale = newRectTransform.localScale;
+ target.eulerAngles = from.eulerAngles;
+ target.position = from.position;
+ target.rotation = from.rotation;
+ target.anchoredPosition = from.anchoredPosition;
+ target.sizeDelta = from.sizeDelta;
+ target.anchorMax = from.anchorMax;
+ target.anchorMin = from.anchorMin;
+ target.pivot = from.pivot;
+ target.localScale = from.localScale;
}
///
@@ -354,17 +382,7 @@ namespace Fungus
}
}
- ///
- /// Moves Character in front of other characters on stage
- ///
- public virtual void MoveToFront(Character character)
- {
- PortraitOptions options = new PortraitOptions(true);
- options.character = character;
-
- MoveToFront(CleanPortraitOptions(options));
- }
-
+
///
/// Moves Character in front of other characters on stage
///
@@ -375,51 +393,6 @@ namespace Fungus
FinishCommand(options);
}
- ///
- /// Shows character at a named position in the stage
- ///
- ///
- /// Named position on stage
- public virtual void Show(Character character, string position)
- {
- PortraitOptions options = new PortraitOptions(true);
- options.character = character;
- options.fromPosition = options.toPosition = stage.GetPosition(position);
-
- Show(options);
- }
-
- ///
- /// Shows character moving from a position to a position
- ///
- ///
- ///
- /// Where the character will appear
- /// Where the character will move to
- public virtual void Show(Character character, string portrait, string fromPosition, string toPosition)
- {
- PortraitOptions options = new PortraitOptions(true);
- options.character = character;
- options.portrait = character.GetPortrait(portrait);
- options.fromPosition = stage.GetPosition(fromPosition);
- options.toPosition = stage.GetPosition(toPosition);
- options.move = true;
-
- Show(options);
- }
-
- ///
- /// From lua, you can pass an options table with named arguments
- /// example:
- /// stage.show{character=jill, portrait="happy", fromPosition="right", toPosition="left"}
- /// Any option available in the PortraitOptions is available from Lua
- ///
- /// Moonsharp Table
- public virtual void Show(Table optionsTable)
- {
- Show(PortraitUtil.ConvertTableToPortraitOptions(optionsTable, stage));
- }
-
///
/// Show portrait with the supplied portrait options
///
@@ -454,33 +427,18 @@ namespace Fungus
// LeanTween doesn't handle 0 duration properly
float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon;
- // Fade out a duplicate of the existing portrait image
- if (options.character.State.portraitImage != null && options.character.State.portraitImage.overrideSprite != null)
- {
- GameObject tempGO = GameObject.Instantiate(options.character.State.portraitImage.gameObject);
- tempGO.transform.SetParent(options.character.State.portraitImage.transform, false);
- tempGO.transform.localPosition = Vector3.zero;
- tempGO.transform.localScale = options.character.State.position.localScale;
-
- Image tempImage = tempGO.GetComponent();
- tempImage.overrideSprite = options.character.State.portraitImage.overrideSprite;
- tempImage.preserveAspect = true;
- tempImage.color = options.character.State.portraitImage.color;
+ var prevPortrait = options.character.State.portrait;
- LeanTween.alpha(tempImage.rectTransform, 0f, duration).setEase(stage.FadeEaseType).setOnComplete(() => {
- Destroy(tempGO);
- }).setRecursive(false);
- }
-
- // Fade in the new sprite image
- if (options.character.State.portraitImage.overrideSprite != options.portrait ||
- options.character.State.portraitImage.color.a < 1f)
+ if (options.character.State.portrait != null && options.character.State.portrait != options.portrait)
{
- options.character.State.portraitImage.overrideSprite = options.portrait;
- options.character.State.portraitImage.color = new Color(1f, 1f, 1f, 0f);
- LeanTween.alpha(options.character.State.portraitImage.rectTransform, 1f, duration).setEase(stage.FadeEaseType).setRecursive(false);
+ LeanTween.alpha(options.character.State.portraitImage.rectTransform, 0f, duration)
+ .setEase(stage.FadeEaseType)
+ .setRecursive(false);
}
+ options.character.State.SetPortraitImageBySprite(options.portrait);
+ LeanTween.alpha(options.character.State.portraitImage.rectTransform, 1f, duration).setEase(stage.FadeEaseType).setRecursive(false);
+
DoMoveTween(options);
FinishCommand(options);
@@ -490,14 +448,117 @@ namespace Fungus
stage.CharactersOnStage.Add(options.character);
}
+ MoveToFront(options);
+
// Update character state after showing
options.character.State.onScreen = true;
options.character.State.display = DisplayType.Show;
- options.character.State.portrait = options.portrait;
options.character.State.facing = options.facing;
options.character.State.position = options.toPosition;
}
+ ///
+ /// Hide portrait with provided options
+ ///
+ public virtual void Hide(PortraitOptions options)
+ {
+ CleanPortraitOptions(options);
+
+ if (options.character.State.display == DisplayType.None)
+ {
+ return;
+ }
+
+ SetupPortrait(options);
+
+ // LeanTween doesn't handle 0 duration properly
+ float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon;
+
+ LeanTween.alpha(options.character.State.portraitImage.rectTransform, 0f, duration).setEase(stage.FadeEaseType).setRecursive(false);
+
+ DoMoveTween(options);
+
+ //update character state after hiding
+ options.character.State.onScreen = false;
+ options.character.State.facing = options.facing;
+ options.character.State.position = options.toPosition;
+ options.character.State.display = DisplayType.Hide;
+
+ if (stage.CharactersOnStage.Remove(options.character))
+ {
+ }
+
+ FinishCommand(options);
+ }
+
+ ///
+ /// Sets the dimmed state of a character on the stage.
+ ///
+ public virtual void SetDimmed(Character character, bool dimmedState)
+ {
+ if (character.State.dimmed == dimmedState)
+ {
+ return;
+ }
+
+ character.State.dimmed = dimmedState;
+
+ Color targetColor = dimmedState ? stage.DimColor : Color.white;
+
+ // LeanTween doesn't handle 0 duration properly
+ float duration = (stage.FadeDuration > 0f) ? stage.FadeDuration : float.Epsilon;
+
+ LeanTween.color(character.State.portraitImage.rectTransform, targetColor, duration).setEase(stage.FadeEaseType).setRecursive(false);
+ }
+
+ #region Overloads and Helpers
+
+ ///
+ /// Shows character at a named position in the stage
+ ///
+ ///
+ /// Named position on stage
+ public virtual void Show(Character character, string position)
+ {
+ PortraitOptions options = new PortraitOptions(true);
+ options.character = character;
+ options.fromPosition = options.toPosition = stage.GetPosition(position);
+
+ Show(options);
+ }
+
+ ///
+ /// Shows character moving from a position to a position
+ ///
+ ///
+ ///
+ /// Where the character will appear
+ /// Where the character will move to
+ public virtual void Show(Character character, string portrait, string fromPosition, string toPosition)
+ {
+ PortraitOptions options = new PortraitOptions(true);
+ options.character = character;
+ options.portrait = character.GetPortrait(portrait);
+ options.fromPosition = stage.GetPosition(fromPosition);
+ options.toPosition = stage.GetPosition(toPosition);
+ options.move = true;
+
+ Show(options);
+ }
+
+ ///
+ /// From lua, you can pass an options table with named arguments
+ /// example:
+ /// stage.show{character=jill, portrait="happy", fromPosition="right", toPosition="left"}
+ /// Any option available in the PortraitOptions is available from Lua
+ ///
+ /// Moonsharp Table
+ public virtual void Show(Table optionsTable)
+ {
+ Show(PortraitUtil.ConvertTableToPortraitOptions(optionsTable, stage));
+ }
+
+
///
/// Simple show command that shows the character with an available named portrait
///
@@ -559,60 +620,31 @@ namespace Fungus
{
Hide(PortraitUtil.ConvertTableToPortraitOptions(optionsTable, stage));
}
-
+
///
- /// Hide portrait with provided options
+ /// Moves Character in front of other characters on stage
///
- public virtual void Hide(PortraitOptions options)
+ public virtual void MoveToFront(Character character)
{
- CleanPortraitOptions(options);
-
- if (options.character.State.display == DisplayType.None)
- {
- return;
- }
-
- SetupPortrait(options);
-
- // LeanTween doesn't handle 0 duration properly
- float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon;
-
- LeanTween.alpha(options.character.State.portraitImage.rectTransform, 0f, duration).setEase(stage.FadeEaseType).setRecursive(false);
-
- DoMoveTween(options);
-
- stage.CharactersOnStage.Remove(options.character);
-
- //update character state after hiding
- options.character.State.onScreen = false;
- options.character.State.portrait = options.portrait;
- options.character.State.facing = options.facing;
- options.character.State.position = options.toPosition;
- options.character.State.display = DisplayType.Hide;
+ PortraitOptions options = new PortraitOptions(true);
+ options.character = character;
- FinishCommand(options);
+ MoveToFront(CleanPortraitOptions(options));
}
- ///
- /// Sets the dimmed state of a character on the stage.
- ///
- public virtual void SetDimmed(Character character, bool dimmedState)
- {
- if (character.State.dimmed == dimmedState)
- {
- return;
- }
-
- character.State.dimmed = dimmedState;
-
- Color targetColor = dimmedState ? stage.DimColor : Color.white;
- // LeanTween doesn't handle 0 duration properly
- float duration = (stage.FadeDuration > 0f) ? stage.FadeDuration : float.Epsilon;
+ protected virtual void DoMoveTween(Character character, RectTransform fromPosition, RectTransform toPosition, float moveDuration, Boolean waitUntilFinished)
+ {
+ PortraitOptions options = new PortraitOptions(true);
+ options.character = character;
+ options.fromPosition = fromPosition;
+ options.toPosition = toPosition;
+ options.moveDuration = moveDuration;
+ options.waitUntilFinished = waitUntilFinished;
- LeanTween.color(character.State.portraitImage.rectTransform, targetColor, duration).setEase(stage.FadeEaseType).setRecursive(false);
+ DoMoveTween(options);
}
- #endregion
+ #endregion
}
}
diff --git a/Assets/Fungus/Scripts/Components/SaveData.cs b/Assets/Fungus/Scripts/Components/SaveData.cs
index 3a6fdc05..2769988f 100644
--- a/Assets/Fungus/Scripts/Components/SaveData.cs
+++ b/Assets/Fungus/Scripts/Components/SaveData.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
diff --git a/Assets/Fungus/Scripts/Components/SaveManager.cs b/Assets/Fungus/Scripts/Components/SaveManager.cs
index 6451a6f9..a8d97aff 100644
--- a/Assets/Fungus/Scripts/Components/SaveManager.cs
+++ b/Assets/Fungus/Scripts/Components/SaveManager.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
@@ -235,7 +235,7 @@ namespace Fungus
///
/// Deletes a previously stored Save History from persistent storage.
///
- public void Delete(string saveDataKey)
+ public static void Delete(string saveDataKey)
{
#if UNITY_WEBPLAYER || UNITY_WEBGL
PlayerPrefs.DeleteKey(saveDataKey);
diff --git a/Assets/Fungus/Scripts/Components/SaveMenu.cs b/Assets/Fungus/Scripts/Components/SaveMenu.cs
index e7b1ec6d..5ca69564 100644
--- a/Assets/Fungus/Scripts/Components/SaveMenu.cs
+++ b/Assets/Fungus/Scripts/Components/SaveMenu.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
@@ -311,7 +311,7 @@ namespace Fungus
if (restartDeletesSave)
{
- saveManager.Delete(saveDataKey);
+ SaveManager.Delete(saveDataKey);
}
SaveManagerSignals.DoSaveReset();
SceneManager.LoadScene(saveManager.StartScene);
diff --git a/Assets/Fungus/Scripts/Components/SayDialog.cs b/Assets/Fungus/Scripts/Components/SayDialog.cs
index 1ccb7832..c0a8fc11 100644
--- a/Assets/Fungus/Scripts/Components/SayDialog.cs
+++ b/Assets/Fungus/Scripts/Components/SayDialog.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/SceneLoader.cs b/Assets/Fungus/Scripts/Components/SceneLoader.cs
index 933acb2d..cc3818f5 100644
--- a/Assets/Fungus/Scripts/Components/SceneLoader.cs
+++ b/Assets/Fungus/Scripts/Components/SceneLoader.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/SelectOnEnable.cs b/Assets/Fungus/Scripts/Components/SelectOnEnable.cs
index c7a0095b..0bd7930f 100644
--- a/Assets/Fungus/Scripts/Components/SelectOnEnable.cs
+++ b/Assets/Fungus/Scripts/Components/SelectOnEnable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/SpriteFader.cs b/Assets/Fungus/Scripts/Components/SpriteFader.cs
index 47fa48e9..2b0bcbdb 100644
--- a/Assets/Fungus/Scripts/Components/SpriteFader.cs
+++ b/Assets/Fungus/Scripts/Components/SpriteFader.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Stage.cs b/Assets/Fungus/Scripts/Components/Stage.cs
index 2a0d9869..2eaf2591 100644
--- a/Assets/Fungus/Scripts/Components/Stage.cs
+++ b/Assets/Fungus/Scripts/Components/Stage.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -9,7 +9,7 @@ using System.Collections.Generic;
namespace Fungus
{
///
- /// Define a set of screen positions where character sprites can be displayed.
+ /// Define a set of screen positions where character sprites can be displayed and controls portraits.
///
[ExecuteInEditMode]
public class Stage : PortraitController
diff --git a/Assets/Fungus/Scripts/Components/Variable.cs b/Assets/Fungus/Scripts/Components/Variable.cs
index 4a3e317a..66841e1f 100644
--- a/Assets/Fungus/Scripts/Components/Variable.cs
+++ b/Assets/Fungus/Scripts/Components/Variable.cs
@@ -1,8 +1,7 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
-using System;
namespace Fungus
{
@@ -60,45 +59,55 @@ namespace Fungus
///
/// Attribute class for variables.
///
- public class VariableInfoAttribute : Attribute
+ public sealed class VariableInfoAttribute : System.Attribute
{
- public VariableInfoAttribute(string category, string variableType, int order = 0)
+ //Note do not use "isPreviewedOnly:true", it causes the script to fail to load without errors shown
+ public VariableInfoAttribute(string category, string variableType, int order = 0, bool isPreviewedOnly = false)
{
this.Category = category;
this.VariableType = variableType;
this.Order = order;
+ this.IsPreviewedOnly = isPreviewedOnly;
}
public string Category { get; set; }
public string VariableType { get; set; }
public int Order { get; set; }
+ public bool IsPreviewedOnly { get; set; }
}
///
/// Attribute class for variable properties.
///
- public class VariablePropertyAttribute : PropertyAttribute
+ public sealed class VariablePropertyAttribute : PropertyAttribute
{
public VariablePropertyAttribute (params System.Type[] variableTypes)
{
this.VariableTypes = variableTypes;
}
+ public VariablePropertyAttribute(AllVariableTypes.VariableAny any)
+ {
+ VariableTypes = AllVariableTypes.AllFungusVarTypes;
+ }
+
public VariablePropertyAttribute (string defaultText, params System.Type[] variableTypes)
{
this.defaultText = defaultText;
this.VariableTypes = variableTypes;
}
- public String defaultText = "";
+ public string defaultText = "";
+ public string compatibleVariableName = string.Empty;
- public Type[] VariableTypes { get; set; }
+ public System.Type[] VariableTypes { get; set; }
}
///
/// Abstract base class for variables.
///
[RequireComponent(typeof(Flowchart))]
+ [System.Serializable]
public abstract class Variable : MonoBehaviour
{
[SerializeField] protected VariableScope scope;
@@ -122,12 +131,36 @@ namespace Fungus
///
public abstract void OnReset();
+ ///
+ /// Used by SetVariable, child classes required to declare and implement operators.
+ ///
+ ///
+ ///
+ public abstract void Apply(SetOperator setOperator, object value);
+
+ ///
+ /// Used by Ifs, While, and the like. Child classes required to declare and implement comparisons.
+ ///
+ ///
+ ///
+ ///
+ public abstract bool Evaluate(CompareOperator compareOperator, object value);
+
+ ///
+ /// Does the underlying type provide support for +-*/
+ ///
+ public virtual bool IsArithmeticSupported(SetOperator setOperator) { return false; }
+
+ ///
+ /// Does the underlying type provide support for < <= > >=
+ ///
+ public virtual bool IsComparisonSupported() { return false; }
+
///
/// Boxed or referenced value of type defined within inherited types.
/// Not recommended for direct use, primarily intended for use in editor code.
///
public abstract object GetValue();
-
#endregion
}
@@ -198,7 +231,10 @@ namespace Fungus
public override string ToString()
{
- return Value.ToString();
+ if (Value != null)
+ return Value.ToString();
+ else
+ return "Null";
}
protected virtual void Start()
@@ -207,8 +243,80 @@ namespace Fungus
startValue = Value;
}
- public virtual void Apply(SetOperator setOperator, T value) {
- Debug.LogError("Variable doesn't have any operators.");
+ //Apply to get from base system.object to T
+ public override void Apply(SetOperator op, object value)
+ {
+ if(value is T || value == null)
+ {
+ Apply(op, (T)value);
+ }
+ else if(value is VariableBase)
+ {
+ var vbg = value as VariableBase;
+ Apply(op, vbg.Value);
+ }
+ else
+ {
+ Debug.LogError("Cannot do Apply on variable, as object type: " + value.GetType().Name + " is incompatible with " + typeof(T).Name);
+ }
+ }
+
+ public virtual void Apply(SetOperator setOperator, T value)
+ {
+ switch (setOperator)
+ {
+ case SetOperator.Assign:
+ Value = value;
+ break;
+ default:
+ Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
+ break;
+ }
+ }
+
+ //Apply to get from base system.object to T
+ public override bool Evaluate(CompareOperator op, object value)
+ {
+ if (value is T || value == null)
+ {
+ return Evaluate(op, (T)value);
+ }
+ else if (value is VariableBase)
+ {
+ var vbg = value as VariableBase;
+ return Evaluate(op, vbg.Value);
+ }
+ else
+ {
+ Debug.LogError("Cannot do Evaluate on variable, as object type: " + value.GetType().Name + " is incompatible with " + typeof(T).Name);
+ }
+
+ return false;
+ }
+
+ public virtual bool Evaluate(CompareOperator compareOperator, T value)
+ {
+ bool condition = false;
+
+ switch (compareOperator)
+ {
+ case CompareOperator.Equals:
+ condition = Equals(Value, value);// Value.Equals(value);
+ break;
+ case CompareOperator.NotEquals:
+ condition = !Equals(Value, value);
+ break;
+ default:
+ Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
+ break;
+ }
+
+ return condition;
+ }
+
+ public override bool IsArithmeticSupported(SetOperator setOperator)
+ {
+ return setOperator == SetOperator.Assign || base.IsArithmeticSupported(setOperator);
}
}
}
diff --git a/Assets/Fungus/Scripts/Components/View.cs b/Assets/Fungus/Scripts/Components/View.cs
index c8464100..dbba1073 100644
--- a/Assets/Fungus/Scripts/Components/View.cs
+++ b/Assets/Fungus/Scripts/Components/View.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Components/Writer.cs b/Assets/Fungus/Scripts/Components/Writer.cs
index a5f413d4..3b1bd11c 100644
--- a/Assets/Fungus/Scripts/Components/Writer.cs
+++ b/Assets/Fungus/Scripts/Components/Writer.cs
@@ -1,11 +1,11 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
-using System;
+using System.Linq;
using System.Reflection;
using System.Text;
@@ -25,7 +25,7 @@ namespace Fungus
/// Writing has resumed after a pause.
Resume,
/// Writing has ended.
- End
+ End,
}
///
@@ -57,6 +57,8 @@ namespace Fungus
[Tooltip("Click while text is writing to finish writing immediately")]
[SerializeField] protected bool instantComplete = true;
+ [SerializeField] protected bool doReadAheadText = true;
+
// This property is true when the writer is waiting for user input to continue
protected bool isWaitingForInput;
@@ -71,11 +73,39 @@ namespace Fungus
protected bool italicActive = false;
protected bool colorActive = false;
protected string colorText = "";
+ protected bool linkActive = false;
+ protected string linkText = string.Empty;
protected bool sizeActive = false;
protected float sizeValue = 16f;
protected bool inputFlag;
protected bool exitFlag;
+ //holds number of Word tokens in the currently running Write
+ public int WordTokensFound { get; protected set; }
+
+ ///
+ /// Updated during writing of Word tokens, when processed tips over found, fires NotifyAllWordsWritten
+ ///
+ public virtual int WordTokensProcessed
+ {
+ get { return wordTokensProcessed; }
+ protected set
+ {
+ if(wordTokensProcessed < WordTokensFound && value >= WordTokensFound)
+ {
+ NotifyAllWordsWritten();
+ }
+ wordTokensProcessed = value;
+ }
+ }
+ //holds count of number of Word tokens completed
+ protected int wordTokensProcessed;
+
+ ///
+ /// Does the currently processing list of Tokens have Word Tokens that are not yet processed
+ ///
+ public bool HasWordsRemaining { get { return WordTokensProcessed < WordTokensFound; } }
+
protected List writerListeners = new List();
protected StringBuilder openString = new StringBuilder(256);
@@ -89,6 +119,7 @@ namespace Fungus
protected string hiddenColorClose = "";
protected int visibleCharacterCount = 0;
+ protected int readAheadStartIndex = 0;
public WriterAudio AttachedWriterAudio { get; set; }
protected virtual void Awake()
@@ -120,7 +151,7 @@ namespace Fungus
{
// Cache the hidden color string
Color32 c = hiddenTextColor;
- hiddenColorOpen = String.Format("", c.r, c.g, c.b, c.a);
+ hiddenColorOpen = string.Format("", c.r, c.g, c.b, c.a);
hiddenColorClose = "";
}
@@ -148,7 +179,13 @@ namespace Fungus
{
openString.Append("");
+ openString.Append(">");
+ }
+ if (linkActive)
+ {
+ openString.Append("");
}
if (boldActive)
{
@@ -177,7 +214,11 @@ namespace Fungus
}
if (colorActive)
{
- closeString.Append("");
+ closeString.Append("");
+ }
+ if (linkActive)
+ {
+ closeString.Append("");
}
if (sizeActive)
{
@@ -206,19 +247,21 @@ namespace Fungus
value = defaultValue;
if (paramList.Count > index)
{
- Single.TryParse(paramList[index], out value);
+ float.TryParse(paramList[index], out value);
return true;
}
return false;
}
- protected virtual IEnumerator ProcessTokens(List tokens, bool stopAudio, Action onComplete)
+ protected virtual IEnumerator ProcessTokens(List tokens, bool stopAudio, System.Action onComplete)
{
// Reset control members
boldActive = false;
italicActive = false;
colorActive = false;
sizeActive = false;
+ WordTokensFound = tokens.Count(x => x.type == TokenType.Words);
+ WordTokensProcessed = 0;
colorText = "";
sizeValue = 16f;
currentPunctuationPause = punctuationPause;
@@ -241,22 +284,25 @@ namespace Fungus
// Notify listeners about new token
WriterSignals.DoTextTagToken(this, token, i, tokens.Count);
-
+
// Update the read ahead string buffer. This contains the text for any
// Word tags which are further ahead in the list.
- readAheadString.Length = 0;
- for (int j = i + 1; j < tokens.Count; ++j)
+ if (doReadAheadText)
{
- var readAheadToken = tokens[j];
-
- if (readAheadToken.type == TokenType.Words &&
- readAheadToken.paramList.Count == 1)
+ readAheadString.Length = 0;
+ for (int j = i + 1; j < tokens.Count; ++j)
{
- readAheadString.Append(readAheadToken.paramList[0]);
- }
- else if (readAheadToken.type == TokenType.WaitForInputAndClear)
- {
- break;
+ var readAheadToken = tokens[j];
+
+ if (readAheadToken.type == TokenType.Words &&
+ readAheadToken.paramList.Count == 1)
+ {
+ readAheadString.Append(readAheadToken.paramList[0]);
+ }
+ else if (readAheadToken.type == TokenType.WaitForInputAndClear)
+ {
+ break;
+ }
}
}
@@ -264,6 +310,7 @@ namespace Fungus
{
case TokenType.Words:
yield return StartCoroutine(DoWords(token.paramList, previousTokenType));
+ WordTokensProcessed++;
break;
case TokenType.BoldStart:
@@ -294,6 +341,18 @@ namespace Fungus
colorActive = false;
break;
+ case TokenType.LinkStart:
+ if (CheckParamCount(token.paramList, 1))
+ {
+ linkActive = true;
+ linkText = token.paramList[0];
+ }
+ break;
+
+ case TokenType.LinkEnd:
+ linkActive = false;
+ break;
+
case TokenType.SizeStart:
if (TryGetSingleParam(token.paramList, 0, 16f, out sizeValue))
{
@@ -495,59 +554,92 @@ namespace Fungus
UpdateCloseMarkup();
float timeAccumulator = Time.deltaTime;
+ float invWritingSpeed = 1f / currentWritingSpeed;
- for (int i = 0; i < param.Length + 1; ++i)
- {
- // Exit immediately if the exit flag has been set
- if (exitFlag)
- {
- break;
- }
-
- // Pause mid sentence if Paused is set
- while (Paused)
- {
- yield return null;
- }
+ //refactor this, its mostly the same 30 lines of code
+ if (textAdapter.SupportsHiddenCharacters())
+ {
+ //pausing for 1 frame means we can get better first data, but is conflicting with animation ?
+ // or is it something else inserting the color alpha invis
+ yield return null;
+ //this works for first thing being shown but then no subsequent, as the char counts have not been update
+ // by tmpro after the set to ""
+ var startingReveal = Mathf.Min(readAheadStartIndex, textAdapter.CharactersToReveal);
+ PartitionString(writeWholeWords, param, param.Length + 1);
- //actually grab the next chars
- PartitionString(writeWholeWords, param, i);
ConcatenateString(startText);
textAdapter.Text = outputString.ToString();
NotifyGlyph();
+ textAdapter.RevealedCharacters = startingReveal;
+ yield return null;
- // No delay if user has clicked and Instant Complete is enabled
- if (instantComplete && inputFlag)
+ while (textAdapter.RevealedCharacters < Mathf.Min(readAheadStartIndex, textAdapter.CharactersToReveal))
{
- continue;
- }
+ // No delay if user has clicked and Instant Complete is enabled
+ if (instantComplete && inputFlag)
+ {
+ textAdapter.RevealedCharacters = textAdapter.CharactersToReveal;
+ }
- // Punctuation pause
- if (leftString.Length > 0 &&
- rightString.Length > 0 &&
- IsPunctuation(leftString.ToString(leftString.Length - 1, 1)[0]))
- {
- yield return StartCoroutine(DoWait(currentPunctuationPause));
+ if (currentWritingSpeed > 0f)
+ {
+ textAdapter.RevealedCharacters++;
+ timeAccumulator -= invWritingSpeed;
+ if (timeAccumulator <= 0f)
+ {
+ var waitTime = Mathf.Max(invWritingSpeed, Time.deltaTime);
+ yield return new WaitForSeconds(waitTime);
+ timeAccumulator += waitTime;
+ }
+ }
}
+ }
+ else
+ {
+ for (int i = 0; i < param.Length + 1; ++i)
+ {
+ if (exitFlag)
+ {
+ break;
+ }
- // Delay between characters
- if (currentWritingSpeed > 0f)
- {
- float invWritingSpeed = 1f / currentWritingSpeed;
+ // Pause mid sentence if Paused is set
+ while (Paused)
+ {
+ yield return null;
+ }
+
+ PartitionString(writeWholeWords, param, i);
+ ConcatenateString(startText);
+ textAdapter.Text = outputString.ToString();
- timeAccumulator -= invWritingSpeed;
- if (timeAccumulator <= 0f)
+ NotifyGlyph();
+
+ // No delay if user has clicked and Instant Complete is enabled
+ if (instantComplete && inputFlag)
{
- if (invWritingSpeed > Time.deltaTime)
- {
- yield return new WaitForSeconds(invWritingSpeed);
- timeAccumulator += invWritingSpeed;
- }
- else
+ continue;
+ }
+
+ // Punctuation pause
+ if (leftString.Length > 0 &&
+ rightString.Length > 0 &&
+ IsPunctuation(leftString.ToString(leftString.Length - 1, 1)[0]))
+ {
+ //timeAccumulator -= currentPunctuationPause; ???
+ yield return StartCoroutine(DoWait(currentPunctuationPause));
+ }
+
+ // Delay between characters
+ if (currentWritingSpeed > 0f)
+ {
+ timeAccumulator -= invWritingSpeed;
+ if (timeAccumulator <= 0f)
{
- yield return null;
- timeAccumulator += Time.deltaTime;
+ var waitTime = Mathf.Max(invWritingSpeed, Time.deltaTime);
+ yield return new WaitForSeconds(waitTime);
+ timeAccumulator += waitTime;
}
}
}
@@ -573,7 +665,7 @@ namespace Fungus
// Look ahead to find next whitespace or end of string
for (int j = i; j < inputString.Length + 1; ++j)
{
- if (j == inputString.Length || Char.IsWhiteSpace(inputString[j]))
+ if (j == inputString.Length || char.IsWhiteSpace(inputString[j]))
{
leftString.Length = j;
rightString.Remove(0, j);
@@ -591,6 +683,7 @@ namespace Fungus
protected virtual void ConcatenateString(string startText)
{
outputString.Length = 0;
+ readAheadStartIndex = int.MaxValue;
// string tempText = startText + openText + leftText + closeText;
outputString.Append(startText);
@@ -612,6 +705,8 @@ namespace Fungus
CacheHiddenColorStrings();
}
+ readAheadStartIndex = outputString.Length;
+
outputString.Append(hiddenColorOpen);
outputString.Append(rightString);
outputString.Append(readAheadString);
@@ -628,7 +723,7 @@ namespace Fungus
}
float duration = 1f;
- if (!Single.TryParse(param, out duration))
+ if (!float.TryParse(param, out duration))
{
duration = 1f;
}
@@ -781,6 +876,15 @@ namespace Fungus
}
}
+ protected virtual void NotifyAllWordsWritten()
+ {
+ for (int i = 0; i < writerListeners.Count; i++)
+ {
+ var writerListener = writerListeners[i];
+ writerListener.OnAllWordsWritten();
+ }
+ }
+
protected virtual void NotifyEnd(bool stopAudio)
{
WriterSignals.DoWriterState(this, WriterState.End);
@@ -841,7 +945,7 @@ namespace Fungus
/// Wait for the Voice over to complete before proceeding
/// Audio clip to play when text starts writing.
/// Callback to call when writing is finished.
- public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, bool waitForVO, AudioClip audioClip, Action onComplete)
+ public virtual IEnumerator Write(string content, bool clear, bool waitForInput, bool stopAudio, bool waitForVO, AudioClip audioClip, System.Action onComplete)
{
if (clear)
{
diff --git a/Assets/Fungus/Scripts/Components/WriterAudio.cs b/Assets/Fungus/Scripts/Components/WriterAudio.cs
index 95c8710d..b5162ca6 100644
--- a/Assets/Fungus/Scripts/Components/WriterAudio.cs
+++ b/Assets/Fungus/Scripts/Components/WriterAudio.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -259,7 +259,11 @@ namespace Fungus
targetAudioSource.clip = voiceOverClip;
targetAudioSource.Play();
}
-
+
+ public void OnAllWordsWritten()
+ {
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs b/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs
new file mode 100644
index 00000000..d1cc7591
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs
@@ -0,0 +1,67 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEditor;
+using UnityEngine;
+
+namespace Fungus.EditorUtils
+{
+ ///
+ /// Custom drawer for the AnyVaraibleAndDataPair, shows only the matching data for the targeted variable
+ /// scripts.
+ ///
+ [CustomPropertyDrawer(typeof(Fungus.AnyVariableAndDataPair))]
+ public class AnyVariableAndDataPairDrawer : PropertyDrawer
+ {
+ public Fungus.Flowchart lastFlowchart;
+
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ position.height = EditorGUIUtility.singleLineHeight;
+
+ var varProp = property.FindPropertyRelative("variable");
+
+ EditorGUI.PropertyField(position, varProp, label);
+
+ position.y += EditorGUIUtility.singleLineHeight;
+
+ if (varProp.objectReferenceValue != null)
+ {
+ var varPropType = varProp.objectReferenceValue.GetType();
+
+ var typeActionsRes = AnyVariableAndDataPair.typeActionLookup[varPropType];
+
+ if (typeActionsRes != null)
+ {
+ var targetName = "data." + typeActionsRes.DataPropName;
+ var dataProp = property.FindPropertyRelative(targetName);
+ if (dataProp != null)
+ {
+ EditorGUI.PropertyField(position, dataProp, new GUIContent("Data", "Data to use in pair with the above variable."));
+ }
+ else
+ {
+ EditorGUI.LabelField(position, "Cound not find property in AnyVariableData of name " + targetName);
+ }
+ }
+ else
+ {
+ //no matching data type, oops
+ EditorGUI.LabelField(position, "Cound not find property in AnyVariableData of type " + varPropType.Name);
+ }
+ }
+ else
+ {
+ //no var selected
+ EditorGUI.LabelField(position, "Must select a variable before setting data.");
+ }
+
+ property.serializedObject.ApplyModifiedProperties();
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ return EditorGUIUtility.singleLineHeight * 2;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs.meta
new file mode 100644
index 00000000..9cd14666
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/AnyVariableAndDataPairDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5a3b2252ee10d3b45ad82e7e7dde5ccd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/AssetModProcessor.cs b/Assets/Fungus/Scripts/Editor/AssetModProcessor.cs
index 1d2e7d41..905b0f36 100644
--- a/Assets/Fungus/Scripts/Editor/AssetModProcessor.cs
+++ b/Assets/Fungus/Scripts/Editor/AssetModProcessor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using System.IO;
diff --git a/Assets/Fungus/Scripts/Editor/BasePopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/BasePopupWindowContent.cs
index 5bf7406e..54ca4116 100644
--- a/Assets/Fungus/Scripts/Editor/BasePopupWindowContent.cs
+++ b/Assets/Fungus/Scripts/Editor/BasePopupWindowContent.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEditor;
using UnityEngine;
using System;
diff --git a/Assets/Fungus/Scripts/Editor/BlockEditor.cs b/Assets/Fungus/Scripts/Editor/BlockEditor.cs
index 04e178b0..38119cdb 100644
--- a/Assets/Fungus/Scripts/Editor/BlockEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/BlockEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
@@ -8,8 +8,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
-using System.Text.RegularExpressions;
-using System.IO;
using System.Reflection;
namespace Fungus.EditorUtils
@@ -456,6 +454,8 @@ namespace Fungus.EditorUtils
int selectedIndex = 0;
blockNames.Add(nullLabel);
var blocks = flowchart.GetComponents();
+ blocks = blocks.OrderBy(x => x.BlockName).ToArray();
+
for (int i = 0; i < blocks.Length; ++i)
{
blockNames.Add(new GUIContent(blocks[i].BlockName));
@@ -494,6 +494,8 @@ namespace Fungus.EditorUtils
int selectedIndex = 0;
blockNames.Add(nullLabel);
Block[] blocks = flowchart.GetComponents();
+ blocks = blocks.OrderBy(x => x.BlockName).ToArray();
+
for (int i = 0; i < blocks.Length; ++i)
{
blockNames.Add(new GUIContent(blocks[i].BlockName));
@@ -517,187 +519,6 @@ namespace Fungus.EditorUtils
return result;
}
- [MenuItem("Tools/Fungus/Utilities/Export Reference Docs")]
- protected static void ExportReferenceDocs()
- {
- const string path = "./Docs";
-
- ExportCommandInfo(path);
- ExportEventHandlerInfo(path);
-
- FlowchartWindow.ShowNotification("Exported Reference Documentation");
- }
-
- public static List> GetFilteredCommandInfoAttribute(List menuTypes)
- {
- Dictionary> filteredAttributes = new Dictionary>();
-
- foreach (System.Type type in menuTypes)
- {
- object[] attributes = type.GetCustomAttributes(false);
- foreach (object obj in attributes)
- {
- CommandInfoAttribute infoAttr = obj as CommandInfoAttribute;
- if (infoAttr != null)
- {
- string dictionaryName = string.Format("{0}/{1}", infoAttr.Category, infoAttr.CommandName);
-
- int existingItemPriority = -1;
- if (filteredAttributes.ContainsKey(dictionaryName))
- {
- existingItemPriority = filteredAttributes[dictionaryName].Value.Priority;
- }
-
- if (infoAttr.Priority > existingItemPriority)
- {
- KeyValuePair keyValuePair = new KeyValuePair(type, infoAttr);
- filteredAttributes[dictionaryName] = keyValuePair;
- }
- }
- }
- }
- return filteredAttributes.Values.ToList>();
- }
-
-
- // Compare delegate for sorting the list of command attributes
- public static int CompareCommandAttributes(KeyValuePair x, KeyValuePair y)
- {
- int compare = (x.Value.Category.CompareTo(y.Value.Category));
- if (compare == 0)
- {
- compare = (x.Value.CommandName.CompareTo(y.Value.CommandName));
- }
- return compare;
- }
-
- protected static void ExportCommandInfo(string path)
- {
- // Dump command info
- List menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList();
- List> filteredAttributes = GetFilteredCommandInfoAttribute(menuTypes);
- filteredAttributes.Sort(CompareCommandAttributes);
-
- // Build list of command categories
- List commandCategories = new List();
- foreach (var keyPair in filteredAttributes)
- {
- CommandInfoAttribute info = keyPair.Value;
- if (info.Category != "" &&
- !commandCategories.Contains(info.Category))
- {
- commandCategories.Add(info.Category);
- }
- }
- commandCategories.Sort();
-
- // Output the commands in each category
- foreach (string category in commandCategories)
- {
- string markdown = "# " + category + " commands # {#" + category.ToLower() + "_commands}\n\n";
- markdown += "[TOC]\n";
-
- foreach (var keyPair in filteredAttributes)
- {
- CommandInfoAttribute info = keyPair.Value;
-
- if (info.Category == category ||
- info.Category == "" && category == "Scripting")
- {
- markdown += "# " + info.CommandName + " # {#" + info.CommandName.Replace(" ", "") + "}\n";
- markdown += info.HelpText + "\n\n";
- markdown += "Defined in " + keyPair.Key.FullName + "\n";
- markdown += GetPropertyInfo(keyPair.Key);
- }
- }
-
- string filePath = path + "/command_ref/" + category.ToLower() + "_commands.md";
-
- Directory.CreateDirectory(Path.GetDirectoryName(filePath));
- File.WriteAllText(filePath, markdown);
- }
- }
-
- protected static void ExportEventHandlerInfo(string path)
- {
- List eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList();
- List eventHandlerCategories = new List();
- eventHandlerCategories.Add("Core");
- foreach (System.Type type in eventHandlerTypes)
- {
- EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
- if (info != null &&
- info.Category != "" &&
- !eventHandlerCategories.Contains(info.Category))
- {
- eventHandlerCategories.Add(info.Category);
- }
- }
- eventHandlerCategories.Sort();
-
- // Output the commands in each category
- foreach (string category in eventHandlerCategories)
- {
- string markdown = "# " + category + " event handlers # {#" + category.ToLower() + "_events}\n\n";
- markdown += "[TOC]\n";
-
- foreach (System.Type type in eventHandlerTypes)
- {
- EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
-
- if (info != null &&
- (info.Category == category ||
- (info.Category == "" && category == "Core")))
- {
- markdown += "# " + info.EventHandlerName + " # {#" + info.EventHandlerName.Replace(" ", "") + "}\n";
- markdown += info.HelpText + "\n\n";
- markdown += "Defined in " + type.FullName + "\n";
- markdown += GetPropertyInfo(type);
- }
- }
-
- string filePath = path + "/command_ref/" + category.ToLower() + "_events.md";
-
- Directory.CreateDirectory(Path.GetDirectoryName(filePath));
- File.WriteAllText(filePath, markdown);
- }
- }
-
- protected static string GetPropertyInfo(System.Type type)
- {
- string markdown = "";
- foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
- {
- TooltipAttribute attribute = (TooltipAttribute)Attribute.GetCustomAttribute(field, typeof(TooltipAttribute));
- if (attribute == null)
- {
- continue;
- }
-
- // Change field name to how it's displayed in the inspector
- string propertyName = Regex.Replace(field.Name, "(\\B[A-Z])", " $1");
- if (propertyName.Length > 1)
- {
- propertyName = propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1);
- }
- else
- {
- propertyName = propertyName.ToUpper();
- }
-
- markdown += propertyName + " | " + field.FieldType + " | " + attribute.tooltip + "\n";
- }
-
- if (markdown.Length > 0)
- {
- markdown = "\nProperty | Type | Description\n --- | --- | ---\n" + markdown + "\n";
- }
-
- return markdown;
- }
-
-
-
public virtual void ShowContextMenu()
{
var block = target as Block;
@@ -1083,5 +904,49 @@ namespace Fungus.EditorUtils
Repaint();
}
+
+
+
+ public static List> GetFilteredCommandInfoAttribute(List menuTypes)
+ {
+ Dictionary> filteredAttributes = new Dictionary>();
+
+ foreach (System.Type type in menuTypes)
+ {
+ object[] attributes = type.GetCustomAttributes(false);
+ foreach (object obj in attributes)
+ {
+ CommandInfoAttribute infoAttr = obj as CommandInfoAttribute;
+ if (infoAttr != null)
+ {
+ string dictionaryName = string.Format("{0}/{1}", infoAttr.Category, infoAttr.CommandName);
+
+ int existingItemPriority = -1;
+ if (filteredAttributes.ContainsKey(dictionaryName))
+ {
+ existingItemPriority = filteredAttributes[dictionaryName].Value.Priority;
+ }
+
+ if (infoAttr.Priority > existingItemPriority)
+ {
+ KeyValuePair keyValuePair = new KeyValuePair(type, infoAttr);
+ filteredAttributes[dictionaryName] = keyValuePair;
+ }
+ }
+ }
+ }
+ return filteredAttributes.Values.ToList>();
+ }
+
+ // Compare delegate for sorting the list of command attributes
+ public static int CompareCommandAttributes(KeyValuePair x, KeyValuePair y)
+ {
+ int compare = (x.Value.Category.CompareTo(y.Value.Category));
+ if (compare == 0)
+ {
+ compare = (x.Value.CommandName.CompareTo(y.Value.CommandName));
+ }
+ return compare;
+ }
}
}
diff --git a/Assets/Fungus/Scripts/Editor/BlockInspector.cs b/Assets/Fungus/Scripts/Editor/BlockInspector.cs
index cacc1d0f..cab86d00 100644
--- a/Assets/Fungus/Scripts/Editor/BlockInspector.cs
+++ b/Assets/Fungus/Scripts/Editor/BlockInspector.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Editor/BlockReferenceDrawer.cs b/Assets/Fungus/Scripts/Editor/BlockReferenceDrawer.cs
index 71e020d4..0f1caf2c 100644
--- a/Assets/Fungus/Scripts/Editor/BlockReferenceDrawer.cs
+++ b/Assets/Fungus/Scripts/Editor/BlockReferenceDrawer.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/CallEditor.cs b/Assets/Fungus/Scripts/Editor/CallEditor.cs
index c4e0ca8f..96836549 100644
--- a/Assets/Fungus/Scripts/Editor/CallEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/CallEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/CameraMenuItems.cs b/Assets/Fungus/Scripts/Editor/CameraMenuItems.cs
index 84671063..71527688 100644
--- a/Assets/Fungus/Scripts/Editor/CameraMenuItems.cs
+++ b/Assets/Fungus/Scripts/Editor/CameraMenuItems.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Editor/CharacterEditor.cs b/Assets/Fungus/Scripts/Editor/CharacterEditor.cs
index 057692be..b2b82f9f 100644
--- a/Assets/Fungus/Scripts/Editor/CharacterEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/CharacterEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/CommandEditor.cs b/Assets/Fungus/Scripts/Editor/CommandEditor.cs
index 24a07648..15ea72b9 100644
--- a/Assets/Fungus/Scripts/Editor/CommandEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/CommandEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs
index 7ad1eb71..5c0a7f5d 100644
--- a/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs
+++ b/Assets/Fungus/Scripts/Editor/CommandListAdaptor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -24,8 +24,9 @@ namespace Fungus.EditorUtils
if (commandLabelStyle == null)
{
- commandLabelStyle = new GUIStyle(GUI.skin.box);
+ commandLabelStyle = new GUIStyle(GUI.skin.label);
commandLabelStyle.normal.background = FungusEditorResources.CommandBackground;
+ commandLabelStyle.normal.textColor = Color.black;
int borderSize = 5;
commandLabelStyle.border.top = borderSize;
commandLabelStyle.border.bottom = borderSize;
diff --git a/Assets/Fungus/Scripts/Editor/ControlAudioEditor.cs b/Assets/Fungus/Scripts/Editor/ControlAudioEditor.cs
index 489bc86b..dac3b79a 100644
--- a/Assets/Fungus/Scripts/Editor/ControlAudioEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/ControlAudioEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/CustomGUI.cs b/Assets/Fungus/Scripts/Editor/CustomGUI.cs
index 89a489bd..10ffa73d 100644
--- a/Assets/Fungus/Scripts/Editor/CustomGUI.cs
+++ b/Assets/Fungus/Scripts/Editor/CustomGUI.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs b/Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs
new file mode 100644
index 00000000..1cbb0682
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs
@@ -0,0 +1,59 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEngine;
+
+namespace Fungus.EditorUtils
+{
+ ///
+ /// Fungus Variables are drawn via EditorGUI.Property by default, however, some types may require a custom replacement.
+ /// The most common example is a Quaternion, Unity does not show you a quaternion as 4 floats, it shows you
+ /// the euler angles, we also want to do that here
+ ///
+ /// This class is delegated to by editors to draw the actual variable property line.
+ ///
+ public static class CustomVariableDrawerLookup
+ {
+ //If you create new types that require custom singleline drawers, add them here
+ public static Dictionary> typeToDrawer =
+ new Dictionary>()
+ {
+ {
+ typeof(QuaternionVariable),
+ (rect, valueProp) => {valueProp.quaternionValue = UnityEngine.Quaternion.Euler(UnityEditor.EditorGUI.Vector3Field(rect, new UnityEngine.GUIContent(""), valueProp.quaternionValue.eulerAngles)); }
+ },
+ {
+ typeof(Vector4Variable),
+ (rect, valueProp) => {valueProp.vector4Value = UnityEditor.EditorGUI.Vector4Field(rect, new UnityEngine.GUIContent(""), valueProp.vector4Value); }
+ },
+ };
+
+ public static bool GetDrawer(System.Type type, out System.Action drawer)
+ {
+ return typeToDrawer.TryGetValue(type, out drawer);
+ }
+
+ ///
+ /// Called by editors that want a single line variable property drawn
+ ///
+ ///
+ ///
+ ///
+ public static void DrawCustomOrPropertyField(System.Type type, Rect rect, SerializedProperty prop)
+ {
+ System.Action drawer = null;
+ //delegate actual drawing to the variableInfo
+ var foundDrawer = typeToDrawer.TryGetValue(type, out drawer);
+ if (foundDrawer)
+ {
+ drawer(rect, prop);
+ }
+ else
+ {
+ EditorGUI.PropertyField(rect, prop, new GUIContent(""));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs.meta b/Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs.meta
new file mode 100644
index 00000000..ad272a5d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ce09adfbce8ccde4db2fa5371897b2b0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/DialogInputEditor.cs b/Assets/Fungus/Scripts/Editor/DialogInputEditor.cs
index 78abf0ce..56dabbe8 100644
--- a/Assets/Fungus/Scripts/Editor/DialogInputEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/DialogInputEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
namespace Fungus.EditorUtils
diff --git a/Assets/Fungus/Scripts/Editor/EditorExtensions.cs b/Assets/Fungus/Scripts/Editor/EditorExtensions.cs
index a1968ee5..4a3c9279 100644
--- a/Assets/Fungus/Scripts/Editor/EditorExtensions.cs
+++ b/Assets/Fungus/Scripts/Editor/EditorExtensions.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Editor/EditorZoomArea.cs b/Assets/Fungus/Scripts/Editor/EditorZoomArea.cs
index 7acbceb4..1a9155ce 100644
--- a/Assets/Fungus/Scripts/Editor/EditorZoomArea.cs
+++ b/Assets/Fungus/Scripts/Editor/EditorZoomArea.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
// Original code by Martin Ecker (http://martinecker.com)
@@ -52,6 +52,22 @@ namespace Fungus.EditorUtils
result.y += pivotPoint.y;
return result;
}
+
+ public static Rect SnapPosition(this Rect rect, float snapInterval)
+ {
+ var tmp = rect;
+ var x = tmp.position.x;
+ var y = tmp.position.y;
+ tmp.position = new Vector2(Mathf.RoundToInt(x / snapInterval) * snapInterval, Mathf.RoundToInt(y / snapInterval) * snapInterval);
+ return tmp;
+ }
+
+ public static Rect SnapWidth(this Rect rect, float snapInterval)
+ {
+ var tmp = rect;
+ tmp.width = Mathf.RoundToInt(tmp.width / snapInterval) * snapInterval;
+ return tmp;
+ }
}
public class EditorZoomArea
diff --git a/Assets/Fungus/Scripts/Editor/EnumFlagDrawer.cs b/Assets/Fungus/Scripts/Editor/EnumFlagDrawer.cs
index 28e1fb7f..d3d80847 100644
--- a/Assets/Fungus/Scripts/Editor/EnumFlagDrawer.cs
+++ b/Assets/Fungus/Scripts/Editor/EnumFlagDrawer.cs
@@ -1,5 +1,7 @@
-//from http://wiki.unity3d.com/index.php/EnumFlagPropertyDrawer
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+// Adapated from http://wiki.unity3d.com/index.php/EnumFlagPropertyDrawer
//placed in fungus namespace to avoid collisions with your own
using System;
diff --git a/Assets/Fungus/Scripts/Editor/EventHandlerEditor.cs b/Assets/Fungus/Scripts/Editor/EventHandlerEditor.cs
index 7bd49673..ef475059 100644
--- a/Assets/Fungus/Scripts/Editor/EventHandlerEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/EventHandlerEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/EventWindow.cs b/Assets/Fungus/Scripts/Editor/EventWindow.cs
index 774670d7..bd14c239 100644
--- a/Assets/Fungus/Scripts/Editor/EventWindow.cs
+++ b/Assets/Fungus/Scripts/Editor/EventWindow.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
// Adapted from: https://github.com/thecodejunkie/unity.resources/blob/master/scripts/editor/ExtendedEditorWindow.cs
diff --git a/Assets/Fungus/Scripts/Editor/ExportReferenceDocs.cs b/Assets/Fungus/Scripts/Editor/ExportReferenceDocs.cs
new file mode 100644
index 00000000..a7349be8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/ExportReferenceDocs.cs
@@ -0,0 +1,226 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using UnityEditor;
+using UnityEngine;
+
+namespace Fungus.EditorUtils
+{
+ ///
+ /// Helper functions for generating the markdown files for Fungus Commands and Events.
+ ///
+ public static class ExportReferenceDocs
+ {
+ private const string CommandRefDocPath = BaseDocPath + "command_ref/";
+ private const string BaseDocPath = "./Docs/";
+
+ [MenuItem("Tools/Fungus/Utilities/Export Reference Docs")]
+ public static void Export()
+ {
+ ExportCommandInfo();
+ ExportEventHandlerInfo();
+
+ FlowchartWindow.ShowNotification("Exported Reference Documentation");
+ }
+
+ private static void ExportCommandInfo()
+ {
+ // Dump command info
+ List menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList();
+ List> filteredAttributes = BlockEditor.GetFilteredCommandInfoAttribute(menuTypes);
+ filteredAttributes.Sort(BlockEditor.CompareCommandAttributes);
+
+ // Build list of command categories
+ List commandCategories = new List();
+ foreach (var keyPair in filteredAttributes)
+ {
+ CommandInfoAttribute info = keyPair.Value;
+ if (info.Category != "" &&
+ !commandCategories.Contains(info.Category))
+ {
+ commandCategories.Add(info.Category);
+ }
+ }
+ commandCategories.Sort();
+
+ var sb = new System.Text.StringBuilder(@"# Command Reference
+
+This is the reference documentation for all Fungus commands.
+
+");
+ // Output the commands in each category
+ foreach (string category in commandCategories)
+ {
+ string markdown = "# " + category + " commands # {#" + category.ToLower() + "_commands}\n\n";
+ markdown += "[TOC]\n";
+
+ foreach (var keyPair in filteredAttributes)
+ {
+ CommandInfoAttribute info = keyPair.Value;
+
+ if (info.Category == category ||
+ info.Category == "" && category == "Scripting")
+ {
+ markdown += "# " + info.CommandName + " # {#" + info.CommandName.Replace(" ", "") + "}\n";
+ markdown += info.HelpText + "\n\n";
+ markdown += "Defined in " + keyPair.Key.FullName + "\n";
+ markdown += GetPropertyInfo(keyPair.Key);
+ }
+ }
+
+ WriteFile(markdown, CommandRefDocPath, category.ToLower(), "_commands.md");
+ sb.Append("* [").Append(category).Append("](").Append(category.ToLower()).AppendLine("_commands)");
+ }
+
+ sb.AppendLine();
+ WriteFile(sb.ToString(), BaseDocPath, "", "command_reference.md");
+ }
+
+ private static void ExportEventHandlerInfo()
+ {
+ List eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList();
+ List eventHandlerCategories = new List();
+ eventHandlerCategories.Add("Core");
+ foreach (System.Type type in eventHandlerTypes)
+ {
+ EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
+ if (info != null &&
+ info.Category != "" &&
+ !eventHandlerCategories.Contains(info.Category))
+ {
+ eventHandlerCategories.Add(info.Category);
+ }
+ }
+ eventHandlerCategories.Sort();
+
+ var sb = new System.Text.StringBuilder(@"# Event Handler Reference {#eventhandler_reference}
+
+This is the reference documentation for all Fungus event handlers.
+
+");
+
+ // Output the commands in each category
+ foreach (string category in eventHandlerCategories)
+ {
+ string markdown = "# " + category + " event handlers # {#" + category.ToLower() + "_events}\n\n";
+ markdown += "[TOC]\n";
+
+ foreach (System.Type type in eventHandlerTypes)
+ {
+ EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
+
+ if (info != null &&
+ (info.Category == category ||
+ (info.Category == "" && category == "Core")))
+ {
+ markdown += "# " + info.EventHandlerName + " # {#" + info.EventHandlerName.Replace(" ", "") + "}\n";
+ markdown += info.HelpText + "\n\n";
+ markdown += "Defined in " + type.FullName + "\n";
+ markdown += GetPropertyInfo(type);
+ }
+ }
+
+ WriteFile(markdown, CommandRefDocPath, category.ToLower(), "_events.md");
+ sb.Append("* [").Append(category).Append("](").Append(category.ToLower()).AppendLine("_events)");
+ }
+
+ sb.AppendLine();
+ WriteFile(sb.ToString(), BaseDocPath, "", "eventhandler_reference.md");
+ }
+
+ private static void WriteFile(string markdown, string path, string category, string suffix)
+ {
+ markdown += "Auto-Generated by Fungus.ExportReferenceDocs";
+
+ string filePath = path + category.ToLower() + suffix;
+
+ Directory.CreateDirectory(Path.GetDirectoryName(filePath));
+ File.WriteAllText(filePath, markdown);
+ }
+
+ private static string GetPropertyInfo(System.Type type)
+ {
+ string markdown = "";
+ foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
+ {
+ TooltipAttribute attribute = (TooltipAttribute)Attribute.GetCustomAttribute(field, typeof(TooltipAttribute));
+ if (attribute == null)
+ {
+ continue;
+ }
+
+ // Change field name to how it's displayed in the inspector
+ string propertyName = Regex.Replace(field.Name, "(\\B[A-Z])", " $1");
+ if (propertyName.Length > 1)
+ {
+ propertyName = propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1);
+ }
+ else
+ {
+ propertyName = propertyName.ToUpper();
+ }
+
+ markdown += propertyName + " | " + field.FieldType + " | " + attribute.tooltip + "\n";
+ }
+
+ if (markdown.Length > 0)
+ {
+ markdown = "\nProperty | Type | Description\n --- | --- | ---\n" + markdown + "\n";
+ }
+
+ return markdown;
+ }
+
+ [MenuItem("Tools/Fungus/Utilities/Convert Docs to GitHub MD")]
+ public static void ConvertAllToGHMD()
+ {
+ var files = Directory.GetFiles(BaseDocPath, "*.md", SearchOption.AllDirectories);
+ foreach (var file in files)
+ {
+ ConvertFileToGHMD(file);
+ }
+
+ FlowchartWindow.ShowNotification("Converted " + files.Length.ToString() + " to Github MD");
+ }
+
+ //strips anchor links and TOC, which are not supported on Github wiki mds
+ private static void ConvertFileToGHMD(string fileLoc)
+ {
+ var sb = new System.Text.StringBuilder();
+ var lines = File.ReadAllLines(fileLoc);
+
+ foreach (var line in lines)
+ {
+ if (line.Length > 0 && line[0] == '#')
+ {
+ var secondToken = line.IndexOf(" # ");
+ if (secondToken != -1)
+ {
+ var heading = line.Substring(0, secondToken);
+ sb.AppendLine(heading);
+ }
+ else
+ {
+ sb.AppendLine(line);
+ }
+ }
+ else if (line == "[TOC]")
+ {
+ //skip
+ }
+ else
+ {
+ sb.AppendLine(line);
+ }
+ }
+
+ File.WriteAllText(fileLoc, sb.ToString());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/ExportReferenceDocs.cs.meta b/Assets/Fungus/Scripts/Editor/ExportReferenceDocs.cs.meta
new file mode 100644
index 00000000..74e709f7
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/ExportReferenceDocs.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ae5ffaf325414b049a5c31ab9b9bb22d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs
index f9566f21..d286f611 100644
--- a/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/FlowchartEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs b/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs
index acd4cc73..c05beec5 100644
--- a/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs
+++ b/Assets/Fungus/Scripts/Editor/FlowchartMenuItems.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
index 985fd3ff..c746557f 100644
--- a/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
+++ b/Assets/Fungus/Scripts/Editor/FlowchartWindow.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -172,12 +172,29 @@ namespace Fungus.EditorUtils
}
}
+
+
+ public const float GridLineSpacingSize = 120;
+ public const float GridObjectSnap = 20;
+ public const float DefaultBlockHeight = 40;
+ public const float BlockMinWidth = 60;
+ public const float BlockMaxWidth = 240;
+ public const float MinZoomValue = 0.25f;
+ public const float MaxZoomValue = 1f;
+ public const int HorizontalPad = 20;
+ public const int VerticalPad = 5;
+ //defines the distance between a down and up for a right click to be a click rather than a drag
+ public const float RightClickTolerance = 5f;
+ public const string SearchFieldName = "search";
+
+
+ protected readonly Color connectionColor = new Color(0.65f, 0.65f, 0.65f, 1.0f);
+
+
protected List copyList = new List();
public static List deleteList = new List();
protected Vector2 startDragPosition;
- public const float minZoomValue = 0.25f;
- public const float maxZoomValue = 1f;
- protected GUIStyle nodeStyle = new GUIStyle();
+ protected GUIStyle nodeStyle, descriptionStyle, handlerStyle, blockSearchPopupNormalStyle, blockSearchPopupSelectedStyle;
protected static BlockInspector blockInspector;
protected int forceRepaintCount;
protected Texture2D addTexture;
@@ -187,16 +204,13 @@ namespace Fungus.EditorUtils
protected Vector2 startSelectionBoxPosition = -Vector2.one;
protected List mouseDownSelectionState = new List();
protected Color gridLineColor = Color.black;
- protected readonly Color connectionColor = new Color(0.65f, 0.65f, 0.65f, 1.0f);
// Context Click occurs on MouseDown which interferes with panning
// Track right click positions manually to show menus on MouseUp
protected Vector2 rightClickDown = -Vector2.one;
- protected const float rightClickTolerance = 5f;
- protected const string searchFieldName = "search";
private string searchString = string.Empty;
protected Rect searchRect;
protected Rect popupRect;
- protected Block[] filteredBlocks = new Block[0];
+ protected List filteredBlocks = new List();
protected int blockPopupSelection = -1;
protected Vector2 popupScroll;
protected Flowchart flowchart, prevFlowchart;
@@ -224,6 +238,8 @@ namespace Fungus.EditorUtils
}
}
private GUIStyle toolbarSeachCancelButtonStyle;
+ private bool didDoubleClick;
+
protected GUIStyle ToolbarSeachCancelButtonStyle
{
get
@@ -243,13 +259,6 @@ namespace Fungus.EditorUtils
protected virtual void OnEnable()
{
- // All block nodes use the same GUIStyle, but with a different background
- nodeStyle.border = new RectOffset(20, 20, 5, 5);
- nodeStyle.padding = nodeStyle.border;
- nodeStyle.contentOffset = Vector2.zero;
- nodeStyle.alignment = TextAnchor.MiddleCenter;
- nodeStyle.wordWrap = true;
-
addTexture = FungusEditorResources.AddSmall;
addButtonContent = new GUIContent(addTexture, "Add a new block");
connectionPointTexture = FungusEditorResources.ConnectionPoint;
@@ -270,6 +279,47 @@ namespace Fungus.EditorUtils
#endif
}
+ //cache styles here, rather than duping them for every block we may ever draw,
+ // does mean any modifications made to the style when drawing must be undone as you go
+ protected void InitStyles()
+ {
+ if (nodeStyle == null)
+ {
+ nodeStyle = new GUIStyle();
+ // All block nodes use the same GUIStyle, but with a different background
+ nodeStyle.border = new RectOffset(HorizontalPad, HorizontalPad, VerticalPad, VerticalPad);
+ nodeStyle.padding = nodeStyle.border;
+ nodeStyle.contentOffset = Vector2.zero;
+ nodeStyle.alignment = TextAnchor.MiddleCenter;
+ nodeStyle.wordWrap = true;
+ }
+
+ if (EditorStyles.helpBox != null && descriptionStyle == null)
+ {
+ descriptionStyle = new GUIStyle(EditorStyles.helpBox);
+ descriptionStyle.wordWrap = true;
+ }
+
+ if (EditorStyles.whiteLabel != null && handlerStyle == null)
+ {
+ handlerStyle = new GUIStyle(EditorStyles.whiteLabel);
+ handlerStyle.wordWrap = true;
+ handlerStyle.margin.top = 0;
+ handlerStyle.margin.bottom = 0;
+ handlerStyle.alignment = TextAnchor.MiddleCenter;
+ }
+
+ if(blockSearchPopupNormalStyle == null || blockSearchPopupSelectedStyle == null)
+ {
+ blockSearchPopupNormalStyle = new GUIStyle(GUI.skin.FindStyle("MenuItem"));
+ blockSearchPopupNormalStyle.padding = new RectOffset(8, 0, 0, 0);
+ blockSearchPopupNormalStyle.imagePosition = ImagePosition.ImageLeft;
+ blockSearchPopupSelectedStyle = new GUIStyle(blockSearchPopupNormalStyle);
+ blockSearchPopupSelectedStyle.normal = blockSearchPopupSelectedStyle.hover;
+ blockSearchPopupNormalStyle.hover = blockSearchPopupNormalStyle.normal;
+ }
+ }
+
protected virtual void OnDisable()
{
EditorApplication.update -= OnEditorUpdate;
@@ -353,7 +403,7 @@ namespace Fungus.EditorUtils
if (flowchart == null)
{
blocks = new Block[0];
- filteredBlocks = new Block[0];
+ filteredBlocks = new List();
}
else
{
@@ -470,30 +520,41 @@ namespace Fungus.EditorUtils
{
filterStale = false;
//reset all
- for (int i = 0; filteredBlocks != null && i < filteredBlocks.Length; i++)
+ for (int i = 0; filteredBlocks != null && i < filteredBlocks.Count; i++)
{
if (filteredBlocks[i] != null)
{
- filteredBlocks[i].IsFiltered = false;
+ filteredBlocks[i].FilterState = Block.FilteredState.None;
}
}
var nullCount = filteredBlocks.Count(x => x == null);
- if (nullCount > 0 && nullCount != filteredBlocks.Length)
+ if (nullCount > 0 && nullCount != filteredBlocks.Count)
{
Debug.LogWarning("Null block found in filteredBlocks. May be a symptom of an underlying issue");
}
- //gather new
- filteredBlocks = blocks.Where(block => IsBlockNameMatch(block) || IsCommandContentMatch(block)).ToArray();
-
- //update filteredness
- foreach (var item in filteredBlocks)
+ filteredBlocks.Clear();
+
+ for (int i = 0; i < blocks.Length; i++)
{
- item.IsFiltered = true;
+ var item = blocks[i];
+ if (item != null)
+ {
+ if(IsBlockNameMatch(item))
+ {
+ filteredBlocks.Add(item);
+ item.FilterState = Block.FilteredState.Full;
+ }
+ else if (IsCommandContentMatch(item))
+ {
+ filteredBlocks.Add(item);
+ item.FilterState = Block.FilteredState.Partial;
+ }
+ }
}
- blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Length - 1);
+ blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Count - 1);
}
}
@@ -528,7 +589,7 @@ namespace Fungus.EditorUtils
break;
case EventType.KeyDown:
- if (GUI.GetNameOfFocusedControl() == searchFieldName)
+ if (GUI.GetNameOfFocusedControl() == SearchFieldName)
{
var centerBlock = false;
var selectBlock = false;
@@ -562,9 +623,9 @@ namespace Fungus.EditorUtils
break;
}
- blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Length - 1);
+ blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Count - 1);
- if (centerBlock && filteredBlocks.Length > 0)
+ if (centerBlock && filteredBlocks.Count > 0)
{
var block = filteredBlocks[blockPopupSelection];
CenterBlock(block);
@@ -682,11 +743,11 @@ namespace Fungus.EditorUtils
//attempt to defilter previous, if due to scene change these will be null
// the regular filter updates will still occur within UpdateBlockCollection
- for (int i = 0; i < filteredBlocks.Length; i++)
+ for (int i = 0; i < filteredBlocks.Count; i++)
{
if (filteredBlocks[i] != null)
{
- filteredBlocks[i].IsFiltered = false;
+ filteredBlocks[i].FilterState = Block.FilteredState.None;
}
}
@@ -713,6 +774,8 @@ namespace Fungus.EditorUtils
return;
}
+ InitStyles();
+
DeleteBlocks();
UpdateFilteredBlocks();
@@ -785,7 +848,7 @@ namespace Fungus.EditorUtils
// Draw scale bar and labels
GUILayout.Label("Scale", EditorStyles.miniLabel);
var newZoom = GUILayout.HorizontalSlider(
- flowchart.Zoom, minZoomValue, maxZoomValue, GUILayout.MinWidth(40), GUILayout.MaxWidth(100)
+ flowchart.Zoom, MinZoomValue, MaxZoomValue, GUILayout.MinWidth(40), GUILayout.MaxWidth(100)
);
GUILayout.Label(flowchart.Zoom.ToString("0.0#x"), EditorStyles.miniLabel, GUILayout.Width(30));
@@ -803,13 +866,14 @@ namespace Fungus.EditorUtils
GUILayout.FlexibleSpace();
// Draw search bar
- GUI.SetNextControlName(searchFieldName);
+ GUI.SetNextControlName(SearchFieldName);
var newString = EditorGUILayout.TextField(searchString, ToolbarSeachTextFieldStyle, GUILayout.Width(150));
if (newString != searchString)
{
searchString = newString;
filterStale = true;
}
+ GUI.SetNextControlName(string.Empty);
if (e.type == EventType.Repaint)
{
@@ -817,7 +881,7 @@ namespace Fungus.EditorUtils
popupRect = searchRect;
popupRect.width += 12;
popupRect.y += popupRect.height;
- popupRect.height = Mathf.Min(filteredBlocks.Length * 16, position.height - 22);
+ popupRect.height = Mathf.Min(Mathf.Max(1,filteredBlocks.Count) * 16, position.height - 22);
}
if (GUILayout.Button("", ToolbarSeachCancelButtonStyle))
@@ -855,14 +919,15 @@ namespace Fungus.EditorUtils
GUILayout.EndVertical();
}
GUILayout.EndHorizontal();
- DrawVariablesBlock(e);
// Draw block search popup on top of other controls
- if (GUI.GetNameOfFocusedControl() == searchFieldName && filteredBlocks.Length > 0)
+ if (!string.IsNullOrEmpty(searchString))
{
DrawBlockPopup(e);
}
+
+ DrawVariablesBlock(e);
}
protected virtual void DrawVariablesBlock(Event e)
@@ -926,7 +991,7 @@ namespace Fungus.EditorUtils
protected virtual void DrawBlockPopup(Event e)
{
- blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, filteredBlocks.Length - 1);
+ blockPopupSelection = Mathf.Clamp(blockPopupSelection, 0, Mathf.Max(filteredBlocks.Count - 1,0));
GUI.Box(popupRect, "", GUI.skin.FindStyle("sv_iconselector_back"));
@@ -945,48 +1010,50 @@ namespace Fungus.EditorUtils
{
popupScroll = EditorGUILayout.BeginScrollView(popupScroll, GUIStyle.none, GUI.skin.verticalScrollbar);
{
- var normalStyle = new GUIStyle(GUI.skin.FindStyle("MenuItem"));
- normalStyle.padding = new RectOffset(8, 0, 0, 0);
- normalStyle.imagePosition = ImagePosition.ImageLeft;
- var selectedStyle = new GUIStyle(normalStyle);
- selectedStyle.normal = selectedStyle.hover;
- normalStyle.hover = normalStyle.normal;
+ for (int i = 0; i < filteredBlocks.Count; ++i)
+ {
+ DrawBlockSearchPopUpItem(filteredBlocks[i], i == blockPopupSelection);
+ }
- for (int i = 0; i < filteredBlocks.Length; ++i)
+ if(filteredBlocks.Count == 0)
{
- EditorGUILayout.BeginHorizontal(GUILayout.Height(16));
+ DrawBlockSearchPopUpItem(null, false);
+ }
+ }
+ EditorGUILayout.EndScrollView();
+ }
+ GUILayout.EndArea();
+ }
- var block = filteredBlocks[i];
- var style = i == blockPopupSelection ? selectedStyle : normalStyle;
+ protected void DrawBlockSearchPopUpItem(Block block, bool selected)
+ {
+ EditorGUILayout.BeginHorizontal(GUILayout.Height(16));
- GUI.contentColor = GetBlockGraphics(block).tint;
+ var style = selected ? blockSearchPopupSelectedStyle : blockSearchPopupNormalStyle;
- var buttonPressed = false;
- if (GUILayout.Button(FungusEditorResources.BulletPoint, style, GUILayout.Width(16)))
- {
- buttonPressed = true;
- }
+ GUI.contentColor = block != null ? GetBlockGraphics(block).tint : Color.white;
- GUI.contentColor = Color.white;
+ var buttonPressed = false;
+ if (GUILayout.Button(FungusEditorResources.BulletPoint, style, GUILayout.Width(16)))
+ {
+ buttonPressed = true;
+ }
- if (GUILayout.Button(block.BlockName, style))
- {
- buttonPressed = true;
- }
+ GUI.contentColor = Color.white;
- if (buttonPressed)
- {
- CenterBlock(block);
- SelectBlock(block);
- CloseBlockPopup();
- }
+ if (GUILayout.Button(block != null ? block.BlockName : "No Matches", style))
+ {
+ buttonPressed = true;
+ }
- EditorGUILayout.EndHorizontal();
- }
- }
- EditorGUILayout.EndScrollView();
+ if (buttonPressed)
+ {
+ CenterBlock(block);
+ SelectBlock(block);
+ CloseBlockPopup();
}
- GUILayout.EndArea();
+
+ EditorGUILayout.EndHorizontal();
}
protected Block GetBlockAtPoint(Vector2 point)
@@ -1027,6 +1094,15 @@ namespace Fungus.EditorUtils
{
if (hitBlock != null)
{
+ if(e.clickCount == 2)
+ {
+ CenterBlock(hitBlock);
+
+ e.Use();
+ didDoubleClick = true;
+ return;
+ }
+
startDragPosition = e.mousePosition / flowchart.Zoom - flowchart.ScrollPos;
Undo.RecordObject(flowchart, "Select");
@@ -1141,7 +1217,7 @@ namespace Fungus.EditorUtils
break;
case MouseButton.Right:
- if (Vector2.Distance(rightClickDown, e.mousePosition) > rightClickTolerance)
+ if (Vector2.Distance(rightClickDown, e.mousePosition) > RightClickTolerance)
{
rightClickDown = -Vector2.one;
}
@@ -1177,7 +1253,13 @@ namespace Fungus.EditorUtils
switch (e.button)
{
case MouseButton.Left:
-
+ if(didDoubleClick)
+ {
+ didDoubleClick = false;
+ return;
+ }
+
+
if (dragBlock != null)
{
for (int i = 0; i < flowchart.SelectedBlocks.Count; ++i)
@@ -1190,6 +1272,11 @@ namespace Fungus.EditorUtils
Undo.RecordObject(block, "Block Position");
tempRect.position += distance;
block._NodeRect = tempRect;
+ if (FungusEditorPreferences.useGridSnap)
+ {
+ block._NodeRect = block._NodeRect.SnapPosition(GridObjectSnap);
+ }
+ Repaint();
}
dragBlock = null;
@@ -1328,12 +1415,6 @@ namespace Fungus.EditorUtils
{
DrawGrid();
- // Draw connections
- foreach (var block in blocks)
- {
- DrawConnections(block);
- }
-
//draw all non selected
for (int i = 0; i < blocks.Length; ++i)
{
@@ -1350,7 +1431,7 @@ namespace Fungus.EditorUtils
DrawBlock(block, scriptViewRect);
}
- //draw all selected
+ //draw all selected
for (int i = 0; i < blocks.Length; ++i)
{
var block = blocks[i];
@@ -1452,13 +1533,14 @@ namespace Fungus.EditorUtils
{
var prevZoom = flowchart.Zoom;
flowchart.Zoom += delta;
- flowchart.Zoom = Mathf.Clamp(flowchart.Zoom, minZoomValue, maxZoomValue);
+ flowchart.Zoom = Mathf.Clamp(flowchart.Zoom, MinZoomValue, MaxZoomValue);
var deltaSize = position.size / prevZoom - position.size / flowchart.Zoom;
var offset = -Vector2.Scale(deltaSize, center);
flowchart.ScrollPos += offset;
forceRepaintCount = 1;
}
+ //Potentially could be faster using https://forum.unity.com/threads/how-do-i-access-the-background-image-used-for-the-animator.501876/
protected virtual void DrawGrid()
{
float width = this.position.width / flowchart.Zoom;
@@ -1466,23 +1548,22 @@ namespace Fungus.EditorUtils
Handles.color = gridLineColor;
- float gridSize = 128f;
- float x = flowchart.ScrollPos.x % gridSize;
+ float x = flowchart.ScrollPos.x % GridLineSpacingSize;
while (x < width)
{
Handles.DrawLine(new Vector2(x, 0), new Vector2(x, height));
- x += gridSize;
+ x += GridLineSpacingSize;
}
- float y = (flowchart.ScrollPos.y % gridSize);
+ float y = (flowchart.ScrollPos.y % GridLineSpacingSize);
while (y < height)
{
if (y >= 0)
{
Handles.DrawLine(new Vector2(0, y), new Vector2(width, y));
}
- y += gridSize;
+ y += GridLineSpacingSize;
}
Handles.color = Color.white;
@@ -1517,6 +1598,18 @@ namespace Fungus.EditorUtils
return newBlock;
}
+ public Block CreateBlockSuppressSelect(Flowchart flowchart, Vector2 position)
+ {
+ Block newBlock = flowchart.CreateBlock(position);
+ UpdateBlockCollection();
+ Undo.RegisterCreatedObjectUndo(newBlock, "New Block");
+
+ return newBlock;
+ }
+
+ //prevent every DrawConnections from allocating a new list for all of its connections
+ protected List connectedBlocksWorkSpace = new List();
+
protected virtual void DrawConnections(Block block)
{
if (block == null)
@@ -1524,7 +1617,6 @@ namespace Fungus.EditorUtils
return;
}
- var connectedBlocks = new List();
bool blockIsSelected = flowchart.SelectedBlock == block;
@@ -1552,10 +1644,10 @@ namespace Fungus.EditorUtils
bool highlight = command.IsExecuting || (blockIsSelected && commandIsSelected);
- connectedBlocks.Clear();
- command.GetConnectedBlocks(ref connectedBlocks);
+ connectedBlocksWorkSpace.Clear();
+ command.GetConnectedBlocks(ref connectedBlocksWorkSpace);
- foreach (var blockB in connectedBlocks)
+ foreach (var blockB in connectedBlocksWorkSpace)
{
if (blockB == null ||
block == blockB ||
@@ -1919,7 +2011,7 @@ namespace Fungus.EditorUtils
case "Find":
blockPopupSelection = 0;
popupScroll = Vector2.zero;
- EditorGUI.FocusTextInControl(searchFieldName);
+ EditorGUI.FocusTextInControl(SearchFieldName);
e.Use();
break;
}
@@ -1939,12 +2031,17 @@ namespace Fungus.EditorUtils
{
GUIUtility.keyboardControl = 0;
searchString = string.Empty;
+ filterStale = true;
}
+ static protected List blockGraphicsUniqueListWorkSpace = new List();
+ static protected List blockGraphicsConnectedWorkSpace = new List();
protected virtual BlockGraphics GetBlockGraphics(Block block)
{
var graphics = new BlockGraphics();
+ blockGraphicsUniqueListWorkSpace.Clear();
+ blockGraphicsConnectedWorkSpace.Clear();
Color defaultTint;
if (block._EventHandler != null)
{
@@ -1955,19 +2052,18 @@ namespace Fungus.EditorUtils
else
{
// Count the number of unique connections (excluding self references)
- var uniqueList = new List();
- var connectedBlocks = block.GetConnectedBlocks();
- foreach (var connectedBlock in connectedBlocks)
+ block.GetConnectedBlocks(ref blockGraphicsConnectedWorkSpace);
+ foreach (var connectedBlock in blockGraphicsConnectedWorkSpace)
{
if (connectedBlock == block ||
- uniqueList.Contains(connectedBlock))
+ blockGraphicsUniqueListWorkSpace.Contains(connectedBlock))
{
continue;
}
- uniqueList.Add(connectedBlock);
+ blockGraphicsUniqueListWorkSpace.Add(connectedBlock);
}
- if (uniqueList.Count > 1)
+ if (blockGraphicsUniqueListWorkSpace.Count > 1)
{
graphics.offTexture = FungusEditorResources.ChoiceNodeOff;
graphics.onTexture = FungusEditorResources.ChoiceNodeOn;
@@ -1989,79 +2085,90 @@ namespace Fungus.EditorUtils
private void DrawBlock(Block block, Rect scriptViewRect)
{
float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.BlockName)).x + 10;
- float nodeWidthB = 0f;
- if (block._EventHandler != null)
+
+ Rect tempRect = block._NodeRect;
+ tempRect.width = Mathf.Clamp(nodeWidthA, BlockMinWidth, BlockMaxWidth);
+ tempRect.height = DefaultBlockHeight;
+ if (FungusEditorPreferences.useGridSnap)
{
- nodeWidthB = nodeStyle.CalcSize(new GUIContent(block._EventHandler.GetSummary())).x + 10;
+ tempRect = tempRect.SnapWidth(GridObjectSnap);
}
-
- Rect tempRect = block._NodeRect;
- tempRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120);
- tempRect.height = 40;
block._NodeRect = tempRect;
- Rect windowRect = new Rect(block._NodeRect);
- windowRect.position += flowchart.ScrollPos;
+ // Draw blocks
+ var graphics = GetBlockGraphics(block);
+
+ Rect windowRelativeRect = new Rect(block._NodeRect);
+ if (FungusEditorPreferences.useGridSnap)
+ {
+ windowRelativeRect = windowRelativeRect.SnapPosition(GridObjectSnap);
+ }
+ windowRelativeRect.position += flowchart.ScrollPos;
//skip if outside of view
- if (!scriptViewRect.Overlaps(windowRect))
+ if (!scriptViewRect.Overlaps(windowRelativeRect))
return;
- // Draw blocks
- GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle);
- var graphics = GetBlockGraphics(block);
-
- // Make sure node is wide enough to fit the node name text
- float width = nodeStyleCopy.CalcSize(new GUIContent(block.BlockName)).x;
- tempRect = block._NodeRect;
- tempRect.width = Mathf.Max(block._NodeRect.width, width);
- block._NodeRect = tempRect;
+ var tmpNormBg = nodeStyle.normal.background;
// Draw untinted highlight
if (block.IsSelected && !block.IsControlSelected)
{
GUI.backgroundColor = Color.white;
- nodeStyleCopy.normal.background = graphics.onTexture;
- GUI.Box(windowRect, "", nodeStyleCopy);
+ nodeStyle.normal.background = graphics.onTexture;
+ GUI.Box(windowRelativeRect, "", nodeStyle);
+ nodeStyle.normal.background = tmpNormBg;
}
if (block.IsControlSelected && !block.IsSelected)
{
GUI.backgroundColor = Color.white;
- nodeStyleCopy.normal.background = graphics.onTexture;
+ nodeStyle.normal.background = graphics.onTexture;
var c = GUI.backgroundColor;
c.a = 0.5f;
GUI.backgroundColor = c;
- GUI.Box(windowRect, "", nodeStyleCopy);
+ GUI.Box(windowRelativeRect, "", nodeStyle);
+ nodeStyle.normal.background = tmpNormBg;
}
// Draw tinted block; ensure text is readable
var brightness = graphics.tint.r * 0.3 + graphics.tint.g * 0.59 + graphics.tint.b * 0.11;
- nodeStyleCopy.normal.textColor = brightness >= 0.5 ? Color.black : Color.white;
+ var tmpNormTxtCol = nodeStyle.normal.textColor;
+ nodeStyle.normal.textColor = brightness >= 0.5 ? Color.black : Color.white;
- if (GUI.GetNameOfFocusedControl() == searchFieldName && !block.IsFiltered)
+ switch (block.FilterState)
{
+ case Block.FilteredState.Full:
+ break;
+ case Block.FilteredState.Partial:
+ graphics.tint.a *= 0.65f;
+ break;
+ case Block.FilteredState.None:
graphics.tint.a *= 0.2f;
+ break;
+ default:
+ break;
}
- nodeStyleCopy.normal.background = graphics.offTexture;
+ nodeStyle.normal.background = graphics.offTexture;
GUI.backgroundColor = graphics.tint;
- GUI.Box(windowRect, block.BlockName, nodeStyleCopy);
+ GUI.Box(windowRelativeRect, block.BlockName, nodeStyle);
GUI.backgroundColor = Color.white;
if (block.Description.Length > 0)
{
- GUIStyle descriptionStyle = new GUIStyle(EditorStyles.helpBox);
- descriptionStyle.wordWrap = true;
var content = new GUIContent(block.Description);
- windowRect.y += windowRect.height;
- windowRect.height = descriptionStyle.CalcHeight(content, windowRect.width);
- GUI.Label(windowRect, content, descriptionStyle);
+ windowRelativeRect.y += windowRelativeRect.height;
+ windowRelativeRect.height = descriptionStyle.CalcHeight(content, windowRelativeRect.width);
+ GUI.Label(windowRelativeRect, content, descriptionStyle);
}
GUI.backgroundColor = Color.white;
+ nodeStyle.normal.textColor = tmpNormTxtCol;
+ nodeStyle.normal.background = tmpNormBg;
+
// Draw Event Handler labels
if (block._EventHandler != null)
{
@@ -2071,13 +2178,7 @@ namespace Fungus.EditorUtils
{
handlerLabel = "<" + info.EventHandlerName + "> ";
}
-
- GUIStyle handlerStyle = new GUIStyle(EditorStyles.whiteLabel);
- handlerStyle.wordWrap = true;
- handlerStyle.margin.top = 0;
- handlerStyle.margin.bottom = 0;
- handlerStyle.alignment = TextAnchor.MiddleCenter;
-
+
Rect rect = new Rect(block._NodeRect);
rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block._NodeRect.width);
rect.x += flowchart.ScrollPos.x;
@@ -2085,6 +2186,9 @@ namespace Fungus.EditorUtils
GUI.Label(rect, handlerLabel, handlerStyle);
}
+
+
+ DrawConnections(block);
}
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs
index fa8021fc..48c910b1 100644
--- a/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs
+++ b/Assets/Fungus/Scripts/Editor/FungusEditorPreferences.cs
@@ -1,4 +1,7 @@
-using System.Linq;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Linq;
using UnityEditor;
using UnityEngine;
@@ -18,9 +21,11 @@ namespace Fungus
private static bool prefsLoaded = false;
private const string HIDE_MUSH_KEY = "hideMushroomInHierarchy";
private const string USE_LEGACY_MENUS = "useLegacyMenus";
+ private const string USE_GRID_SNAP = "useGridSnap";
public static bool hideMushroomInHierarchy;
public static bool useLegacyMenus;
+ public static bool useGridSnap;
static FungusEditorPreferences()
{
@@ -60,6 +65,7 @@ namespace Fungus
// Preferences GUI
hideMushroomInHierarchy = EditorGUILayout.Toggle("Hide Mushroom Flowchart Icon", hideMushroomInHierarchy);
useLegacyMenus = EditorGUILayout.Toggle(new GUIContent("Legacy Menus", "Force Legacy menus for Event, Add Variable and Add Command menus"), useLegacyMenus);
+ useGridSnap = EditorGUILayout.Toggle(new GUIContent("Grid Snap", "Align and Snap block positions and widths in the flowchart window to the grid"), useGridSnap);
EditorGUILayout.Space();
//ideally if any are null, but typically it is all or nothing that have broken links due to version changes or moving files external to Unity
@@ -110,6 +116,7 @@ namespace Fungus
{
EditorPrefs.SetBool(HIDE_MUSH_KEY, hideMushroomInHierarchy);
EditorPrefs.SetBool(USE_LEGACY_MENUS, useLegacyMenus);
+ EditorPrefs.SetBool(USE_GRID_SNAP, useGridSnap);
}
}
@@ -117,6 +124,7 @@ namespace Fungus
{
hideMushroomInHierarchy = EditorPrefs.GetBool(HIDE_MUSH_KEY, false);
useLegacyMenus = EditorPrefs.GetBool(USE_LEGACY_MENUS, false);
+ useGridSnap = EditorPrefs.GetBool(USE_GRID_SNAP, false);
prefsLoaded = true;
}
}
diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs
index 886db035..123c3853 100644
--- a/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs
+++ b/Assets/Fungus/Scripts/Editor/FungusEditorResources.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -15,7 +15,7 @@ using System.Reflection;
namespace Fungus.EditorUtils
{
[CustomEditor(typeof(FungusEditorResources))]
- internal class FungusEditorResourcesInspector : Editor
+ public class FungusEditorResourcesInspector : Editor
{
public override void OnInspectorGUI()
{
@@ -36,7 +36,7 @@ namespace Fungus.EditorUtils
}
// Handle reimporting all assets
- internal class EditorResourcesPostProcessor : AssetPostprocessor
+ public class EditorResourcesPostProcessor : AssetPostprocessor
{
private static void OnPostprocessAllAssets(string[] importedAssets, string[] _, string[] __, string[] ___)
{
@@ -56,10 +56,10 @@ namespace Fungus.EditorUtils
}
}
- internal partial class FungusEditorResources : ScriptableObject
+ public partial class FungusEditorResources : ScriptableObject
{
[Serializable]
- internal class EditorTexture
+ public class EditorTexture
{
[SerializeField] private Texture2D free;
[SerializeField] private Texture2D pro;
@@ -81,7 +81,7 @@ namespace Fungus.EditorUtils
private static readonly string PartialEditorResourcesPath = System.IO.Path.Combine("Fungus", "EditorResources");
[SerializeField] [HideInInspector] private bool updateOnReloadScripts = false;
- internal static FungusEditorResources Instance
+ public static FungusEditorResources Instance
{
get
{
@@ -125,7 +125,7 @@ namespace Fungus.EditorUtils
return string.Empty;
}
- internal static void GenerateResourcesScript()
+ public static void GenerateResourcesScript()
{
// Get all unique filenames
var textureNames = new HashSet();
@@ -143,7 +143,7 @@ namespace Fungus.EditorUtils
using (var writer = new StreamWriter(absolutePath))
{
- writer.WriteLine("// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).");
+ writer.WriteLine("// This code is part of the Fungus library (https://github.com/snozbot/fungus)");
writer.WriteLine("// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)");
writer.WriteLine("");
writer.WriteLine("#pragma warning disable 0649");
@@ -152,7 +152,7 @@ namespace Fungus.EditorUtils
writer.WriteLine("");
writer.WriteLine("namespace Fungus.EditorUtils");
writer.WriteLine("{");
- writer.WriteLine(" internal partial class FungusEditorResources : ScriptableObject");
+ writer.WriteLine(" public partial class FungusEditorResources : ScriptableObject");
writer.WriteLine(" {");
foreach (var name in textureNames)
@@ -187,7 +187,7 @@ namespace Fungus.EditorUtils
}
}
- internal static void UpdateTextureReferences(FungusEditorResources instance)
+ public static void UpdateTextureReferences(FungusEditorResources instance)
{
// Iterate through all fields in instance and set texture references
var serializedObject = new SerializedObject(instance);
diff --git a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs
index bc077d06..6a45b22a 100644
--- a/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs
+++ b/Assets/Fungus/Scripts/Editor/FungusEditorResourcesGenerated.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#pragma warning disable 0649
@@ -7,7 +7,7 @@ using UnityEngine;
namespace Fungus.EditorUtils
{
- internal partial class FungusEditorResources : ScriptableObject
+ public partial class FungusEditorResources : ScriptableObject
{
[SerializeField] private EditorTexture add;
[SerializeField] private EditorTexture add_small;
diff --git a/Assets/Fungus/Scripts/Editor/GenerateVariableHelper.cs b/Assets/Fungus/Scripts/Editor/GenerateVariableHelper.cs
new file mode 100644
index 00000000..28e4f521
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/GenerateVariableHelper.cs
@@ -0,0 +1,778 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEditor;
+using UnityEngine;
+
+namespace Fungus.EditorUtils
+{
+ ///
+ /// Helper script that auto generates the required script for FungusVariables that wrap existing classes.
+ ///
+ /// Intended to speed up the creation of fungus wrappers of unity builtin types and custom user types.
+ ///
+ public class VariableScriptGenerator
+ {
+ public string NamespaceUsingDeclare { get; set; }
+
+ public bool PreviewOnly { get; set; }
+ private string _category = "Other";
+ public string Category { get { return _category; } set { _category = value; } }
+
+ public List types { get; private set; }
+
+ public bool generateVariableClass = true,
+ generatePropertyCommand = true,
+ generateVariableDataClass = true,
+ generateOnlyDeclaredMembers = true;
+
+ public string ClassName { get { return TargetType.Name; } }
+ public string CamelCaseClassName { get { return Char.ToLowerInvariant(ClassName[0]) + ClassName.Substring(1); } }
+
+ public string GenClassName { get { return ClassName + "Variable"; } }
+
+ public string VariableFileName { get { return VaraibleScriptLocation + ClassName + "Variable.cs"; } }
+ public string VariableEditorFileName { get { return EditorScriptLocation + ClassName + "VariableDrawer.cs"; } }
+ public string PropertyFileName { get { return PropertyScriptLocation + ClassName + "Property.cs"; } }
+
+ private Type _targetType;
+
+ public Type TargetType
+ {
+ get
+ {
+ return _targetType;
+ }
+ set
+ {
+ _targetType = value;
+ ExistingGeneratedClass = null;
+ ExistingGeneratedDrawerClass = null;
+ ExistingGeneratedPropCommandClass = null;
+
+ if (_targetType != null)
+ {
+ ExistingGeneratedClass = types.Find(x => x.Name == GenClassName);
+ ExistingGeneratedDrawerClass = types.Find(x => x.Name == (ClassName + "VariableDrawer"));
+ ExistingGeneratedPropCommandClass = types.Find(x => x.Name == (ClassName + "Property"));
+ if (ExistingGeneratedPropCommandClass != null)
+ {
+ var nested = ExistingGeneratedPropCommandClass.GetNestedTypes().ToList();
+ ExistingGeneratedPropEnumClass = nested.Find(x => x.Name == "Property");
+ }
+ }
+ }
+ }
+
+ public Type ExistingGeneratedClass { get; private set; }
+ public Type ExistingGeneratedDrawerClass { get; private set; }
+ public Type ExistingGeneratedPropCommandClass { get; private set; }
+ public Type ExistingGeneratedPropEnumClass { get; private set; }
+
+ private StringBuilder getBuilder, setBuilder;// = new StringBuilder("switch (property)\n{");
+ private List enumBuilder = new List();
+
+ //data and helper for a single native to single fungus type
+ public class FungusVariableTypeHelper
+ {
+ private HashSet usedTypes = new HashSet();
+ private List handlers = new List();
+
+ public class TypeHandler
+ {
+ public TypeHandler(Type native, Type fungusType, string localName, string nativeAsString = null, string fungusTypeAsString = null)
+ {
+ NativeType = native;
+ NativeTypeString = string.IsNullOrEmpty(nativeAsString) ? native.Name : nativeAsString;
+ FungusType = fungusType;
+ FungusTypeString = string.IsNullOrEmpty(fungusTypeAsString) ? fungusType.Name : fungusTypeAsString;
+ LocalVariableName = localName;
+ }
+
+ public Type NativeType { get; set; }
+ public Type FungusType { get; set; }
+ public string NativeTypeString { get; set; }
+ public string FungusTypeString { get; set; }
+ public string LocalVariableName { get; set; }
+
+ public string GetLocalVariableNameWithDeclaration()
+ {
+ return "var " + LocalVariableName + " = inOutVar as " + FungusTypeString + ';';
+ }
+
+ public string GetVarPropText()
+ {
+ return "typeof(" + FungusTypeString + ")";
+ }
+ }
+
+ public void AddHandler(TypeHandler t)
+ {
+ if (handlers.Find(x => x.NativeType == t.NativeType || x.LocalVariableName == t.LocalVariableName) != null)
+ {
+ Debug.LogError("AddHandler rejected due to duplicate native field or local variable name");
+ return;
+ }
+
+ handlers.Add(t);
+ }
+
+ public bool IsTypeHandled(Type t)
+ {
+ return handlers.Find(x => x.NativeType == t) != null;
+ }
+
+ public string GetSpecificVariableVarientFromType(Type t)
+ {
+ usedTypes.Add(t);
+
+ var loc = handlers.Find(x => x.NativeType == t);
+ if (loc != null)
+ {
+ return loc.LocalVariableName;
+ }
+ else
+ {
+ return "ERROR - Unsupprted type requested";
+ }
+ }
+
+ public string GetUsedTypeVars()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ foreach (Type t in usedTypes)
+ {
+ var loc = handlers.Find(x => x.NativeType == t);
+ if (loc != null)
+ {
+ sb.Append(" ");
+ sb.AppendLine(loc.GetLocalVariableNameWithDeclaration());
+ }
+ }
+
+ return sb.ToString();
+ }
+
+ public string GetVariablePropertyTypeOfs()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ foreach (Type t in usedTypes)
+ {
+ var loc = handlers.Find(x => x.NativeType == t);
+ if (loc != null)
+ {
+ if (sb.Length > 0)
+ {
+ sb.AppendLine(",");
+ sb.Append(" ");
+ }
+ sb.Append(loc.GetVarPropText());
+ }
+ }
+
+ return sb.ToString();
+ }
+ }
+
+ private FungusVariableTypeHelper helper = new FungusVariableTypeHelper();
+
+ #region consts
+
+ // need to also track if they are preview only
+ static public readonly string[] AllGeneratedVariableTypeClassNames =
+ {
+ "Animator",
+ "AudioSource",
+ //"Boolean",
+ "Color",
+ "Collection",
+ "Collider",
+ "Collider2D",
+ "Collision",
+ "Collision2D",
+ "ControllerColliderHit",
+ //"Float",
+ "GameObject",
+ //"Integer",
+ "Material",
+ "Matrix4x4",
+ //"Object",
+ "Quaternion",
+ "Rigidbody",
+ "Rigidbody2D",
+ "Sprite",
+ //"String",
+ "Texture",
+ "Transform",
+ "Vector2",
+ "Vector3",
+ "Vector4"};
+
+ private const string ScriptLocation = "./Assets/Fungus/Scripts/";
+ private const string PropertyScriptLocation = ScriptLocation + "Commands/Property/";
+ private const string VaraibleScriptLocation = ScriptLocation + "VariableTypes/";
+ private const string EditorScriptLocation = ScriptLocation + "Editor/VariableTypes/";
+
+ private const string EditorDataDrawerScriptTemplate = @"// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEditor;
+using UnityEngine;
+
+namespace Fungus.EditorUtils
+{{
+ [CustomPropertyDrawer(typeof({0}Data))]
+ public class {0}DataDrawer : VariableDataDrawer<{0}Variable>
+ {{ }}
+}}";
+
+ //0 ClassName
+ //1 NamespaceOfClass
+ //2 lowerClassName
+ //3 Category
+ //4 previewOnly
+ //5 full name
+
+ private const string VariableAndDataScriptTemplate = @"// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+{1}
+
+namespace Fungus
+{{
+ ///
+ /// {0} variable type.
+ ///
+ [VariableInfo(""{3}"", ""{0}""{4})]
+ [AddComponentMenu("""")]
+ [System.Serializable]
+ public class {0}Variable : VariableBase<{5}>
+ {{ }}
+
+ ///
+ /// Container for a {0} variable reference or constant value.
+ ///
+ [System.Serializable]
+ public struct {0}Data
+ {{
+ [SerializeField]
+ [VariableProperty("""", typeof({0}Variable))]
+ public {0}Variable {2}Ref;
+
+ [SerializeField]
+ public {5} {2}Val;
+
+ public static implicit operator {5}({0}Data {0}Data)
+ {{
+ return {0}Data.Value;
+ }}
+
+ public {0}Data({5} v)
+ {{
+ {2}Val = v;
+ {2}Ref = null;
+ }}
+
+ public {5} Value
+ {{
+ get {{ return ({2}Ref == null) ? {2}Val : {2}Ref.Value; }}
+ set {{ if ({2}Ref == null) {{ {2}Val = value; }} else {{ {2}Ref.Value = value; }} }}
+ }}
+
+ public string GetDescription()
+ {{
+ if ({2}Ref == null)
+ {{
+ return {2}Val.ToString();
+ }}
+ else
+ {{
+ return {2}Ref.Key;
+ }}
+ }}
+ }}
+}}";
+
+ //0 ClassName
+ //1 NamespaceOfClass
+ //2 lowerClassName
+ //3 Category
+ //4 previewOnly
+ //5 full name
+
+ private const string VariableOnlyScriptTemplate = @"// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+{1}
+
+namespace Fungus
+{{
+ ///
+ /// {0} variable type.
+ ///
+ [VariableInfo(""{3}"", ""{0}""{4})]
+ [AddComponentMenu("""")]
+ [System.Serializable]
+ public class {0}Variable : VariableBase<{5}>
+ {{ }}
+}}";
+
+ //0 typeo
+ //1 prop enum
+ //2 lower class name
+ //3 get generated
+ //4 set generated
+ //5 used vars
+ //6 variableProperty Type of
+ //7 null check summary
+ private const string DataBasedPropertyScriptTemplate = @"// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+namespace Fungus
+{{
+ //
+ /// Get or Set a property of a {0} component
+ ///
+ [CommandInfo(""Property"",
+ ""{0}"",
+ ""Get or Set a property of a {0} component"")]
+ [AddComponentMenu("""")]
+ public class {0}Property : BaseVariableProperty
+ {{
+ //generated property
+ {1}
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ protected {0}Data {2}Data;
+
+ [SerializeField]
+ [VariableProperty({6})]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {{
+{5}
+
+ var target = {2}Data.Value;
+
+ switch (getOrSet)
+ {{
+ case GetSet.Get:
+ {3}
+ break;
+
+ case GetSet.Set:
+ {4}
+ break;
+
+ default:
+ break;
+ }}
+
+ Continue();
+ }}
+
+ public override string GetSummary()
+ {{{7}
+ if (inOutVar == null)
+ {{
+ return ""Error: no variable set to push or pull data to or from"";
+ }}
+
+ return getOrSet.ToString() + "" "" + property.ToString();
+ }}
+
+ public override Color GetButtonColor()
+ {{
+ return new Color32(235, 191, 217, 255);
+ }}
+
+ public override bool HasReference(Variable variable)
+ {{
+ if ({2}Data.{2}Ref == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }}
+ }}
+}}";
+
+ //0 typeo
+ //1 prop enum
+ //2 lower class name
+ //3 get generated
+ //4 set generated
+ //5 used vars
+ //6 variableProperty Type of
+ //7 null check summary
+ private const string VariableOnlyPropertyScriptTemplate = @"// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+using UnityEngine;
+
+namespace Fungus
+{{
+ //
+ /// Get or Set a property of a {0} component
+ ///
+ [CommandInfo(""Property"",
+ ""{0}"",
+ ""Get or Set a property of a {0} component"")]
+ [AddComponentMenu("""")]
+ public class {0}Property : BaseVariableProperty
+ {{
+ //generated property
+ {1}
+
+ [SerializeField]
+ protected Property property;
+
+ [SerializeField]
+ [VariableProperty(typeof({0}Variable))]
+ protected {0}Variable {2}Var;
+
+ [SerializeField]
+ [VariableProperty({6})]
+ protected Variable inOutVar;
+
+ public override void OnEnter()
+ {{
+{5}
+
+ var target = {2}Var.Value;
+
+ switch (getOrSet)
+ {{
+ case GetSet.Get:
+ {3}
+ break;
+
+ case GetSet.Set:
+ {4}
+ break;
+
+ default:
+ break;
+ }}
+
+ Continue();
+ }}
+
+ public override string GetSummary()
+ {{{7}
+ if (inOutVar == null)
+ {{
+ return ""Error: no variable set to push or pull data to or from"";
+ }}
+
+ return getOrSet.ToString() + "" "" + property.ToString();
+ }}
+
+ public override Color GetButtonColor()
+ {{
+ return new Color32(235, 191, 217, 255);
+ }}
+
+ public override bool HasReference(Variable variable)
+ {{
+ if ({2}Var == variable || inOutVar == variable)
+ return true;
+
+ return false;
+ }}
+ }}
+}}";
+
+ private const string DefaultCaseFailure = @" default:
+ Debug.Log(""Unsupported get or set attempted"");
+ break;
+ }";
+
+ private const string DataNullCheckSummary = @"
+ if ({0}Data.Value == null)
+ {{
+ return ""Error: no {0} set"";
+ }}";
+
+ private const string VariableOnlyNullCheckSummary = @"
+ if ({0}Var == null)
+ {{
+ return ""Error: no {0}Var set"";
+ }}";
+
+ #endregion consts
+
+ public VariableScriptGenerator()
+ {
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Animator), typeof(AnimatorVariable), "ioani"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(AudioSource), typeof(AudioSourceVariable), "ioaud"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(bool), typeof(BooleanVariable), "iob"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Collider2D), typeof(Collider2DVariable), "ioc2d"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Collider), typeof(ColliderVariable), "ioc"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Collection), typeof(CollectionVariable), "iocollect"));
+ //we don't need to do collision varaibles
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Color), typeof(ColorVariable), "iocol"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(float), typeof(FloatVariable), "iof"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(GameObject), typeof(GameObjectVariable), "iogo"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(int), typeof(IntegerVariable), "ioi"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Material), typeof(MaterialVariable), "iomat"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Matrix4x4), typeof(Matrix4x4Variable), "iom4"));
+ //we skip object
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Quaternion), typeof(QuaternionVariable), "ioq"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Rigidbody2D), typeof(Rigidbody2DVariable), "iorb2d"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Rigidbody), typeof(RigidbodyVariable), "iorb"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Sprite), typeof(SpriteVariable), "iospr"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(string), typeof(StringVariable), "ios"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Texture), typeof(TextureVariable), "iotex"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Transform), typeof(TransformVariable), "iot"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Vector2), typeof(Vector2Variable), "iov2"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Vector3), typeof(Vector3Variable), "iov"));
+ helper.AddHandler(new FungusVariableTypeHelper.TypeHandler(typeof(Vector4), typeof(Vector4Variable), "iov4"));
+
+ types = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes()).ToList();
+ }
+
+ public void Generate()
+ {
+ if (TargetType == null)
+ throw new Exception("No type given");
+
+ EditorUtility.DisplayProgressBar("Generating " + ClassName, "Starting", 0);
+ try
+ {
+ if (generateVariableClass)
+ {
+ Func lam = () =>
+ {
+ var usingDec = !string.IsNullOrEmpty(NamespaceUsingDeclare) ? ("using " + NamespaceUsingDeclare + ";") : string.Empty;
+ return string.Format(generateVariableDataClass ? VariableAndDataScriptTemplate : VariableOnlyScriptTemplate,
+ ClassName, usingDec, CamelCaseClassName, Category, PreviewOnly ? ", IsPreviewedOnly = true" : "", TargetType.FullName);
+ };
+ FileSaveHelper("Variable", VaraibleScriptLocation, VariableFileName, lam);
+ }
+
+ if (generateVariableClass && generateVariableDataClass)
+ {
+ Func lam = () => { return string.Format(EditorDataDrawerScriptTemplate, ClassName); };
+ FileSaveHelper("VariableDrawer", EditorScriptLocation, VariableEditorFileName, lam);
+ }
+
+ if (generatePropertyCommand)
+ {
+ GeneratePropertyCommand();
+ }
+ }
+ catch (Exception e)
+ {
+ Debug.LogError(e.Message);
+ }
+
+ EditorUtility.ClearProgressBar();
+ }
+
+ private void GeneratePropertyCommand()
+ {
+ enumBuilder.Add("public enum Property \n { \n");
+ getBuilder = new StringBuilder("switch (property)\n {\n".Replace("\n", System.Environment.NewLine));
+ setBuilder = new StringBuilder("switch (property)\n {\n".Replace("\n", System.Environment.NewLine));
+
+ AddAllExistingEnumNames();
+
+ EditorUtility.DisplayProgressBar("Generating " + ClassName, "Property", 0);
+ int numAdded = PropertyFieldLogic();
+ numAdded += PropertyPropLogic();
+
+ EditorUtility.DisplayProgressBar("Generating " + ClassName, "Property Building", 0);
+
+ //finalise buidlers
+ setBuilder.AppendLine(DefaultCaseFailure);
+ var setcontents = setBuilder.ToString();
+
+ getBuilder.AppendLine(DefaultCaseFailure);
+ var getcontents = getBuilder.ToString();
+
+ enumBuilder.Add(" }\n");
+ var enumgen = String.Join(null, enumBuilder.ToArray());
+ enumgen = enumgen.Replace("\n", System.Environment.NewLine);
+
+ var typeVars = helper.GetUsedTypeVars();
+ var variablePropertyTypes = helper.GetVariablePropertyTypeOfs();
+
+ string nullCheck = "";
+
+ if (TargetType.IsClass)
+ {
+ nullCheck = string.Format(generateVariableDataClass ? DataNullCheckSummary : VariableOnlyNullCheckSummary, CamelCaseClassName);
+ }
+
+ //write to file
+ Func propContentOp = () =>
+ {
+ return string.Format(generateVariableDataClass ? DataBasedPropertyScriptTemplate : VariableOnlyPropertyScriptTemplate,
+ClassName, enumgen, CamelCaseClassName, getcontents, setcontents, typeVars, variablePropertyTypes, nullCheck);
+ };
+
+ //only generate the file if we actually found variables to get and or set
+ if (numAdded > 0)
+ {
+ FileSaveHelper("Property", PropertyScriptLocation, PropertyFileName, propContentOp);
+ }
+ else
+ {
+ Debug.LogWarning("Attempted to generate property class for " + ClassName + " but found no variables to get or set");
+ }
+ }
+
+ private void AddAllExistingEnumNames()
+ {
+ if (ExistingGeneratedPropEnumClass != null)
+ {
+ if (ExistingGeneratedPropEnumClass.IsEnum)
+ {
+ var res = Enum.GetNames(ExistingGeneratedPropEnumClass);
+ for (int i = 0; i < res.Length; i++)
+ {
+ AddToEnum(res[i]);
+ }
+ }
+ }
+ }
+
+ private System.Reflection.BindingFlags GetBindingFlags()
+ {
+ if (generateOnlyDeclaredMembers)
+ return System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly;
+ return System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance;
+ }
+
+ private int PropertyFieldLogic()
+ {
+ int retval = 0;
+
+ EditorUtility.DisplayProgressBar("Generating " + ClassName, "Property Scanning Fields", 0);
+ var fields = TargetType.GetFields(GetBindingFlags());
+ for (int i = 0; i < fields.Length; i++)
+ {
+ if (helper.IsTypeHandled(fields[i].FieldType))
+ {
+ var actualName = fields[i].Name;
+ var upperCaseName = Char.ToUpperInvariant(actualName[0]) + actualName.Substring(1);
+ //add it to the enum
+ AddToEnum(upperCaseName);
+
+ //add it to the get
+ AddToGet(fields[i].FieldType, upperCaseName, actualName);
+
+ //add it to the set
+ AddToSet(fields[i].FieldType, upperCaseName, actualName);
+ retval++;
+ }
+ }
+
+ return retval;
+ }
+
+ private int PropertyPropLogic()
+ {
+ int retval = 0;
+
+ EditorUtility.DisplayProgressBar("Generating " + ClassName, "Property Scanning Props", 0);
+ var props = TargetType.GetProperties(GetBindingFlags());
+ for (int i = 0; i < props.Length; i++)
+ {
+ if (helper.IsTypeHandled(props[i].PropertyType) && props[i].GetIndexParameters().Length == 0 && !IsObsolete(props[i].GetCustomAttributes(false)))
+ {
+ var actualName = props[i].Name;
+ var upperCaseName = Char.ToUpperInvariant(actualName[0]) + actualName.Substring(1);
+ //add it to the enum
+ AddToEnum(upperCaseName);
+
+ if (props[i].CanRead)
+ {
+ //add it to the get
+ AddToGet(props[i].PropertyType, upperCaseName, actualName);
+ }
+ if (props[i].CanWrite)
+ {
+ //add it to the set
+ AddToSet(props[i].PropertyType, upperCaseName, actualName);
+ }
+
+ if (props[i].CanRead || props[i].CanWrite)
+ retval++;
+ }
+ }
+
+ return retval;
+ }
+
+ private void AddToSet(Type fieldType, string nameEnum, string nameVariable)
+ {
+ setBuilder.Append(" case Property.");
+ setBuilder.Append(nameEnum);
+ setBuilder.AppendLine(":");
+ setBuilder.Append(" target.");
+ setBuilder.Append(nameVariable);
+ setBuilder.Append(" = ");
+ setBuilder.Append(helper.GetSpecificVariableVarientFromType(fieldType));
+ setBuilder.AppendLine(".Value;");
+ setBuilder.AppendLine(" break;");
+ }
+
+ private void AddToGet(Type fieldType, string nameEnum, string nameVariable)
+ {
+ getBuilder.Append(" case Property.");
+ getBuilder.Append(nameEnum);
+ getBuilder.AppendLine(":");
+ getBuilder.Append(" " + helper.GetSpecificVariableVarientFromType(fieldType));
+ getBuilder.Append(".Value = target.");
+ getBuilder.Append(nameVariable);
+ getBuilder.AppendLine(";");
+ getBuilder.AppendLine(" break;");
+ }
+
+ private void AddToEnum(string name)
+ {
+ if (enumBuilder.IndexOf(name) == -1)
+ {
+ enumBuilder.Add(" ");
+ enumBuilder.Add(name);
+ enumBuilder.Add(", \n");
+ }
+ }
+
+ private bool IsObsolete(object[] attrs)
+ {
+ if (attrs.Length > 0)
+ return attrs.FirstOrDefault(x => x.GetType() == typeof(ObsoleteAttribute)) != null;
+ return false;
+ }
+
+ private void FileSaveHelper(string op, string loc, string filename, Func opLambda)
+ {
+ EditorUtility.DisplayProgressBar("Generating " + ClassName, op, 0);
+ var scriptContents = opLambda();
+ System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(loc));
+ System.IO.File.WriteAllText(filename, scriptContents);
+ Debug.Log("Created " + filename);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/GenerateVariableHelper.cs.meta b/Assets/Fungus/Scripts/Editor/GenerateVariableHelper.cs.meta
new file mode 100644
index 00000000..26c2653d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/GenerateVariableHelper.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d1e036e4e5a3dbd4fa3533a2c7ea0d0f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/GenerateVariableWindow.cs b/Assets/Fungus/Scripts/Editor/GenerateVariableWindow.cs
new file mode 100644
index 00000000..90c1fcf9
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/GenerateVariableWindow.cs
@@ -0,0 +1,153 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEditor;
+using UnityEngine;
+
+
+namespace Fungus.EditorUtils
+{
+ ///
+ /// Adds window that generates the require scripts to create a new FungusVariable that wraps an existing type.
+ ///
+ /// These can then be used in the fungus flowcharts. It also generates a *Property command to allow Gets and Sets
+ /// on all the elements of that variable that Fungus Understands. The Quaternion and Matrix4x4 have been auto
+ /// generated and then auto formatted in visual studio and set to preview only as examples of it's use.
+ ///
+ /// It can be used to help building variable wrappers for builtin Unity types or your own components or classes.
+ ///
+ /// To add new types see the VariableScriptGenerator constructor.
+ ///
+ public class GenerateVariableWindow : EditorWindow
+ {
+ private VariableScriptGenerator generator = new VariableScriptGenerator();
+ private string userInputClassName = "";
+ private List typeList = new List();
+
+ public void OnGUI()
+ {
+ DrawMenuPanel();
+ }
+
+ private void DrawMenuPanel()
+ {
+ EditorGUI.BeginChangeCheck();
+
+ if(GUILayout.Button("Generate All from List"))
+ {
+ foreach (var item in VariableScriptGenerator.AllGeneratedVariableTypeClassNames)
+ {
+ generator.TargetType = generator.types.Where(x => string.Compare(x.Name, item, StringComparison.InvariantCultureIgnoreCase) == 0).First();
+ generator.Generate();
+
+ generator = new VariableScriptGenerator();
+ }
+ }
+
+ userInputClassName = EditorGUILayout.TextField("ClassName", userInputClassName);
+
+ if (EditorGUI.EndChangeCheck())
+ {
+ generator.TargetType = null;
+
+ try
+ {
+ typeList = generator.types.Where(x => string.Compare(x.Name,userInputClassName,StringComparison.InvariantCultureIgnoreCase) == 0).ToList();
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ try
+ {
+ int index = typeList.IndexOf(generator.TargetType);
+ EditorGUI.BeginChangeCheck();
+ index = GUILayout.SelectionGrid(index, typeList.Select(x => x.FullName).ToArray(), 1);
+
+ if (index < 0 || index > typeList.Count)
+ index = 0;
+
+ if (EditorGUI.EndChangeCheck() || generator.TargetType == null)
+ generator.TargetType = typeList[index];
+ }
+ catch (Exception)
+ {
+ generator.TargetType = null;
+ }
+
+
+ EditorGUILayout.Space();
+
+ if (generator.TargetType == null)
+ {
+ EditorGUILayout.HelpBox("Must select a type first", MessageType.Info);
+ }
+ else
+ {
+ generator.generateVariableClass = EditorGUILayout.Toggle("Generate Variable", generator.generateVariableClass);
+ generator.generateVariableDataClass = EditorGUILayout.Toggle("Generate Variable Data", generator.generateVariableDataClass);
+ generator.PreviewOnly = EditorGUILayout.Toggle("Variable List preview only", generator.PreviewOnly);
+
+ if (generator.TargetType.IsAbstract)
+ {
+ EditorGUILayout.HelpBox(generator.TargetType.FullName + " is abstract. No Variable will be generated", MessageType.Error);
+ generator.generateVariableClass = false;
+ }
+
+ if (generator.generateVariableClass)
+ {
+ if (generator.ExistingGeneratedClass != null)
+ {
+ EditorGUILayout.HelpBox("Variable Appears to already exist. Overwriting or errors may occur.", MessageType.Warning);
+ }
+ if (generator.ExistingGeneratedDrawerClass != null)
+ {
+ EditorGUILayout.HelpBox("Variable Drawer Appears to already exist. Overwriting or errors may occur.", MessageType.Warning);
+ }
+
+ generator.Category = EditorGUILayout.TextField("Category", generator.Category);
+ generator.NamespaceUsingDeclare = EditorGUILayout.TextField("NamespaceUsingDeclare", generator.NamespaceUsingDeclare);
+ }
+
+ EditorGUILayout.Space();
+ generator.generatePropertyCommand = EditorGUILayout.Toggle("Generate Property Command", generator.generatePropertyCommand);
+ if (generator.generatePropertyCommand)
+ {
+ generator.generateOnlyDeclaredMembers = EditorGUILayout.Toggle("Only declared members", generator.generateOnlyDeclaredMembers);
+ if (generator.ExistingGeneratedPropCommandClass != null)
+ {
+ EditorGUILayout.HelpBox("Property Appears to already exist. Overwriting or errors may occur.", MessageType.Warning);
+ }
+ }
+
+ EditorGUILayout.Space();
+ if (GUILayout.Button("Generate Now"))
+ {
+ try
+ {
+ generator.Generate();
+ EditorUtility.DisplayProgressBar("Generating " + userInputClassName, "Importing Scripts", 0);
+ AssetDatabase.Refresh();
+ }
+ catch (Exception e)
+ {
+ Debug.LogWarning(e.Message);
+ //throw e;
+ }
+ generator = new VariableScriptGenerator();
+ EditorUtility.ClearProgressBar();
+ userInputClassName = "";
+ }
+ }
+ }
+
+ [MenuItem("Tools/Fungus/Utilities/Generate Fungus Varaible")]
+ public static GenerateVariableWindow ShowWindow()
+ {
+ var w = GetWindow(typeof(GenerateVariableWindow), true, "Generate Fungus Varaible", true);
+ w.Show();
+ return w as GenerateVariableWindow;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/GenerateVariableWindow.cs.meta b/Assets/Fungus/Scripts/Editor/GenerateVariableWindow.cs.meta
new file mode 100644
index 00000000..0bcc3095
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/GenerateVariableWindow.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 84f560447a3d4ce40ae5cd87d061d043
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs b/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs
index 11093842..69e7fda6 100644
--- a/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs
+++ b/Assets/Fungus/Scripts/Editor/HierarchyIcons.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
@@ -67,7 +70,7 @@ namespace Fungus
// place the icon to the left of the element
Rect r = new Rect(selectionRect);
#if UNITY_2019_1_OR_NEWER
- r.x -= r.height;
+ r.x -= 28; //this would make sense as singleLineHeight *2 but it isn't as that includes padding
#else
r.x = 0;
#endif
@@ -81,4 +84,4 @@ namespace Fungus
GUI.Label(r, TextureIcon);
}
}
-}
\ No newline at end of file
+}
diff --git a/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs b/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs
index 978d1ec3..e8e5bf26 100644
--- a/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/InvokeEventEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs b/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs
index 6058383a..86420cef 100644
--- a/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/InvokeMethodEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Editor/LabelEditor.cs b/Assets/Fungus/Scripts/Editor/LabelEditor.cs
index 68ca46c8..fa94b932 100644
--- a/Assets/Fungus/Scripts/Editor/LabelEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/LabelEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/LocalizationEditor.cs b/Assets/Fungus/Scripts/Editor/LocalizationEditor.cs
index 72e2efcb..550435a1 100644
--- a/Assets/Fungus/Scripts/Editor/LocalizationEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/LocalizationEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs
index ba2ba3e4..0556ae79 100644
--- a/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs
+++ b/Assets/Fungus/Scripts/Editor/LuaScriptedImporter.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
using UnityEditor.Experimental.AssetImporters;
using System.IO;
diff --git a/Assets/Fungus/Scripts/Editor/MenuEditor.cs b/Assets/Fungus/Scripts/Editor/MenuEditor.cs
index 25f3cb87..16a6eddc 100644
--- a/Assets/Fungus/Scripts/Editor/MenuEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/MenuEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
@@ -43,12 +43,26 @@ namespace Fungus.EditorUtils
EditorGUILayout.PropertyField(textProp);
EditorGUILayout.PropertyField(descriptionProp);
-
+
+ EditorGUILayout.BeginHorizontal();
BlockEditor.BlockField(targetBlockProp,
new GUIContent("Target Block", "Block to call when option is selected"),
new GUIContent(""),
flowchart);
-
+ const int popupWidth = 17;
+ if(targetBlockProp.objectReferenceValue == null && GUILayout.Button("+",GUILayout.MaxWidth(popupWidth)))
+ {
+ var fw = EditorWindow.GetWindow();
+ var t = (Menu)target;
+ var activeFlowchart = t.GetFlowchart();
+ var newBlock = fw.CreateBlockSuppressSelect(activeFlowchart, t.ParentBlock._NodeRect.position - Vector2.down * 60);
+ targetBlockProp.objectReferenceValue = newBlock;
+ activeFlowchart.SelectedBlock = t.ParentBlock;
+ }
+ EditorGUILayout.EndHorizontal();
+
+
+
EditorGUILayout.PropertyField(hideIfVisitedProp);
EditorGUILayout.PropertyField(interactableProp);
EditorGUILayout.PropertyField(setMenuDialogProp);
diff --git a/Assets/Fungus/Scripts/Editor/MenuTimerEditor.cs b/Assets/Fungus/Scripts/Editor/MenuTimerEditor.cs
index 4607af78..a26eeb96 100644
--- a/Assets/Fungus/Scripts/Editor/MenuTimerEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/MenuTimerEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/NarrativeMenuItems.cs b/Assets/Fungus/Scripts/Editor/NarrativeMenuItems.cs
index 539015f1..62dc94bf 100644
--- a/Assets/Fungus/Scripts/Editor/NarrativeMenuItems.cs
+++ b/Assets/Fungus/Scripts/Editor/NarrativeMenuItems.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs
index e0a714a7..8442f64c 100644
--- a/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs
+++ b/Assets/Fungus/Scripts/Editor/PopupContent/CommandSelectorPopupWindowContent.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEditor;
using UnityEngine;
using System;
diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs
index 9e490423..b96e4d0c 100644
--- a/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs
+++ b/Assets/Fungus/Scripts/Editor/PopupContent/EventSelectorPopupWindowContent.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEditor;
using UnityEngine;
using System;
diff --git a/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs b/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs
index 697d8db0..bf7cc9ad 100644
--- a/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs
+++ b/Assets/Fungus/Scripts/Editor/PopupContent/VariableSelectPopupWindowContent.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/PortraitEditor.cs b/Assets/Fungus/Scripts/Editor/PortraitEditor.cs
index eec0d740..bb7fbd1b 100644
--- a/Assets/Fungus/Scripts/Editor/PortraitEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/PortraitEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs
index 6286eab1..cc82444b 100644
--- a/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/SaveMenuEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
@@ -19,7 +19,7 @@ namespace Fungus.EditorUtils
if (saveMenu != null)
{
- PlayerPrefs.DeleteKey(saveMenu.SaveDataKey);
+ SaveManager.Delete(saveMenu.SaveDataKey);
FlowchartWindow.ShowNotification("Deleted Save Data");
}
}
diff --git a/Assets/Fungus/Scripts/Editor/SaveMenuItems.cs b/Assets/Fungus/Scripts/Editor/SaveMenuItems.cs
index d14132bc..1f277bba 100644
--- a/Assets/Fungus/Scripts/Editor/SaveMenuItems.cs
+++ b/Assets/Fungus/Scripts/Editor/SaveMenuItems.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/SayEditor.cs b/Assets/Fungus/Scripts/Editor/SayEditor.cs
index a6ace53f..2f9ca7f1 100644
--- a/Assets/Fungus/Scripts/Editor/SayEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/SayEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/SerializedPropertyExtensions.cs b/Assets/Fungus/Scripts/Editor/SerializedPropertyExtensions.cs
index cc7ce852..71543b2c 100644
--- a/Assets/Fungus/Scripts/Editor/SerializedPropertyExtensions.cs
+++ b/Assets/Fungus/Scripts/Editor/SerializedPropertyExtensions.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/SetVariableEditor.cs b/Assets/Fungus/Scripts/Editor/SetVariableEditor.cs
index 847560f8..9c895ee5 100644
--- a/Assets/Fungus/Scripts/Editor/SetVariableEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/SetVariableEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
@@ -11,51 +11,15 @@ namespace Fungus.EditorUtils
[CustomEditor (typeof(SetVariable))]
public class SetVariableEditor : CommandEditor
{
- protected struct VariablePropertyInfo
- {
- public string name;
- public SerializedProperty dataProp;
-
- public VariablePropertyInfo(string name, SerializedProperty dataProp) {
- this.name = name;
- this.dataProp = dataProp;
- }
- }
-
- protected SerializedProperty variableProp;
+ protected SerializedProperty anyVarProp;
protected SerializedProperty setOperatorProp;
-
- // Variable data props
- protected Dictionary propertyInfoByVariableType;
-
- protected List variableDataProps;
-
+
public override void OnEnable()
{
base.OnEnable();
- variableProp = serializedObject.FindProperty("variable");
+ anyVarProp = serializedObject.FindProperty("anyVar");
setOperatorProp = serializedObject.FindProperty("setOperator");
-
- // Get variable data props by name
- propertyInfoByVariableType = new Dictionary() {
- { typeof(BooleanVariable), new VariablePropertyInfo("Boolean", serializedObject.FindProperty("booleanData")) },
- { typeof(IntegerVariable), new VariablePropertyInfo("Integer", serializedObject.FindProperty("integerData")) },
- { typeof(FloatVariable), new VariablePropertyInfo("Float", serializedObject.FindProperty("floatData")) },
- { typeof(StringVariable), new VariablePropertyInfo("String", serializedObject.FindProperty("stringData")) },
- { typeof(AnimatorVariable), new VariablePropertyInfo("Animator", serializedObject.FindProperty("animatorData")) },
- { typeof(AudioSourceVariable), new VariablePropertyInfo("AudioSource", serializedObject.FindProperty("audioSourceData")) },
- { typeof(ColorVariable), new VariablePropertyInfo("Color", serializedObject.FindProperty("colorData")) },
- { typeof(GameObjectVariable), new VariablePropertyInfo("GameObject", serializedObject.FindProperty("gameObjectData")) },
- { typeof(MaterialVariable), new VariablePropertyInfo("Material", serializedObject.FindProperty("materialData")) },
- { typeof(ObjectVariable), new VariablePropertyInfo("Object", serializedObject.FindProperty("objectData")) },
- { typeof(Rigidbody2DVariable), new VariablePropertyInfo("Rigidbody2D", serializedObject.FindProperty("rigidbody2DData")) },
- { typeof(SpriteVariable), new VariablePropertyInfo("Sprite", serializedObject.FindProperty("spriteData")) },
- { typeof(TextureVariable), new VariablePropertyInfo("Texture", serializedObject.FindProperty("textureData")) },
- { typeof(TransformVariable), new VariablePropertyInfo("Transform", serializedObject.FindProperty("transformData")) },
- { typeof(Vector2Variable), new VariablePropertyInfo("Vector2", serializedObject.FindProperty("vector2Data")) },
- { typeof(Vector3Variable), new VariablePropertyInfo("Vector3", serializedObject.FindProperty("vector3Data")) }
- };
}
public override void DrawCommandGUI()
@@ -71,53 +35,36 @@ namespace Fungus.EditorUtils
}
// Select Variable
- EditorGUILayout.PropertyField(variableProp);
+ EditorGUILayout.PropertyField(anyVarProp, true);
- if (variableProp.objectReferenceValue == null)
- {
- serializedObject.ApplyModifiedProperties();
- return;
- }
+ //fetching every draw to ensure we don't have stale data based on types that have changed by user selection,
+ // without us noticing.
// Get selected variable
- Variable selectedVariable = variableProp.objectReferenceValue as Variable;
- System.Type variableType = selectedVariable.GetType();
-
- // Get operators for the variable
- SetOperator[] setOperators = SetVariable.operatorsByVariableType[variableType];
-
- // Create operator list
+ Variable selectedVariable = anyVarProp.FindPropertyRelative("variable").objectReferenceValue as Variable;
List operatorsList = new List();
- foreach (var setOperator in setOperators)
+ if (selectedVariable != null)
{
- switch (setOperator)
- {
- case SetOperator.Assign:
- operatorsList.Add(new GUIContent("="));
- break;
- case SetOperator.Negate:
- operatorsList.Add(new GUIContent("=!"));
- break;
- case SetOperator.Add:
- operatorsList.Add(new GUIContent("+="));
- break;
- case SetOperator.Subtract:
- operatorsList.Add(new GUIContent("-="));
- break;
- case SetOperator.Multiply:
- operatorsList.Add(new GUIContent("*="));
- break;
- case SetOperator.Divide:
- operatorsList.Add(new GUIContent("\\="));
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " operator has no matching GUIContent.");
- break;
- }
+ if(selectedVariable.IsArithmeticSupported(SetOperator.Assign))
+ operatorsList.Add(new GUIContent(VariableUtil.GetSetOperatorDescription(SetOperator.Assign)));
+ if (selectedVariable.IsArithmeticSupported(SetOperator.Negate))
+ operatorsList.Add(new GUIContent(VariableUtil.GetSetOperatorDescription(SetOperator.Negate)));
+ if (selectedVariable.IsArithmeticSupported(SetOperator.Add))
+ operatorsList.Add(new GUIContent(VariableUtil.GetSetOperatorDescription(SetOperator.Add)));
+ if (selectedVariable.IsArithmeticSupported(SetOperator.Subtract))
+ operatorsList.Add(new GUIContent(VariableUtil.GetSetOperatorDescription(SetOperator.Subtract)));
+ if (selectedVariable.IsArithmeticSupported(SetOperator.Multiply))
+ operatorsList.Add(new GUIContent(VariableUtil.GetSetOperatorDescription(SetOperator.Multiply)));
+ if (selectedVariable.IsArithmeticSupported(SetOperator.Divide))
+ operatorsList.Add(new GUIContent(VariableUtil.GetSetOperatorDescription(SetOperator.Divide)));
+ }
+ else
+ {
+ operatorsList.Add(VariableConditionEditor.None);
}
// Get previously selected operator
- int selectedIndex = System.Array.IndexOf(setOperators, t._SetOperator);
+ int selectedIndex = (int) t._SetOperator;
if (selectedIndex < 0)
{
// Default to first index if the operator is not found in the available operators list
@@ -128,13 +75,10 @@ namespace Fungus.EditorUtils
// Get next selected operator
selectedIndex = EditorGUILayout.Popup(new GUIContent("Operation", "Arithmetic operator to use"), selectedIndex, operatorsList.ToArray());
-
- setOperatorProp.enumValueIndex = (int)setOperators[selectedIndex];
-
-
- VariablePropertyInfo propertyInfo = propertyInfoByVariableType[variableType];
- EditorGUILayout.PropertyField(propertyInfo.dataProp, new GUIContent(propertyInfo.name));
-
+ if (selectedVariable != null)
+ {
+ setOperatorProp.enumValueIndex = selectedIndex;
+ }
serializedObject.ApplyModifiedProperties();
}
diff --git a/Assets/Fungus/Scripts/Editor/SolutionFileFixer.cs b/Assets/Fungus/Scripts/Editor/SolutionFileFixer.cs
new file mode 100644
index 00000000..9eb32251
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/SolutionFileFixer.cs
@@ -0,0 +1,17 @@
+using UnityEditor;
+
+#if UNITY_2019_3_12
+namespace Fungus.EditorUtils
+{
+ //fix for a bug introduced in unity 2019.3.12 that prevents cross asmdef references from showing
+ // doco and code hinting correctly in vs2019
+ // https://forum.unity.com/threads/2019-3-12f1-build-errors.880312/
+ public class SolutionFileFixer : AssetPostprocessor
+ {
+ private static string OnGeneratedCSProject(string path, string content)
+ {
+ return content.Replace("false", "true");
+ }
+ }
+}
+#endif
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/SolutionFileFixer.cs.meta b/Assets/Fungus/Scripts/Editor/SolutionFileFixer.cs.meta
new file mode 100644
index 00000000..b23ff66f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/SolutionFileFixer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 016e0ddcf2101ba4a8d50bf1f440f5c5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/SpriteMenuItems.cs b/Assets/Fungus/Scripts/Editor/SpriteMenuItems.cs
index ea016fa1..7d7a553a 100644
--- a/Assets/Fungus/Scripts/Editor/SpriteMenuItems.cs
+++ b/Assets/Fungus/Scripts/Editor/SpriteMenuItems.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/StageEditor.cs b/Assets/Fungus/Scripts/Editor/StageEditor.cs
index 71cc27f1..c8529f7f 100644
--- a/Assets/Fungus/Scripts/Editor/StageEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/StageEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/VariableConditionEditor.cs b/Assets/Fungus/Scripts/Editor/VariableConditionEditor.cs
index cc5c1515..47e328b8 100644
--- a/Assets/Fungus/Scripts/Editor/VariableConditionEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/VariableConditionEditor.cs
@@ -1,52 +1,60 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
using UnityEngine;
-using System.Collections.Generic;
namespace Fungus.EditorUtils
{
- [CustomEditor (typeof(VariableCondition), true)]
+ ///
+ /// Handles custom drawing for ConditionExperssions within the VariableCondition and inherited commands.
+ ///
+ /// TODO; refactor to allow a propertydrawer on ConditionExperssion and potentially list as reorderable
+ ///
+ [CustomEditor(typeof(VariableCondition), true)]
public class VariableConditionEditor : CommandEditor
{
- protected SerializedProperty variableProp;
- protected SerializedProperty compareOperatorProp;
+ public static readonly GUIContent None = new GUIContent("");
- protected Dictionary propByVariableType;
+ public static readonly GUIContent[] emptyList = new GUIContent[]
+ {
+ None,
+ };
+
+ private static readonly GUIContent[] compareListAll = new GUIContent[]
+ {
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.Equals)),
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.NotEquals)),
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.LessThan)),
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.GreaterThan)),
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.LessThanOrEquals)),
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.GreaterThanOrEquals)),
+ };
+
+ private static readonly GUIContent[] compareListEqualOnly = new GUIContent[]
+ {
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.Equals)),
+ new GUIContent(VariableUtil.GetCompareOperatorDescription(CompareOperator.NotEquals)),
+ };
+
+ protected SerializedProperty conditions;
public override void OnEnable()
{
base.OnEnable();
- variableProp = serializedObject.FindProperty("variable");
- compareOperatorProp = serializedObject.FindProperty("compareOperator");
-
- // Get variable data props by name
- propByVariableType = new Dictionary() {
- { typeof(BooleanVariable), serializedObject.FindProperty("booleanData") },
- { typeof(IntegerVariable), serializedObject.FindProperty("integerData") },
- { typeof(FloatVariable), serializedObject.FindProperty("floatData") },
- { typeof(StringVariable), serializedObject.FindProperty("stringData") },
- { typeof(AnimatorVariable), serializedObject.FindProperty("animatorData") },
- { typeof(AudioSourceVariable), serializedObject.FindProperty("audioSourceData") },
- { typeof(ColorVariable), serializedObject.FindProperty("colorData") },
- { typeof(GameObjectVariable), serializedObject.FindProperty("gameObjectData") },
- { typeof(MaterialVariable), serializedObject.FindProperty("materialData") },
- { typeof(ObjectVariable), serializedObject.FindProperty("objectData") },
- { typeof(Rigidbody2DVariable), serializedObject.FindProperty("rigidbody2DData") },
- { typeof(SpriteVariable), serializedObject.FindProperty("spriteData") },
- { typeof(TextureVariable), serializedObject.FindProperty("textureData") },
- { typeof(TransformVariable), serializedObject.FindProperty("transformData") },
- { typeof(Vector2Variable), serializedObject.FindProperty("vector2Data") },
- { typeof(Vector3Variable), serializedObject.FindProperty("vector3Data") }
- };
+ conditions = serializedObject.FindProperty("conditions");
}
public override void DrawCommandGUI()
{
serializedObject.Update();
+ EditorGUILayout.PropertyField(serializedObject.FindProperty("anyOrAllConditions"));
+
+ conditions.arraySize = EditorGUILayout.IntField("Size", conditions.arraySize);
+ GUILayout.Label("Conditions", EditorStyles.boldLabel);
+
VariableCondition t = target as VariableCondition;
var flowchart = (Flowchart)t.GetFlowchart();
@@ -55,71 +63,43 @@ namespace Fungus.EditorUtils
return;
}
- // Select Variable
- EditorGUILayout.PropertyField(variableProp);
-
- if (variableProp.objectReferenceValue == null)
+ EditorGUI.indentLevel++;
+ for (int i = 0; i < conditions.arraySize; i++)
{
- serializedObject.ApplyModifiedProperties();
- return;
- }
+ var conditionAnyVar = conditions.GetArrayElementAtIndex(i).FindPropertyRelative("anyVar");
+ var conditionCompare = conditions.GetArrayElementAtIndex(i).FindPropertyRelative("compareOperator");
- // Get selected variable
- Variable selectedVariable = variableProp.objectReferenceValue as Variable;
- System.Type variableType = selectedVariable.GetType();
+ EditorGUILayout.PropertyField(conditionAnyVar, new GUIContent("Variable"), true);
- // Get operators for the variable
- CompareOperator[] compareOperators = VariableCondition.operatorsByVariableType[variableType];
+ // Get selected variable
+ Variable selectedVariable = conditionAnyVar.FindPropertyRelative("variable").objectReferenceValue as Variable;
- // Create operator list
- List operatorsList = new List();
- foreach (var compareOperator in compareOperators)
- {
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- operatorsList.Add(new GUIContent("=="));
- break;
- case CompareOperator.NotEquals:
- operatorsList.Add(new GUIContent("!="));
- break;
- case CompareOperator.LessThan:
- operatorsList.Add(new GUIContent("<"));
- break;
- case CompareOperator.GreaterThan:
- operatorsList.Add(new GUIContent(">"));
- break;
- case CompareOperator.LessThanOrEquals:
- operatorsList.Add(new GUIContent("<="));
- break;
- case CompareOperator.GreaterThanOrEquals:
- operatorsList.Add(new GUIContent(">="));
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " operator has no matching GUIContent.");
- break;
- }
- }
+ if (selectedVariable == null)
+ continue;
- // Get previously selected operator
- int selectedIndex = System.Array.IndexOf(compareOperators, t._CompareOperator);
- if (selectedIndex < 0)
- {
- // Default to first index if the operator is not found in the available operators list
- // This can occur when changing between variable types
- selectedIndex = 0;
- }
+ GUIContent[] operatorsList = emptyList;
+ operatorsList = selectedVariable.IsComparisonSupported() ? compareListAll : compareListEqualOnly;
- selectedIndex = EditorGUILayout.Popup(
- new GUIContent("Compare", "The comparison operator to use when comparing values"),
- selectedIndex,
- operatorsList.ToArray());
+ // Get previously selected operator
+ int selectedIndex = conditionCompare.enumValueIndex;
+ if (selectedIndex < 0 || selectedIndex >= operatorsList.Length)
+ {
+ // Default to first index if the operator is not found in the available operators list
+ // This can occur when changing between variable types
+ selectedIndex = 0;
+ }
- compareOperatorProp.enumValueIndex = (int)compareOperators[selectedIndex];
+ selectedIndex = EditorGUILayout.Popup(
+ new GUIContent("Compare", "The comparison operator to use when comparing values"),
+ selectedIndex,
+ operatorsList);
- EditorGUILayout.PropertyField(propByVariableType[variableType]);
+ conditionCompare.enumValueIndex = selectedIndex;
+ EditorGUILayout.Separator();
+ }
+ EditorGUI.indentLevel--;
serializedObject.ApplyModifiedProperties();
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableEditor.cs b/Assets/Fungus/Scripts/Editor/VariableEditor.cs
index 26918064..83c2a785 100644
--- a/Assets/Fungus/Scripts/Editor/VariableEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/VariableEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
@@ -156,7 +156,15 @@ namespace Fungus.EditorUtils
if (variableProperty.VariableTypes.Length == 0)
{
- return true;
+ var compatChecker = property.serializedObject.targetObject as ICollectionCompatible;
+ if (compatChecker != null)
+ {
+ return compatChecker.IsVarCompatibleWithCollection(v, variableProperty.compatibleVariableName);
+ }
+ else
+ {
+ return true;
+ }
}
return variableProperty.VariableTypes.Contains(v.GetType());
@@ -213,38 +221,47 @@ namespace Fungus.EditorUtils
var origLabel = new GUIContent(label);
- if (EditorGUI.GetPropertyHeight(valueProp, label) > EditorGUIUtility.singleLineHeight)
+ if (EditorGUI.GetPropertyHeight(valueProp, label) <= EditorGUIUtility.singleLineHeight)
{
- DrawMultiLineProperty(position, origLabel, referenceProp, valueProp, flowchart);
+ DrawSingleLineProperty(position, origLabel, referenceProp, valueProp, flowchart, typeInfo);
}
else
{
- DrawSingleLineProperty(position, origLabel, referenceProp, valueProp, flowchart);
+ DrawMultiLineProperty(position, origLabel, referenceProp, valueProp, flowchart, typeInfo);
}
EditorGUI.EndProperty();
}
- protected virtual void DrawSingleLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart)
+ protected virtual void DrawSingleLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart,
+ VariableInfoAttribute typeInfo)
{
- const int popupWidth = 17;
-
+ int popupWidth = Mathf.RoundToInt(EditorGUIUtility.singleLineHeight);
+ const int popupGap = 5;
+
+ //get out starting rect with intent honoured
Rect controlRect = EditorGUI.PrefixLabel(rect, label);
Rect valueRect = controlRect;
- valueRect.width = controlRect.width - popupWidth - 5;
+ valueRect.width = controlRect.width - popupWidth - popupGap;
Rect popupRect = controlRect;
+ //we are overriding much of the auto layout to cram this all on 1 line so zero the intend and restore it later
+ var prevIndent = EditorGUI.indentLevel;
+ EditorGUI.indentLevel = 0;
+
if (referenceProp.objectReferenceValue == null)
{
- EditorGUI.PropertyField(valueRect, valueProp, new GUIContent(""));
- popupRect.x += valueRect.width + 5;
+ DrawValueProperty(valueRect, valueProp, typeInfo);
+ popupRect.x += valueRect.width + popupGap;
popupRect.width = popupWidth;
}
EditorGUI.PropertyField(popupRect, referenceProp, new GUIContent(""));
+ EditorGUI.indentLevel = prevIndent;
}
- protected virtual void DrawMultiLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart)
+ protected virtual void DrawMultiLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart,
+ VariableInfoAttribute typeInfo)
{
const int popupWidth = 100;
@@ -255,7 +272,7 @@ namespace Fungus.EditorUtils
if (referenceProp.objectReferenceValue == null)
{
- EditorGUI.PropertyField(valueRect, valueProp, label);
+ DrawValueProperty(valueRect, valueProp, typeInfo);
popupRect.x = rect.width - popupWidth + 5;
popupRect.width = popupWidth;
}
@@ -267,6 +284,11 @@ namespace Fungus.EditorUtils
EditorGUI.PropertyField(popupRect, referenceProp, new GUIContent(""));
}
+ protected virtual void DrawValueProperty(Rect valueRect, SerializedProperty valueProp, VariableInfoAttribute typeInfo)
+ {
+ CustomVariableDrawerLookup.DrawCustomOrPropertyField(typeof(T), valueRect, valueProp);
+ }
+
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
VariableInfoAttribute typeInfo = VariableEditor.GetVariableInfo(typeof(T));
@@ -309,52 +331,4 @@ namespace Fungus.EditorUtils
[CustomPropertyDrawer (typeof(StringDataMulti))]
public class StringDataMultiDrawer : VariableDataDrawer
{}
-
- [CustomPropertyDrawer (typeof(ColorData))]
- public class ColorDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(Vector2Data))]
- public class Vector2DataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(Vector3Data))]
- public class Vector3DataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(MaterialData))]
- public class MaterialDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(TextureData))]
- public class TextureDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(SpriteData))]
- public class SpriteDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(GameObjectData))]
- public class GameObjectDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(ObjectData))]
- public class ObjectDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(AnimatorData))]
- public class AnimatorDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(TransformData))]
- public class TransformDataDrawer : VariableDataDrawer
- {}
-
- [CustomPropertyDrawer (typeof(AudioSourceData))]
- public class AudioSourceDrawer : VariableDataDrawer
- { }
-
- [CustomPropertyDrawer(typeof(Rigidbody2DData))]
- public class Rigidbody2DDataDrawer : VariableDataDrawer
- { }
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs b/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs
index fc594466..87cd9e04 100644
--- a/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs
+++ b/Assets/Fungus/Scripts/Editor/VariableListAdaptor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -32,7 +32,6 @@ namespace Fungus.EditorUtils
private float[] itemWidths = new float[4];
private Rect[] itemRects = new Rect[4];
- private GUIContent emptyGUIContent = new GUIContent("");
public SerializedProperty this[int index]
{
@@ -130,7 +129,7 @@ namespace Fungus.EditorUtils
_arrayProperty.serializedObject.Update();
this.widthOfList = (w == 0 ? VariableListAdaptor.DefaultWidth : w) - ScrollSpacer;
-
+
int width = widthOfList;
int totalRatio = DefaultWidth;
@@ -249,7 +248,7 @@ namespace Fungus.EditorUtils
bool isGlobal = scopeProp.enumValueIndex == (int)VariableScope.Global;
-
+ var prevEnabled = GUI.enabled;
if (isGlobal && Application.isPlaying)
{
var res = FungusManager.Instance.GlobalVariables.GetVariable(keyProp.stringValue);
@@ -258,18 +257,17 @@ namespace Fungus.EditorUtils
SerializedObject globalValue = new SerializedObject(res);
var globalValProp = globalValue.FindProperty("value");
- var prevEnabled = GUI.enabled;
- GUI.enabled = false;
- EditorGUI.PropertyField(itemRects[2], globalValProp, emptyGUIContent);
-
- GUI.enabled = prevEnabled;
+ GUI.enabled = false;
+ defaultProp = globalValProp;
}
}
- else
- {
- EditorGUI.PropertyField(itemRects[2], defaultProp, emptyGUIContent);
- }
+
+
+ //variable.DrawProperty(rects[2], defaultProp, variableInfo);
+ VariableDrawProperty(variable, itemRects[2], defaultProp, variableInfo);
+
+ GUI.enabled = prevEnabled;
scope = (VariableScope)EditorGUI.EnumPopup(itemRects[3], variable.Scope);
@@ -279,6 +277,22 @@ namespace Fungus.EditorUtils
GUI.backgroundColor = Color.white;
}
+
+ public static void VariableDrawProperty(Variable variable, Rect rect, SerializedProperty valueProp, VariableInfoAttribute info)
+ {
+ if (valueProp == null)
+ {
+ EditorGUI.LabelField(rect, "N/A");
+ }
+ else if (info.IsPreviewedOnly)
+ {
+ EditorGUI.LabelField(rect, variable.ToString());
+ }
+ else
+ {
+ CustomVariableDrawerLookup.DrawCustomOrPropertyField(variable.GetType(), rect, valueProp);
+ }
+ }
private void DoRightClickMenu(int index)
{
diff --git a/Assets/Fungus/Scripts/Editor/VariableReferenceDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableReferenceDrawer.cs
index 4de4917a..609ff273 100644
--- a/Assets/Fungus/Scripts/Editor/VariableReferenceDrawer.cs
+++ b/Assets/Fungus/Scripts/Editor/VariableReferenceDrawer.cs
@@ -1,4 +1,7 @@
-using UnityEditor;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEditor;
using UnityEngine;
namespace Fungus.EditorUtils
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes.meta b/Assets/Fungus/Scripts/Editor/VariableTypes.meta
new file mode 100644
index 00000000..36ee9931
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 2a6d0205484d6934198d80e5c17c6534
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/AnimatorVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/AnimatorVariableDrawer.cs
new file mode 100644
index 00000000..35534d16
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/AnimatorVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(AnimatorData))]
+ public class AnimatorDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/AnimatorVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/AnimatorVariableDrawer.cs.meta
new file mode 100644
index 00000000..d36c9d66
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/AnimatorVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 84539dbf98b813e4686cedce50f7b357
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/AudioSourceVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/AudioSourceVariableDrawer.cs
new file mode 100644
index 00000000..e6baced8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/AudioSourceVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(AudioSourceData))]
+ public class AudioSourceDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/AudioSourceVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/AudioSourceVariableDrawer.cs.meta
new file mode 100644
index 00000000..708d0d43
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/AudioSourceVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9a4d200af6e624043a82349d0ddb1d00
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/CollectionVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/CollectionVariableDrawer.cs
new file mode 100644
index 00000000..a79bf887
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/CollectionVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(CollectionData))]
+ public class CollectionDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/CollectionVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/CollectionVariableDrawer.cs.meta
new file mode 100644
index 00000000..ba5f2c54
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/CollectionVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0ca2523715ad793419e9bf458e118426
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Collider2DVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/Collider2DVariableDrawer.cs
new file mode 100644
index 00000000..9b71d203
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Collider2DVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(Collider2DData))]
+ public class Collider2DDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Collider2DVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/Collider2DVariableDrawer.cs.meta
new file mode 100644
index 00000000..b24337de
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Collider2DVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1002f1c3b8f44a7478aa6a62584e2130
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/ColliderVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/ColliderVariableDrawer.cs
new file mode 100644
index 00000000..1fa2cc43
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/ColliderVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(ColliderData))]
+ public class ColliderDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/ColliderVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/ColliderVariableDrawer.cs.meta
new file mode 100644
index 00000000..743a406e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/ColliderVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6f5d815af71388044ac855fe4baf2941
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/ColorVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/ColorVariableDrawer.cs
new file mode 100644
index 00000000..b6f56471
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/ColorVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(ColorData))]
+ public class ColorDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/ColorVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/ColorVariableDrawer.cs.meta
new file mode 100644
index 00000000..e106118c
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/ColorVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9a1e3fe915382ed4eafe8b3066786a0d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/GameObjectVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/GameObjectVariableDrawer.cs
new file mode 100644
index 00000000..3513d554
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/GameObjectVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(GameObjectData))]
+ public class GameObjectDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/GameObjectVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/GameObjectVariableDrawer.cs.meta
new file mode 100644
index 00000000..cab4b15e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/GameObjectVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a88e8b6529542d94b985398246c6982c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/MaterialVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/MaterialVariableDrawer.cs
new file mode 100644
index 00000000..020dbaf7
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/MaterialVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(MaterialData))]
+ public class MaterialDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/MaterialVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/MaterialVariableDrawer.cs.meta
new file mode 100644
index 00000000..ba7e5fb3
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/MaterialVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 705f2cf9d782c0b45a19981550262842
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Matrix4x4VariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/Matrix4x4VariableDrawer.cs
new file mode 100644
index 00000000..79d4f6c8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Matrix4x4VariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(Matrix4x4Data))]
+ public class Matrix4x4DataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Matrix4x4VariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/Matrix4x4VariableDrawer.cs.meta
new file mode 100644
index 00000000..553347a9
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Matrix4x4VariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 15e98b43732d6564e87e13ccc2490b05
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/QuaternionVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/QuaternionVariableDrawer.cs
new file mode 100644
index 00000000..935cff4e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/QuaternionVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(QuaternionData))]
+ public class QuaternionDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/QuaternionVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/QuaternionVariableDrawer.cs.meta
new file mode 100644
index 00000000..1261d92e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/QuaternionVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4082ac7fed21c8f459d58bb3efda67fc
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Rigidbody2DVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/Rigidbody2DVariableDrawer.cs
new file mode 100644
index 00000000..80391c42
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Rigidbody2DVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(Rigidbody2DData))]
+ public class Rigidbody2DDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Rigidbody2DVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/Rigidbody2DVariableDrawer.cs.meta
new file mode 100644
index 00000000..72d7514f
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Rigidbody2DVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 20e657e82b90c1142bfdd22b835e62e5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/RigidbodyVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/RigidbodyVariableDrawer.cs
new file mode 100644
index 00000000..ed65143e
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/RigidbodyVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(RigidbodyData))]
+ public class RigidbodyDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/RigidbodyVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/RigidbodyVariableDrawer.cs.meta
new file mode 100644
index 00000000..488aed1d
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/RigidbodyVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0f2345a171733574898d4670f1f7bd79
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/SpriteVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/SpriteVariableDrawer.cs
new file mode 100644
index 00000000..0956e1a0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/SpriteVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(SpriteData))]
+ public class SpriteDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/SpriteVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/SpriteVariableDrawer.cs.meta
new file mode 100644
index 00000000..2094444b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/SpriteVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2f47d83bef7102e4b90dfc16aab634c3
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/TextureVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/TextureVariableDrawer.cs
new file mode 100644
index 00000000..537c1be3
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/TextureVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(TextureData))]
+ public class TextureDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/TextureVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/TextureVariableDrawer.cs.meta
new file mode 100644
index 00000000..94d3ee15
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/TextureVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7e870d88e412ce9429a456459523b9ee
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/TransformVariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/TransformVariableDrawer.cs
new file mode 100644
index 00000000..d115a689
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/TransformVariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(TransformData))]
+ public class TransformDataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/TransformVariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/TransformVariableDrawer.cs.meta
new file mode 100644
index 00000000..d99cdb79
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/TransformVariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: dedf63e544976ef4b9cd0571ca926061
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Vector2VariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector2VariableDrawer.cs
new file mode 100644
index 00000000..b9eaf6c0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector2VariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(Vector2Data))]
+ public class Vector2DataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Vector2VariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector2VariableDrawer.cs.meta
new file mode 100644
index 00000000..b12ebd66
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector2VariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 0f6273c292432b54084aefab14c9db23
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Vector3VariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector3VariableDrawer.cs
new file mode 100644
index 00000000..19242769
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector3VariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(Vector3Data))]
+ public class Vector3DataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Vector3VariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector3VariableDrawer.cs.meta
new file mode 100644
index 00000000..689e9ab0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector3VariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b1a5da98543a7354d872bd85ea6467e9
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Vector4VariableDrawer.cs b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector4VariableDrawer.cs
new file mode 100644
index 00000000..5ac33463
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector4VariableDrawer.cs
@@ -0,0 +1,13 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEditor;
+
+namespace Fungus.EditorUtils
+{
+ [CustomPropertyDrawer(typeof(Vector4Data))]
+ public class Vector4DataDrawer : VariableDataDrawer
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Editor/VariableTypes/Vector4VariableDrawer.cs.meta b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector4VariableDrawer.cs.meta
new file mode 100644
index 00000000..b9081d88
--- /dev/null
+++ b/Assets/Fungus/Scripts/Editor/VariableTypes/Vector4VariableDrawer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 05fb86e0e99c98945b8ce4bb5224e8e5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Editor/ViewEditor.cs b/Assets/Fungus/Scripts/Editor/ViewEditor.cs
index cb022172..898c3d7e 100644
--- a/Assets/Fungus/Scripts/Editor/ViewEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/ViewEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/WriteEditor.cs b/Assets/Fungus/Scripts/Editor/WriteEditor.cs
index eaf4870a..c19e1424 100644
--- a/Assets/Fungus/Scripts/Editor/WriteEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/WriteEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs b/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs
index 9a812922..3399032c 100644
--- a/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs
+++ b/Assets/Fungus/Scripts/Editor/WriterAudioEditor.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEditor;
diff --git a/Assets/Fungus/Scripts/EnumFlagAttribute.cs b/Assets/Fungus/Scripts/EnumFlagAttribute.cs
index d923db5b..2ab6081d 100644
--- a/Assets/Fungus/Scripts/EnumFlagAttribute.cs
+++ b/Assets/Fungus/Scripts/EnumFlagAttribute.cs
@@ -1,5 +1,7 @@
-//from http://wiki.unity3d.com/index.php/EnumFlagPropertyDrawer
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+//Adapted from http://wiki.unity3d.com/index.php/EnumFlagPropertyDrawer
//placed in fungus namespace to avoid collisions with your own
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs b/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs
index 38425380..91220923 100644
--- a/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/ButtonClicked.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs b/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs
index afc517de..efe19336 100644
--- a/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs
@@ -1,7 +1,8 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// 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;
+using UnityEngine;
namespace Fungus
{
@@ -12,18 +13,25 @@ namespace Fungus
"Drag Cancelled",
"The block will execute when the player drags an object and releases it without dropping it on a target object.")]
[AddComponentMenu("")]
- public class DragCancelled : EventHandler
- {
+ public class DragCancelled : EventHandler, ISerializationCallbackReceiver
+ {
public class DragCancelledEvent
{
public Draggable2D DraggableObject;
+
public DragCancelledEvent(Draggable2D draggableObject)
{
DraggableObject = draggableObject;
}
}
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable draggableRef;
+
[Tooltip("Draggable object to listen for drag events on")]
+ [SerializeField] protected List draggableObjects;
+
+ [HideInInspector]
[SerializeField] protected Draggable2D draggableObject;
protected EventDispatcher eventDispatcher;
@@ -47,26 +55,61 @@ namespace Fungus
OnDragCancelled(evt.DraggableObject);
}
+ #region Compatibility
+
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
+ {
+ //add any dragableobject already present to list for backwards compatability
+ if (draggableObject != null)
+ {
+ if (!draggableObjects.Contains(draggableObject))
+ {
+ draggableObjects.Add(draggableObject);
+ }
+ draggableObject = null;
+ }
+ }
+
+ void ISerializationCallbackReceiver.OnBeforeSerialize()
+ {
+ }
+
+ #endregion Compatibility
+
#region Public members
public virtual void OnDragCancelled(Draggable2D draggableObject)
{
- if (draggableObject == this.draggableObject)
+ if (draggableObjects.Contains(draggableObject))
{
+ if (draggableRef != null)
+ {
+ draggableRef.Value = draggableObject.gameObject;
+ }
ExecuteBlock();
}
}
public override string GetSummary()
{
- if (draggableObject != null)
+ string summary = "Draggable: ";
+ if (this.draggableObjects != null && this.draggableObjects.Count != 0)
+ {
+ for (int i = 0; i < this.draggableObjects.Count; i++)
+ {
+ if (draggableObjects[i] != null)
+ {
+ summary += draggableObjects[i].name + ",";
+ }
+ }
+ return summary;
+ }
+ else
{
- return draggableObject.name;
+ return "None";
}
-
- return "None";
}
- #endregion
+ #endregion Public members
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs b/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs
index e0c42514..510cc266 100644
--- a/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs
@@ -1,88 +1,150 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// 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;
+using UnityEngine;
namespace Fungus
{
///
/// The block will execute when the player drags an object and successfully drops it on a target object.
+ ///
+ /// ExecuteAlways used to get the Compatibility that we need, use of ISerializationCallbackReceiver is error prone
+ /// when used on Unity controlled objects as it runs on threads other than main thread.
///
[EventHandlerInfo("Sprite",
"Drag Completed",
"The block will execute when the player drags an object and successfully drops it on a target object.")]
[AddComponentMenu("")]
- public class DragCompleted : EventHandler
- {
+ [ExecuteInEditMode]
+ public class DragCompleted : EventHandler, ISerializationCallbackReceiver
+ {
public class DragCompletedEvent
{
public Draggable2D DraggableObject;
+
public DragCompletedEvent(Draggable2D draggableObject)
{
DraggableObject = draggableObject;
}
}
+
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable draggableRef;
+
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable targetRef;
+
[Tooltip("Draggable object to listen for drag events on")]
+ [HideInInspector]
[SerializeField] protected Draggable2D draggableObject;
+ [SerializeField] protected List draggableObjects;
+
[Tooltip("Drag target object to listen for drag events on")]
+ [HideInInspector]
[SerializeField] protected Collider2D targetObject;
-
+
+ [SerializeField] protected List targetObjects;
+
// There's no way to poll if an object is touching another object, so
// we have to listen to the callbacks and track the touching state ourselves.
protected bool overTarget = false;
+ protected Collider2D targetCollider = null;
+
protected EventDispatcher eventDispatcher;
protected virtual void OnEnable()
{
- eventDispatcher = FungusManager.Instance.EventDispatcher;
+ if (Application.isPlaying)
+ {
+ eventDispatcher = FungusManager.Instance.EventDispatcher;
- eventDispatcher.AddListener(OnDragCompletedEvent);
- eventDispatcher.AddListener(OnDragEnteredEvent);
- eventDispatcher.AddListener(OnDragExitedEvent);
+ eventDispatcher.AddListener(OnDragCompletedEvent);
+ eventDispatcher.AddListener(OnDragEnteredEvent);
+ eventDispatcher.AddListener(OnDragExitedEvent);
- if(draggableObject != null)
- {
- draggableObject.RegisterHandler(this);
+ foreach (Draggable2D dragObj in draggableObjects)
+ {
+ dragObj.RegisterHandler(this);
+ }
}
}
protected virtual void OnDisable()
{
- eventDispatcher.RemoveListener(OnDragCompletedEvent);
- eventDispatcher.RemoveListener(OnDragEnteredEvent);
- eventDispatcher.RemoveListener(OnDragExitedEvent);
-
- if(draggableObject != null)
+ if (Application.isPlaying)
{
- draggableObject.UnregisterHandler(this);
- }
+ eventDispatcher.RemoveListener(OnDragCompletedEvent);
+ eventDispatcher.RemoveListener(OnDragEnteredEvent);
+ eventDispatcher.RemoveListener(OnDragExitedEvent);
+
+ foreach (Draggable2D dragObj in draggableObjects)
+ {
+ dragObj.UnregisterHandler(this);
+ }
- eventDispatcher = null;
+ eventDispatcher = null;
+ }
}
- void OnDragCompletedEvent(DragCompletedEvent evt)
+ private void OnDragCompletedEvent(DragCompletedEvent evt)
{
OnDragCompleted(evt.DraggableObject);
}
- void OnDragEnteredEvent(DragEntered.DragEnteredEvent evt)
+ private void OnDragEnteredEvent(DragEntered.DragEnteredEvent evt)
{
OnDragEntered(evt.DraggableObject, evt.TargetCollider);
}
- void OnDragExitedEvent(DragExited.DragExitedEvent evt)
+ private void OnDragExitedEvent(DragExited.DragExitedEvent evt)
{
OnDragExited(evt.DraggableObject, evt.TargetCollider);
}
+ #region Compatibility
+
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
+ {
+ //presentl using awake due to errors on non main thread access of targetCollider
+ }
+
+ void ISerializationCallbackReceiver.OnBeforeSerialize()
+ {
+ }
+
+ private void Awake()
+ {
+ //add any dragableobject already present to list for backwards compatability
+ if (draggableObject != null)
+ {
+ if (!draggableObjects.Contains(draggableObject))
+ {
+ draggableObjects.Add(draggableObject);
+ }
+ }
+
+ if (targetObject != null)
+ {
+ if (!targetObjects.Contains(targetObject))
+ {
+ targetObjects.Add(targetObject);
+ }
+ }
+ draggableObject = null;
+ targetObject = null;
+ }
+
+ #endregion Compatibility
+
#region Public members
///
/// Gets the draggable object.
///
- public virtual Draggable2D DraggableObject { get { return draggableObject; } }
+ public virtual List DraggableObjects { get { return draggableObjects; } }
///
/// Returns true if the draggable object is over the drag target object.
@@ -97,54 +159,80 @@ namespace Fungus
///
public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject)
{
- if (this.targetObject != null &&
- draggableObject == this.draggableObject &&
- targetObject == this.targetObject)
+ if (this.targetObjects != null && this.draggableObjects != null &&
+ this.draggableObjects.Contains(draggableObject) &&
+ this.targetObjects.Contains(targetObject))
{
overTarget = true;
+ targetCollider = targetObject;
}
}
-
+
///
/// Called by the Draggable2D object when the it exits the drag target.
///
public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject)
{
- if (this.targetObject != null &&
- draggableObject == this.draggableObject &&
- targetObject == this.targetObject)
+ if (this.targetObjects != null && this.draggableObjects != null &&
+ this.draggableObjects.Contains(draggableObject) &&
+ this.targetObjects.Contains(targetObject))
{
overTarget = false;
+ targetCollider = null;
}
}
-
+
///
/// Called by the Draggable2D object when the the drag ends over the drag target.
///
public virtual void OnDragCompleted(Draggable2D draggableObject)
{
- if (draggableObject == this.draggableObject &&
+ if (this.draggableObjects.Contains(draggableObject) &&
overTarget)
{
// Assume that the player will have to do perform another drag and drop operation
// to complete the drag again. This is necessary because we don't get an OnDragExited if the
// draggable object is set to be inactive.
+ if (draggableRef != null)
+ {
+ draggableRef.Value = draggableObject.gameObject;
+ }
+ if (targetRef != null)
+ {
+ targetRef.Value = targetCollider.gameObject;
+ }
+
overTarget = false;
-
+ targetCollider = null;
+
ExecuteBlock();
}
}
public override string GetSummary()
{
- string summary = "";
- if (draggableObject != null)
+ string summary = "Draggable: ";
+ if (this.draggableObjects != null && this.draggableObjects.Count != 0)
{
- summary += "\nDraggable: " + draggableObject.name;
+ for (int i = 0; i < this.draggableObjects.Count; i++)
+ {
+ if (draggableObjects[i] != null)
+ {
+ summary += draggableObjects[i].name + ",";
+ }
+ }
}
- if (targetObject != null)
+
+ summary += "\nTarget: ";
+ if (this.targetObjects != null && this.targetObjects.Count != 0)
{
- summary += "\nTarget: " + targetObject.name;
+ for (int i = 0; i < this.targetObjects.Count; i++)
+ {
+ if (targetObjects[i] != null)
+ {
+ summary += targetObjects[i].name + ",";
+ }
+ }
}
if (summary.Length == 0)
@@ -155,6 +243,6 @@ namespace Fungus
return summary;
}
- #endregion
+ #endregion Public members
}
}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs b/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs
index 9c486b75..4d6ccb54 100644
--- a/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/DragEntered.cs
@@ -1,58 +1,115 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
-using UnityEngine;
-using System;
-using System.Collections;
using System.Collections.Generic;
+using UnityEngine;
namespace Fungus
{
///
/// The block will execute when the player is dragging an object which starts touching the target object.
+ ///
+ /// ExecuteAlways used to get the Compatibility that we need, use of ISerializationCallbackReceiver is error prone
+ /// when used on Unity controlled objects as it runs on threads other than main thread.
///
[EventHandlerInfo("Sprite",
"Drag Entered",
"The block will execute when the player is dragging an object which starts touching the target object.")]
[AddComponentMenu("")]
- public class DragEntered : EventHandler
- {
+ [ExecuteInEditMode]
+ public class DragEntered : EventHandler, ISerializationCallbackReceiver
+ {
public class DragEnteredEvent
{
public Draggable2D DraggableObject;
public Collider2D TargetCollider;
+
public DragEnteredEvent(Draggable2D draggableObject, Collider2D targetCollider)
{
DraggableObject = draggableObject;
TargetCollider = targetCollider;
}
}
+
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable draggableRef;
+
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable targetRef;
+
[Tooltip("Draggable object to listen for drag events on")]
+ [HideInInspector]
[SerializeField] protected Draggable2D draggableObject;
+ [SerializeField] protected List draggableObjects;
+
[Tooltip("Drag target object to listen for drag events on")]
+ [HideInInspector]
[SerializeField] protected Collider2D targetObject;
+ [SerializeField] protected List targetObjects;
+
protected EventDispatcher eventDispatcher;
protected virtual void OnEnable()
{
- eventDispatcher = FungusManager.Instance.EventDispatcher;
+ if (Application.isPlaying)
+ {
+ eventDispatcher = FungusManager.Instance.EventDispatcher;
- eventDispatcher.AddListener(OnDragEnteredEvent);
+ eventDispatcher.AddListener(OnDragEnteredEvent);
+ }
}
protected virtual void OnDisable()
{
- eventDispatcher.RemoveListener(OnDragEnteredEvent);
+ if (Application.isPlaying)
+ {
+ eventDispatcher.RemoveListener(OnDragEnteredEvent);
- eventDispatcher = null;
+ eventDispatcher = null;
+ }
}
- void OnDragEnteredEvent(DragEnteredEvent evt)
+ private void OnDragEnteredEvent(DragEnteredEvent evt)
{
OnDragEntered(evt.DraggableObject, evt.TargetCollider);
}
+
+ #region Compatibility
+
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
+ {
+ }
+
+ void ISerializationCallbackReceiver.OnBeforeSerialize()
+ {
+ }
+
+ private void Awake()
+ {
+ //add any dragableobject already present to list for backwards compatability
+ if (draggableObject != null)
+ {
+ if (!draggableObjects.Contains(draggableObject))
+ {
+ draggableObjects.Add(draggableObject);
+ }
+ }
+
+ if (targetObject != null)
+ {
+ if (!targetObjects.Contains(targetObject))
+ {
+ targetObjects.Add(targetObject);
+ }
+ }
+ draggableObject = null;
+ targetObject = null;
+ }
+
+ #endregion Compatibility
+
#region Public members
///
@@ -60,33 +117,56 @@ namespace Fungus
///
public virtual void OnDragEntered(Draggable2D draggableObject, Collider2D targetObject)
{
- if (draggableObject == this.draggableObject &&
- targetObject == this.targetObject)
+ if (this.targetObjects != null && this.draggableObjects != null &&
+ this.draggableObjects.Contains(draggableObject) &&
+ this.targetObjects.Contains(targetObject))
{
+ if (draggableRef != null)
+ {
+ draggableRef.Value = draggableObject.gameObject;
+ }
+ if (targetRef != null)
+ {
+ targetRef.Value = targetObject.gameObject;
+ }
ExecuteBlock();
}
}
public override string GetSummary()
{
- string summary = "";
- if (draggableObject != null)
+ string summary = "Draggable: ";
+ if (this.draggableObjects != null && this.draggableObjects.Count != 0)
{
- summary += "\nDraggable: " + draggableObject.name;
+ for (int i = 0; i < this.draggableObjects.Count; i++)
+ {
+ if (draggableObjects[i] != null)
+ {
+ summary += draggableObjects[i].name + ",";
+ }
+ }
}
- if (targetObject != null)
+
+ summary += "\nTarget: ";
+ if (this.targetObjects != null && this.targetObjects.Count != 0)
{
- summary += "\nTarget: " + targetObject.name;
+ for (int i = 0; i < this.targetObjects.Count; i++)
+ {
+ if (targetObjects[i] != null)
+ {
+ summary += targetObjects[i].name + ",";
+ }
+ }
}
-
+
if (summary.Length == 0)
{
return "None";
}
-
+
return summary;
}
- #endregion
+ #endregion Public members
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/DragExited.cs b/Assets/Fungus/Scripts/EventHandlers/DragExited.cs
index 446a0c9d..d99ff271 100644
--- a/Assets/Fungus/Scripts/EventHandlers/DragExited.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/DragExited.cs
@@ -1,23 +1,29 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// 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;
+using UnityEngine;
namespace Fungus
{
///
/// The block will execute when the player is dragging an object which stops touching the target object.
+ ///
+ /// ExecuteAlways used to get the Compatibility that we need, use of ISerializationCallbackReceiver is error prone
+ /// when used on Unity controlled objects as it runs on threads other than main thread.
///
[EventHandlerInfo("Sprite",
"Drag Exited",
"The block will execute when the player is dragging an object which stops touching the target object.")]
[AddComponentMenu("")]
- public class DragExited : EventHandler
- {
+ [ExecuteInEditMode]
+ public class DragExited : EventHandler, ISerializationCallbackReceiver
+ {
public class DragExitedEvent
{
public Draggable2D DraggableObject;
public Collider2D TargetCollider;
+
public DragExitedEvent(Draggable2D draggableObject, Collider2D targetCollider)
{
DraggableObject = draggableObject;
@@ -25,33 +31,85 @@ namespace Fungus
}
}
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable draggableRef;
+
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable targetRef;
+
[Tooltip("Draggable object to listen for drag events on")]
+ [HideInInspector]
[SerializeField] protected Draggable2D draggableObject;
+ [SerializeField] protected List draggableObjects;
+
[Tooltip("Drag target object to listen for drag events on")]
+ [HideInInspector]
[SerializeField] protected Collider2D targetObject;
+ [SerializeField] protected List targetObjects;
+
protected EventDispatcher eventDispatcher;
protected virtual void OnEnable()
{
- eventDispatcher = FungusManager.Instance.EventDispatcher;
+ if (Application.isPlaying)
+ {
+ eventDispatcher = FungusManager.Instance.EventDispatcher;
- eventDispatcher.AddListener(OnDragEnteredEvent);
+ eventDispatcher.AddListener(OnDragEnteredEvent);
+ }
}
protected virtual void OnDisable()
{
- eventDispatcher.RemoveListener(OnDragEnteredEvent);
+ if (Application.isPlaying)
+ {
+ eventDispatcher.RemoveListener(OnDragEnteredEvent);
- eventDispatcher = null;
+ eventDispatcher = null;
+ }
}
- void OnDragEnteredEvent(DragExitedEvent evt)
+ private void OnDragEnteredEvent(DragExitedEvent evt)
{
OnDragExited(evt.DraggableObject, evt.TargetCollider);
}
+ #region Compatibility
+
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
+ {
+ }
+
+ void ISerializationCallbackReceiver.OnBeforeSerialize()
+ {
+ }
+
+ private void Awake()
+ {
+ //add any dragableobject already present to list for backwards compatability
+ if (draggableObject != null)
+ {
+ if (!draggableObjects.Contains(draggableObject))
+ {
+ draggableObjects.Add(draggableObject);
+ }
+ }
+
+ if (targetObject != null)
+ {
+ if (!targetObjects.Contains(targetObject))
+ {
+ targetObjects.Add(targetObject);
+ }
+ }
+ draggableObject = null;
+ targetObject = null;
+ }
+
+ #endregion Compatibility
+
#region Public members
///
@@ -59,33 +117,56 @@ namespace Fungus
///
public virtual void OnDragExited(Draggable2D draggableObject, Collider2D targetObject)
{
- if (draggableObject == this.draggableObject &&
- targetObject == this.targetObject)
+ if (this.targetObjects != null && this.draggableObjects != null &&
+ this.draggableObjects.Contains(draggableObject) &&
+ this.targetObjects.Contains(targetObject))
{
+ if (draggableRef != null)
+ {
+ draggableRef.Value = draggableObject.gameObject;
+ }
+ if (targetRef != null)
+ {
+ targetRef.Value = targetObject.gameObject;
+ }
ExecuteBlock();
}
}
public override string GetSummary()
{
- string summary = "";
- if (draggableObject != null)
+ string summary = "Draggable: ";
+ if (this.draggableObjects != null && this.draggableObjects.Count != 0)
{
- summary += "\nDraggable: " + draggableObject.name;
+ for (int i = 0; i < this.draggableObjects.Count; i++)
+ {
+ if (draggableObjects[i] != null)
+ {
+ summary += draggableObjects[i].name + ",";
+ }
+ }
}
- if (targetObject != null)
+
+ summary += "\nTarget: ";
+ if (this.targetObjects != null && this.targetObjects.Count != 0)
{
- summary += "\nTarget: " + targetObject.name;
+ for (int i = 0; i < this.targetObjects.Count; i++)
+ {
+ if (targetObjects[i] != null)
+ {
+ summary += targetObjects[i].name + ",";
+ }
+ }
}
-
+
if (summary.Length == 0)
{
return "None";
}
-
+
return summary;
}
- #endregion
+ #endregion Public members
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs b/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs
index 49134dbb..077455c2 100644
--- a/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/DragStarted.cs
@@ -1,7 +1,8 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// 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;
+using UnityEngine;
namespace Fungus
{
@@ -12,17 +13,24 @@ namespace Fungus
"Drag Started",
"The block will execute when the player starts dragging an object.")]
[AddComponentMenu("")]
- public class DragStarted : EventHandler
- {
+ public class DragStarted : EventHandler, ISerializationCallbackReceiver
+ {
public class DragStartedEvent
{
public Draggable2D DraggableObject;
+
public DragStartedEvent(Draggable2D draggableObject)
{
DraggableObject = draggableObject;
}
}
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable draggableRef;
+
+ [SerializeField] protected List draggableObjects;
+
+ [HideInInspector]
[SerializeField] protected Draggable2D draggableObject;
protected EventDispatcher eventDispatcher;
@@ -41,11 +49,32 @@ namespace Fungus
eventDispatcher = null;
}
- void OnDragStartedEvent(DragStartedEvent evt)
+ private void OnDragStartedEvent(DragStartedEvent evt)
{
OnDragStarted(evt.DraggableObject);
}
+ #region Compatibility
+
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
+ {
+ //add any dragableobject already present to list for backwards compatability
+ if (draggableObject != null)
+ {
+ if (!draggableObjects.Contains(draggableObject))
+ {
+ draggableObjects.Add(draggableObject);
+ }
+ draggableObject = null;
+ }
+ }
+
+ void ISerializationCallbackReceiver.OnBeforeSerialize()
+ {
+ }
+
+ #endregion Compatibility
+
#region Public members
///
@@ -53,22 +82,38 @@ namespace Fungus
///
public virtual void OnDragStarted(Draggable2D draggableObject)
{
- if (draggableObject == this.draggableObject)
+ if (draggableObjects.Contains(draggableObject))
{
+ if (draggableRef != null)
+ {
+ draggableRef.Value = draggableObject.gameObject;
+ }
ExecuteBlock();
}
}
public override string GetSummary()
{
- if (draggableObject != null)
+ string summary = "Draggable: ";
+ if (this.draggableObjects != null && this.draggableObjects.Count != 0)
{
- return draggableObject.name;
+ for (int i = 0; i < this.draggableObjects.Count; i++)
+ {
+ if (draggableObjects[i] != null)
+ {
+ summary += draggableObjects[i].name + ",";
+ }
+ }
}
-
- return "None";
+
+ if (summary.Length == 0)
+ {
+ return "None";
+ }
+
+ return summary;
}
- #endregion
+ #endregion Public members
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs b/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs
index 2ca80601..899f6b97 100644
--- a/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/EndEdit.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/FlowchartEnabled.cs b/Assets/Fungus/Scripts/EventHandlers/FlowchartEnabled.cs
index 18c10305..707ac7d5 100644
--- a/Assets/Fungus/Scripts/EventHandlers/FlowchartEnabled.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/FlowchartEnabled.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/GameStarted.cs b/Assets/Fungus/Scripts/EventHandlers/GameStarted.cs
index 3f4c0fa9..1f9b38f2 100644
--- a/Assets/Fungus/Scripts/EventHandlers/GameStarted.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/GameStarted.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs b/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs
index 4bd6147d..10a99822 100644
--- a/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/KeyPressed.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs b/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs
index 2ba62983..ce3937c3 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MessageReceived.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/AnimatorState.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/AnimatorState.cs
index 9cff9eef..0d9f9759 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/AnimatorState.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/AnimatorState.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/ApplicationState.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/ApplicationState.cs
index 6d4efee2..0a886afa 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/ApplicationState.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/ApplicationState.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/BasePhysicsEventHandler.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/BasePhysicsEventHandler.cs
index ffe4b120..a4da5187 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/BasePhysicsEventHandler.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/BasePhysicsEventHandler.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
using UnityEngine.UI;
namespace Fungus
@@ -18,17 +21,9 @@ namespace Fungus
Exit = 1 << 2,
}
- [Tooltip("Which of the 3d physics messages to we trigger on.")]
+ [Tooltip("Which of the physics messages do we trigger on.")]
[SerializeField]
[EnumFlag]
protected PhysicsMessageType FireOn = PhysicsMessageType.Enter;
-
- protected void ProcessCollider(PhysicsMessageType from, string tagOnOther)
- {
- if ((from & FireOn) != 0)
- {
- ProcessTagFilter(tagOnOther);
- }
- }
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/CharacterControllerCollide.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/CharacterControllerCollide.cs
index e247a7d1..9993fb20 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/CharacterControllerCollide.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/CharacterControllerCollide.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -13,10 +16,21 @@ namespace Fungus
[AddComponentMenu("")]
public class CharacterControllerCollide : TagFilteredEventHandler
{
+ [Tooltip("Optional variable to store the ControllerColliderHit")]
+ [VariableProperty(typeof(ControllerColliderHitVariable))]
+ [SerializeField] protected ControllerColliderHitVariable colHitVar;
private void OnControllerColliderHit(ControllerColliderHit hit)
{
- ProcessTagFilter(hit.gameObject.tag);
+ if (DoesPassFilter(hit.gameObject.tag))
+ {
+ if (colHitVar != null)
+ {
+ colHitVar.Value = hit;
+ }
+
+ ExecuteBlock();
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision.cs
index a9305c99..48f165c7 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
using UnityEngine.UI;
namespace Fungus
@@ -13,19 +16,35 @@ namespace Fungus
[AddComponentMenu("")]
public class Collision : BasePhysicsEventHandler
{
+ [Tooltip("Optional variable to store the collision object that is provided by Unity.")]
+ [VariableProperty(typeof(CollisionVariable))]
+ [SerializeField] protected CollisionVariable collisionVar;
+
private void OnCollisionEnter(UnityEngine.Collision collision)
{
- ProcessCollider(PhysicsMessageType.Enter, collision.collider.tag);
+ ProcessCollisionEvent(PhysicsMessageType.Enter, collision);
}
private void OnCollisionStay(UnityEngine.Collision collision)
{
- ProcessCollider(PhysicsMessageType.Stay, collision.collider.tag);
+ ProcessCollisionEvent(PhysicsMessageType.Stay, collision);
}
private void OnCollisionExit(UnityEngine.Collision collision)
{
- ProcessCollider(PhysicsMessageType.Exit, collision.collider.tag);
+ ProcessCollisionEvent(PhysicsMessageType.Exit, collision);
+ }
+
+ private void ProcessCollisionEvent(PhysicsMessageType from, UnityEngine.Collision collision)
+ {
+ if ((from & FireOn) != 0 &&
+ DoesPassFilter(collision.collider.tag))
+ {
+ if (collisionVar != null)
+ collisionVar.Value = collision;
+
+ ExecuteBlock();
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision2D.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision2D.cs
index 1666feee..10a31a96 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision2D.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Collision2D.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
using UnityEngine.UI;
namespace Fungus
@@ -12,19 +15,35 @@ namespace Fungus
[AddComponentMenu("")]
public class Collision2D : BasePhysicsEventHandler
{
+ [Tooltip("Optional variable to store the collision object that is provided by Unity.")]
+ [VariableProperty(typeof(Collision2DVariable))]
+ [SerializeField] protected Collision2DVariable collisionVar;
+
private void OnCollisionEnter2D(UnityEngine.Collision2D collision)
{
- ProcessCollider(PhysicsMessageType.Enter, collision.collider.tag);
+ ProcessCollisionEvent(PhysicsMessageType.Enter, collision);
}
private void OnCollisionStay2D(UnityEngine.Collision2D collision)
{
- ProcessCollider(PhysicsMessageType.Stay, collision.collider.tag);
+ ProcessCollisionEvent(PhysicsMessageType.Stay, collision);
}
private void OnCollisionExit2D(UnityEngine.Collision2D collision)
{
- ProcessCollider(PhysicsMessageType.Exit, collision.collider.tag);
+ ProcessCollisionEvent(PhysicsMessageType.Exit, collision);
+ }
+
+ private void ProcessCollisionEvent(PhysicsMessageType from, UnityEngine.Collision2D collision)
+ {
+ if ((from & FireOn) != 0 &&
+ DoesPassFilter(collision.collider.tag))
+ {
+ if (collisionVar != null)
+ collisionVar.Value = collision;
+
+ ExecuteBlock();
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Mouse.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Mouse.cs
index 49c4cb6f..e2e09d2c 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Mouse.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Mouse.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Particle.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Particle.cs
index a7c66433..25192fc5 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Particle.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Particle.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -27,11 +30,23 @@ namespace Fungus
[EnumFlag]
protected ParticleMessageFlags FireOn = ParticleMessageFlags.OnParticleCollision;
+ [Tooltip("Optional variable to store the gameobject that particle collided with.")]
+ [VariableProperty(typeof(GameObjectVariable))]
+ [SerializeField] protected GameObjectVariable GOcolliderVar;
+
private void OnParticleCollision(GameObject other)
{
if ((FireOn & ParticleMessageFlags.OnParticleCollision) != 0)
{
- ProcessTagFilter(other.tag);
+ if (DoesPassFilter(other.tag))
+ {
+ if (GOcolliderVar != null)
+ {
+ GOcolliderVar.Value = other;
+ }
+
+ ExecuteBlock();
+ }
}
}
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Render.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Render.cs
index 4aa2077b..45c30dc7 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Render.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Render.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TagFilteredEventHandler.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TagFilteredEventHandler.cs
index 8cd7782e..3abfb9db 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TagFilteredEventHandler.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TagFilteredEventHandler.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
using UnityEngine.UI;
@@ -15,17 +18,15 @@ namespace Fungus
protected void ProcessTagFilter(string tagOnOther)
{
- if (tagFilter.Length == 0)
+ if (DoesPassFilter(tagOnOther))
{
ExecuteBlock();
}
- else
- {
- if (System.Array.IndexOf(tagFilter, tagOnOther) != -1)
- {
- ExecuteBlock();
- }
- }
+ }
+
+ protected bool DoesPassFilter(string tagOnOther)
+ {
+ return tagFilter.Length == 0 || System.Array.IndexOf(tagFilter, tagOnOther) != -1;
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TransformChanged.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TransformChanged.cs
index 2dee96b5..9754d8e9 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TransformChanged.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/TransformChanged.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger.cs
index 53b94f2b..ae0020b5 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger.cs
@@ -1,4 +1,7 @@
-using UnityEngine;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
using UnityEngine.UI;
namespace Fungus
@@ -12,19 +15,36 @@ namespace Fungus
[AddComponentMenu("")]
public class Trigger : BasePhysicsEventHandler
{
+ [Tooltip("Optional variable to store the collider that caused the trigger to occur.")]
+ [VariableProperty(typeof(ColliderVariable))]
+ [SerializeField] protected ColliderVariable colliderVar;
+
private void OnTriggerEnter(Collider col)
{
- ProcessCollider(PhysicsMessageType.Enter, col.tag);
+ ProcessCollider(PhysicsMessageType.Enter, col);
}
private void OnTriggerStay(Collider col)
{
- ProcessCollider(PhysicsMessageType.Stay, col.tag);
+ ProcessCollider(PhysicsMessageType.Stay, col);
}
private void OnTriggerExit(Collider col)
{
- ProcessCollider(PhysicsMessageType.Exit, col.tag);
+ ProcessCollider(PhysicsMessageType.Exit, col);
+ }
+
+ protected void ProcessCollider(PhysicsMessageType from, Collider other)
+ {
+ if ((from & FireOn) != 0 && DoesPassFilter(other.tag))
+ {
+ if (colliderVar != null)
+ {
+ colliderVar.Value = other;
+ }
+
+ ExecuteBlock();
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger2D.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger2D.cs
index 5f9b9280..5cad1e19 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger2D.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/Trigger2D.cs
@@ -1,10 +1,12 @@
-using UnityEngine;
-using UnityEngine.UI;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
namespace Fungus
{
///
- /// The block will execute when a 2d physics trigger matching some basic conditions is met.
+ /// The block will execute when a 2d physics trigger matching some basic conditions is met.
///
[EventHandlerInfo("MonoBehaviour",
"Trigger2D",
@@ -12,20 +14,36 @@ namespace Fungus
[AddComponentMenu("")]
public class Trigger2D : BasePhysicsEventHandler
{
+ [Tooltip("Optional variable to store the collider that caused the trigger to occur.")]
+ [VariableProperty(typeof(Collider2DVariable))]
+ [SerializeField] protected Collider2DVariable colliderVar;
+
private void OnTriggerEnter2D(Collider2D col)
{
- ProcessCollider(PhysicsMessageType.Enter, col.tag);
+ ProcessCollider(PhysicsMessageType.Enter, col);
}
-
+
private void OnTriggerStay2D(Collider2D col)
{
- ProcessCollider(PhysicsMessageType.Stay, col.tag);
+ ProcessCollider(PhysicsMessageType.Stay, col);
}
private void OnTriggerExit2D(Collider2D col)
{
- ProcessCollider(PhysicsMessageType.Exit, col.tag);
+ ProcessCollider(PhysicsMessageType.Exit, col);
}
+ protected void ProcessCollider(PhysicsMessageType from, Collider2D other)
+ {
+ if ((from & FireOn) != 0 && DoesPassFilter(other.tag))
+ {
+ if (colliderVar != null)
+ {
+ colliderVar.Value = other;
+ }
+
+ ExecuteBlock();
+ }
+ }
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/UpdateTick.cs b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/UpdateTick.cs
index b958c00f..8e1864a7 100644
--- a/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/UpdateTick.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/MonoBehaviour/UpdateTick.cs
@@ -1,5 +1,6 @@
-using System.Collections;
-using System.Collections.Generic;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
@@ -13,7 +14,6 @@ namespace Fungus
[AddComponentMenu("")]
public class UpdateTick : EventHandler
{
-
[System.Flags]
public enum UpdateMessageFlags
{
@@ -29,7 +29,7 @@ namespace Fungus
private void Update()
{
- if((FireOn & UpdateMessageFlags.Update) != 0)
+ if ((FireOn & UpdateMessageFlags.Update) != 0)
{
ExecuteBlock();
}
@@ -51,4 +51,4 @@ namespace Fungus
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs b/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs
index 20b72d7d..d0be0c80 100644
--- a/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/ObjectClicked.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs b/Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs
index f95d8682..1bf9f300 100644
--- a/Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/SavePointLoaded.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/EventHandlers/ToggleChanged.cs b/Assets/Fungus/Scripts/EventHandlers/ToggleChanged.cs
index 18b974af..e472d092 100644
--- a/Assets/Fungus/Scripts/EventHandlers/ToggleChanged.cs
+++ b/Assets/Fungus/Scripts/EventHandlers/ToggleChanged.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Interfaces/IBlockCaller.cs b/Assets/Fungus/Scripts/Interfaces/IBlockCaller.cs
index 54d85240..18bb0e2a 100644
--- a/Assets/Fungus/Scripts/Interfaces/IBlockCaller.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IBlockCaller.cs
@@ -1,4 +1,7 @@
-namespace Fungus
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
{
///
/// Interface for indicating that the class holds a reference to and may call a block
diff --git a/Assets/Fungus/Scripts/Interfaces/ICollectionCompatible.cs b/Assets/Fungus/Scripts/Interfaces/ICollectionCompatible.cs
new file mode 100644
index 00000000..c9c0c3c5
--- /dev/null
+++ b/Assets/Fungus/Scripts/Interfaces/ICollectionCompatible.cs
@@ -0,0 +1,14 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ ///
+ /// Interface to allow the VariableEditor to check that a given fungus variable is compatibile with the object it resides
+ /// within, such as in the collection base command
+ ///
+ public interface ICollectionCompatible
+ {
+ bool IsVarCompatibleWithCollection(Fungus.Variable variableInQuestion, string compatibleWith);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Interfaces/ICollectionCompatible.cs.meta b/Assets/Fungus/Scripts/Interfaces/ICollectionCompatible.cs.meta
new file mode 100644
index 00000000..54710ca7
--- /dev/null
+++ b/Assets/Fungus/Scripts/Interfaces/ICollectionCompatible.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8162d81948debc44388945f059f14637
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Interfaces/IDialogInputListener.cs b/Assets/Fungus/Scripts/Interfaces/IDialogInputListener.cs
index 3693b63d..83d5f18d 100644
--- a/Assets/Fungus/Scripts/Interfaces/IDialogInputListener.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IDialogInputListener.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Interfaces/IFungusCollection.cs b/Assets/Fungus/Scripts/Interfaces/IFungusCollection.cs
new file mode 100644
index 00000000..5d0875f5
--- /dev/null
+++ b/Assets/Fungus/Scripts/Interfaces/IFungusCollection.cs
@@ -0,0 +1,72 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ ///
+ /// Extension of IList for Fungus collections and support for associated commands.
+ ///
+ /// Built upon objects being passed in and returned as the base starting point.
+ /// The inherited classes may wish to provided typed access to underlying container,
+ /// this is what the Fungus.GenericCollection does.
+ ///
+ public interface IFungusCollection : System.Collections.IList
+ {
+ int Capacity { get; set; }
+ string Name { get; }
+
+ void Add(IFungusCollection rhsCol);
+
+ void AddUnique(object o);
+
+ void AddUnique(IFungusCollection rhsCol);
+
+ System.Type ContainedType();
+
+ bool ContainsAllOf(IFungusCollection rhsCol);
+
+ bool ContainsAllOfOrdered(IFungusCollection rhsCol);
+
+ bool ContainsAnyOf(IFungusCollection rhsCol);
+
+ void CopyFrom(IFungusCollection rhsCol);
+
+ void CopyFrom(System.Array array);
+
+ void CopyFrom(System.Collections.IList list);
+
+ void Exclusive(IFungusCollection rhsCol);
+
+ object Get(int index);
+
+ void Get(int index, ref Variable variable);
+
+ void Intersection(IFungusCollection rhsCol);
+
+ bool IsCollectionCompatible(object o);
+
+ bool IsElementCompatible(object o);
+
+ int LastIndexOf(object o);
+
+ int Occurrences(object o);
+
+ void RemoveAll(IFungusCollection rhsCol);
+
+ void RemoveAll(object o);
+
+ void Reserve(int count);
+
+ void Resize(int count);
+
+ void Reverse();
+
+ void Set(int index, object o);
+
+ void Shuffle();
+
+ void Sort();
+
+ void Unique();
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Interfaces/IFungusCollection.cs.meta b/Assets/Fungus/Scripts/Interfaces/IFungusCollection.cs.meta
new file mode 100644
index 00000000..5a5c3812
--- /dev/null
+++ b/Assets/Fungus/Scripts/Interfaces/IFungusCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 25858096aa47be24c92616be98863f8e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Interfaces/ILocalizable.cs b/Assets/Fungus/Scripts/Interfaces/ILocalizable.cs
index 47dd863b..3c02ae75 100644
--- a/Assets/Fungus/Scripts/Interfaces/ILocalizable.cs
+++ b/Assets/Fungus/Scripts/Interfaces/ILocalizable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Interfaces/IStringLocationIdentifier.cs b/Assets/Fungus/Scripts/Interfaces/IStringLocationIdentifier.cs
index 288e9f59..72fbbba6 100644
--- a/Assets/Fungus/Scripts/Interfaces/IStringLocationIdentifier.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IStringLocationIdentifier.cs
@@ -1,4 +1,7 @@
-namespace Fungus
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
{
///
/// Interface for providing a human readable path to an element, used in editor code to determine where
diff --git a/Assets/Fungus/Scripts/Interfaces/IUpdateable.cs b/Assets/Fungus/Scripts/Interfaces/IUpdateable.cs
index 6f9e9188..74ae946a 100644
--- a/Assets/Fungus/Scripts/Interfaces/IUpdateable.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IUpdateable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Interfaces/IVariableReference.cs b/Assets/Fungus/Scripts/Interfaces/IVariableReference.cs
index d6848f72..c9018532 100644
--- a/Assets/Fungus/Scripts/Interfaces/IVariableReference.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IVariableReference.cs
@@ -1,4 +1,7 @@
-namespace Fungus
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
{
///
/// Interface for indicating that the class holds a reference to a fungus variable, used primarily in editor.
diff --git a/Assets/Fungus/Scripts/Interfaces/IWriterListener.cs b/Assets/Fungus/Scripts/Interfaces/IWriterListener.cs
index c770570d..3c83bfff 100644
--- a/Assets/Fungus/Scripts/Interfaces/IWriterListener.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IWriterListener.cs
@@ -1,8 +1,7 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
-using System.Collections;
namespace Fungus
{
@@ -28,10 +27,20 @@ namespace Fungus
/// Called when the Writer has resumed writing text.
void OnResume();
- /// Called when the Writer has finished writing text.
+ /// Called when the Writer has finished.
/// Controls whether audio should be stopped when writing ends.
void OnEnd(bool stopAudio);
+ ///
+ /// Called when the Writer has no more Words remaining, but may have waits or other tokens still pending.
+ /// Will not be called if there is NO Words for the writer to process in the first place. e.g. Audio only says
+ /// do not trigger this.
+ ///
+ /// Note that the writer does not know what may happen after it's job is done. If a following Say does
+ /// not clear the existing, you'll get what looks like AllWordsWritten and then more words written.
+ ///
+ void OnAllWordsWritten();
+
/// Called every time the Writer writes a new character glyph.
void OnGlyph();
diff --git a/Assets/Fungus/Scripts/Interfaces/IWriterTextDestination.cs b/Assets/Fungus/Scripts/Interfaces/IWriterTextDestination.cs
index 867dc35b..6104235b 100644
--- a/Assets/Fungus/Scripts/Interfaces/IWriterTextDestination.cs
+++ b/Assets/Fungus/Scripts/Interfaces/IWriterTextDestination.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Signals/BlockSignals.cs b/Assets/Fungus/Scripts/Signals/BlockSignals.cs
index 720abb6a..f9b558f0 100644
--- a/Assets/Fungus/Scripts/Signals/BlockSignals.cs
+++ b/Assets/Fungus/Scripts/Signals/BlockSignals.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Signals/FungusActiveSignals.cs b/Assets/Fungus/Scripts/Signals/FungusActiveSignals.cs
index f28f75bd..b0474271 100644
--- a/Assets/Fungus/Scripts/Signals/FungusActiveSignals.cs
+++ b/Assets/Fungus/Scripts/Signals/FungusActiveSignals.cs
@@ -1,4 +1,7 @@
-namespace Fungus
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
{
///
/// Fungus Priority event signalling system.
diff --git a/Assets/Fungus/Scripts/Signals/MenuSignals.cs b/Assets/Fungus/Scripts/Signals/MenuSignals.cs
index 0f5e8c1f..d2e36bdf 100644
--- a/Assets/Fungus/Scripts/Signals/MenuSignals.cs
+++ b/Assets/Fungus/Scripts/Signals/MenuSignals.cs
@@ -1,4 +1,7 @@
-namespace Fungus
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
{
///
/// Menu change event signalling system.
diff --git a/Assets/Fungus/Scripts/Signals/SaveManagerSignals.cs b/Assets/Fungus/Scripts/Signals/SaveManagerSignals.cs
index 02bb060b..55d9a371 100644
--- a/Assets/Fungus/Scripts/Signals/SaveManagerSignals.cs
+++ b/Assets/Fungus/Scripts/Signals/SaveManagerSignals.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Signals/WriterSignals.cs b/Assets/Fungus/Scripts/Signals/WriterSignals.cs
index 86b59c76..511266ab 100644
--- a/Assets/Fungus/Scripts/Signals/WriterSignals.cs
+++ b/Assets/Fungus/Scripts/Signals/WriterSignals.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
namespace Fungus
diff --git a/Assets/Fungus/Scripts/Utils/AllVariableTypes.cs b/Assets/Fungus/Scripts/Utils/AllVariableTypes.cs
new file mode 100644
index 00000000..79f7dbe0
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/AllVariableTypes.cs
@@ -0,0 +1,311 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections.Generic;
+
+namespace Fungus
+{
+ ///
+ /// Static cache of all fungus variable types, used by commands that are designed to work on
+ /// any and all variable types supported by Fungus.
+ ///
+ /// New types created need to be added to the list below and also to AnyVariableData and
+ /// AnyVaraibleAndDataPair
+ ///
+ public static class AllVariableTypes
+ {
+ public enum VariableAny
+ {
+ Any
+ }
+
+ public static readonly System.Type[] AllFungusVarTypes = new System.Type[]
+ {
+ typeof(AnimatorVariable),
+ typeof(AudioSourceVariable),
+ typeof(BooleanVariable),
+ typeof(CollectionVariable),
+ typeof(Collider2DVariable),
+ typeof(ColliderVariable),
+ typeof(Collision2DVariable),
+ typeof(CollisionVariable),
+ typeof(ColorVariable),
+ typeof(ControllerColliderHitVariable),
+ typeof(FloatVariable),
+ typeof(GameObjectVariable),
+ typeof(IntegerVariable),
+ typeof(MaterialVariable),
+ typeof(Matrix4x4Variable),
+ typeof(ObjectVariable),
+ typeof(QuaternionVariable),
+ typeof(Rigidbody2DVariable),
+ typeof(RigidbodyVariable),
+ typeof(SpriteVariable),
+ typeof(StringVariable),
+ typeof(TextureVariable),
+ typeof(TransformVariable),
+ typeof(Vector2Variable),
+ typeof(Vector3Variable),
+ typeof(Vector4Variable),
+ };
+ }
+
+ ///
+ /// Collection of every Fungus VariableData type, used in commands that are designed to
+ /// support any and all types. Those command just have a AnyVariableData anyVar or
+ /// an AnyVaraibleAndDataPair anyVarDataPair to encapsulate the more unpleasant parts.
+ ///
+ /// New types created need to be added to the list below and also to AllVariableTypes and
+ /// AnyVaraibleAndDataPair
+ ///
+ [System.Serializable]
+ public partial struct AnyVariableData
+ {
+ public AnimatorData animatorData;
+ public AudioSourceData audioSourceData;
+ public BooleanData booleanData;
+ public CollectionData collectionData;
+ public Collider2DData collider2DData;
+ public ColliderData colliderData;
+ public ColorData colorData;
+ public FloatData floatData;
+ public GameObjectData gameObjectData;
+ public IntegerData integerData;
+ public MaterialData materialData;
+ public Matrix4x4Data matrix4x4Data;
+ public ObjectData objectData;
+ public QuaternionData quaternionData;
+ public Rigidbody2DData rigidbody2DData;
+ public RigidbodyData rigidbodyData;
+ public SpriteData spriteData;
+ public StringData stringData;
+ public TextureData textureData;
+ public TransformData transformData;
+ public Vector2Data vector2Data;
+ public Vector3Data vector3Data;
+ public Vector4Data vector4Data;
+
+ public bool HasReference(Variable var)
+ {
+ return animatorData.animatorRef == var ||
+ audioSourceData.audioSourceRef == var ||
+ booleanData.booleanRef == var ||
+ collectionData.collectionRef == var ||
+ collider2DData.collider2DRef == var ||
+ colliderData.colliderRef == var ||
+ colorData.colorRef == var ||
+ floatData.floatRef == var ||
+ gameObjectData.gameObjectRef == var ||
+ integerData.integerRef == var ||
+ materialData.materialRef == var ||
+ matrix4x4Data.matrix4x4Ref == var ||
+ objectData.objectRef == var ||
+ quaternionData.quaternionRef == var ||
+ rigidbody2DData.rigidbody2DRef == var ||
+ rigidbodyData.rigidbodyRef == var ||
+ spriteData.spriteRef == var ||
+ stringData.stringRef == var ||
+ textureData.textureRef == var ||
+ transformData.transformRef == var ||
+ vector2Data.vector2Ref == var ||
+ vector3Data.vector3Ref == var ||
+ vector4Data.vector4Ref == var;
+ }
+ }
+
+ ///
+ /// Pairing of an AnyVariableData and an variable reference. Internal lookup for
+ /// making the right kind of variable with the correct data in the AnyVariableData.
+ /// This is the primary mechanism for hiding the ugly need to match variable to
+ /// correct data type so we can perform comparisons and operations.
+ ///
+ /// New types created need to be added to the list below and also to AllVariableTypes and
+ /// AnyVariableData
+ ///
+ [System.Serializable]
+ public class AnyVariableAndDataPair
+ {
+ public class TypeActions
+ {
+ public TypeActions(string dataPropName,
+ System.Func comparer,
+ System.Func desccription,
+ System.Action set
+ )
+ {
+ DataPropName = dataPropName;
+ CompareFunc = comparer;
+ DescFunc = desccription;
+ SetFunc = set;
+ }
+
+ // used in AnyVaraibleAndDataPair Drawer to show the correct aspect of the AnyVariableData in the editor
+ public string DataPropName { get; set; }
+
+ public System.Func CompareFunc;
+ public System.Func DescFunc;
+ public System.Action SetFunc;
+ }
+
+ [VariableProperty(AllVariableTypes.VariableAny.Any)]
+ [UnityEngine.SerializeField] public Variable variable;
+
+ [UnityEngine.SerializeField] public AnyVariableData data;
+
+ //needs static lookup function table for getting a function or string based on the type
+ // all new variable types will need to be added here also to be supported
+ public static readonly Dictionary typeActionLookup = new Dictionary()
+ {
+ { typeof(AnimatorVariable),
+ new TypeActions( "animatorData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.animatorData.Value); },
+ (anyVar) => anyVar.data.animatorData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.animatorData.Value)) },
+ { typeof(AudioSourceVariable),
+ new TypeActions( "audioSourceData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.audioSourceData.Value); },
+ (anyVar) => anyVar.data.audioSourceData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.audioSourceData.Value)) },
+ { typeof(BooleanVariable),
+ new TypeActions( "booleanData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.booleanData.Value); },
+ (anyVar) => anyVar.data.booleanData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.booleanData.Value)) },
+ { typeof(CollectionVariable),
+ new TypeActions( "collectionData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.collectionData.Value); },
+ (anyVar) => anyVar.data.collectionData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.collectionData.Value)) },
+ { typeof(Collider2DVariable),
+ new TypeActions( "collider2DData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.collider2DData.Value); },
+ (anyVar) => anyVar.data.collider2DData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.collider2DData.Value)) },
+ { typeof(ColliderVariable),
+ new TypeActions( "colliderData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.colliderData.Value); },
+ (anyVar) => anyVar.data.colliderData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.colliderData.Value)) },
+ { typeof(ColorVariable),
+ new TypeActions( "colorData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.colorData.Value); },
+ (anyVar) => anyVar.data.colorData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.colorData.Value)) },
+ { typeof(FloatVariable),
+ new TypeActions( "floatData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.floatData.Value); },
+ (anyVar) => anyVar.data.floatData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.floatData.Value)) },
+ { typeof(GameObjectVariable),
+ new TypeActions( "gameObjectData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.gameObjectData.Value); },
+ (anyVar) => anyVar.data.gameObjectData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.gameObjectData.Value)) },
+ { typeof(IntegerVariable),
+ new TypeActions( "integerData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.integerData.Value); },
+ (anyVar) => anyVar.data.integerData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.integerData.Value)) },
+ { typeof(MaterialVariable),
+ new TypeActions( "materialData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.materialData.Value); },
+ (anyVar) => anyVar.data.materialData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.materialData.Value)) },
+ { typeof(Matrix4x4Variable),
+ new TypeActions( "matrix4x4Data",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.matrix4x4Data.Value); },
+ (anyVar) => anyVar.data.matrix4x4Data.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.matrix4x4Data.Value)) },
+ { typeof(ObjectVariable),
+ new TypeActions( "objectData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.objectData.Value); },
+ (anyVar) => anyVar.data.objectData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.objectData.Value)) },
+ { typeof(QuaternionVariable),
+ new TypeActions( "quaternionData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.quaternionData.Value); },
+ (anyVar) => anyVar.data.quaternionData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.quaternionData.Value)) },
+ { typeof(Rigidbody2DVariable),
+ new TypeActions( "rigidbody2DData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.rigidbody2DData.Value); },
+ (anyVar) => anyVar.data.rigidbody2DData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.rigidbody2DData.Value)) },
+ { typeof(RigidbodyVariable),
+ new TypeActions( "rigidbodyData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.rigidbodyData.Value); },
+ (anyVar) => anyVar.data.rigidbodyData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.rigidbodyData.Value)) },
+ { typeof(SpriteVariable),
+ new TypeActions( "spriteData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.spriteData.Value); },
+ (anyVar) => anyVar.data.spriteData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.spriteData.Value)) },
+ { typeof(StringVariable),
+ new TypeActions( "stringData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.stringData.Value); },
+ (anyVar) => anyVar.data.stringData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.stringData.Value)) },
+ { typeof(TextureVariable),
+ new TypeActions( "textureData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.textureData.Value); },
+ (anyVar) => anyVar.data.textureData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.textureData.Value)) },
+ { typeof(TransformVariable),
+ new TypeActions( "transformData",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.transformData.Value); },
+ (anyVar) => anyVar.data.transformData.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.transformData.Value)) },
+ { typeof(Vector2Variable),
+ new TypeActions( "vector2Data",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.vector2Data.Value); },
+ (anyVar) => anyVar.data.vector2Data.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.vector2Data.Value)) },
+ { typeof(Vector3Variable),
+ new TypeActions( "vector3Data",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.vector3Data.Value); },
+ (anyVar) => anyVar.data.vector3Data.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.vector3Data.Value)) },
+ { typeof(Vector4Variable),
+ new TypeActions( "vector4Data",
+ (anyVar, compareOperator) => {return anyVar.variable.Evaluate(compareOperator, anyVar.data.vector4Data.Value); },
+ (anyVar) => anyVar.data.vector4Data.GetDescription(),
+ (anyVar, setOperator) => anyVar.variable.Apply(setOperator, anyVar.data.vector4Data.Value)) },
+ };
+
+ public bool HasReference(Variable variable)
+ {
+ return variable == this.variable || data.HasReference(variable);
+ }
+
+ public string GetDataDescription()
+ {
+ TypeActions ta = null;
+ if (typeActionLookup.TryGetValue(variable.GetType(), out ta))
+ {
+ return ta.DescFunc(this);
+ }
+ return "Null";
+ }
+
+ public bool Compare(CompareOperator compareOperator, ref bool compareResult)
+ {
+ TypeActions ta = null;
+ if (typeActionLookup.TryGetValue(variable.GetType(), out ta))
+ {
+ compareResult = ta.CompareFunc(this, compareOperator);
+ return true;
+ }
+ return false;
+ }
+
+ public void SetOp(SetOperator setOperator)
+ {
+ TypeActions ta = null;
+ if (typeActionLookup.TryGetValue(variable.GetType(), out ta))
+ {
+ ta.SetFunc(this, setOperator);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Utils/AllVariableTypes.cs.meta b/Assets/Fungus/Scripts/Utils/AllVariableTypes.cs.meta
new file mode 100644
index 00000000..c92845d8
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/AllVariableTypes.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 18d15dbcc71f440409f4ea358af6956f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Utils/BlockReference.cs b/Assets/Fungus/Scripts/Utils/BlockReference.cs
index 47dd497e..667bc1af 100644
--- a/Assets/Fungus/Scripts/Utils/BlockReference.cs
+++ b/Assets/Fungus/Scripts/Utils/BlockReference.cs
@@ -1,4 +1,7 @@
-using System.Collections;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Utils/ConversationManager.cs b/Assets/Fungus/Scripts/Utils/ConversationManager.cs
index 1f00dbd9..0b6bb775 100644
--- a/Assets/Fungus/Scripts/Utils/ConversationManager.cs
+++ b/Assets/Fungus/Scripts/Utils/ConversationManager.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using System.Collections;
@@ -422,8 +422,9 @@ namespace Fungus
}
if (stage != null && currentCharacter != null &&
- (currentPortrait != currentCharacter.State.portrait ||
- currentPosition != currentCharacter.State.position))
+ (currentPortrait != currentCharacter.State.portrait ||
+ currentPosition != currentCharacter.State.position ||
+ (currentCharacter.State.display == DisplayType.Hide && !item.Hide)))
{
var portraitOptions = new PortraitOptions(true);
portraitOptions.display = item.Hide ? DisplayType.Hide : DisplayType.Show;
diff --git a/Assets/Fungus/Scripts/Utils/EventDispatcher.cs b/Assets/Fungus/Scripts/Utils/EventDispatcher.cs
index 36b46ee7..f52dc492 100644
--- a/Assets/Fungus/Scripts/Utils/EventDispatcher.cs
+++ b/Assets/Fungus/Scripts/Utils/EventDispatcher.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Utils/FlowchartData.cs b/Assets/Fungus/Scripts/Utils/FlowchartData.cs
index d1fe8485..87e2db4a 100644
--- a/Assets/Fungus/Scripts/Utils/FlowchartData.cs
+++ b/Assets/Fungus/Scripts/Utils/FlowchartData.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using System.Collections.Generic;
diff --git a/Assets/Fungus/Scripts/Utils/FungusConstants.cs b/Assets/Fungus/Scripts/Utils/FungusConstants.cs
index 4676b4b4..5e9fe40b 100644
--- a/Assets/Fungus/Scripts/Utils/FungusConstants.cs
+++ b/Assets/Fungus/Scripts/Utils/FungusConstants.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Utils/GlobalVariables.cs b/Assets/Fungus/Scripts/Utils/GlobalVariables.cs
index ed50b79b..7aa50752 100644
--- a/Assets/Fungus/Scripts/Utils/GlobalVariables.cs
+++ b/Assets/Fungus/Scripts/Utils/GlobalVariables.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Utils/PortraitUtils.cs b/Assets/Fungus/Scripts/Utils/PortraitUtils.cs
index eed16802..66ed643d 100644
--- a/Assets/Fungus/Scripts/Utils/PortraitUtils.cs
+++ b/Assets/Fungus/Scripts/Utils/PortraitUtils.cs
@@ -1,9 +1,10 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using UnityEngine.UI;
using MoonSharp.Interpreter;
+using System.Collections.Generic;
namespace Fungus
{
@@ -60,10 +61,16 @@ namespace Fungus
public bool onScreen;
public bool dimmed;
public DisplayType display;
- public Sprite portrait;
- public RectTransform position;
+ public RectTransform position, holder;
public FacingDirection facing;
public Image portraitImage;
+ public Sprite portrait { get { return portraitImage != null ? portraitImage.sprite : null; } }
+ public List allPortraits = new List();
+
+ public void SetPortraitImageBySprite(Sprite portrait)
+ {
+ portraitImage = allPortraits.Find(x => x.sprite == portrait);
+ }
}
///
@@ -176,6 +183,19 @@ namespace Fungus
return options;
}
+
+ static public int PortraitCompareTo(Sprite x, Sprite y)
+ {
+ if (x == y)
+ return 0;
+ if (y == null)
+ return -1;
+ if (x == null)
+ return 1;
+
+ return x.name.CompareTo(y.name);
+ }
+
#endregion
}
}
diff --git a/Assets/Fungus/Scripts/Utils/SaveDataItem.cs b/Assets/Fungus/Scripts/Utils/SaveDataItem.cs
index 16bb0368..82ec01d2 100644
--- a/Assets/Fungus/Scripts/Utils/SaveDataItem.cs
+++ b/Assets/Fungus/Scripts/Utils/SaveDataItem.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
diff --git a/Assets/Fungus/Scripts/Utils/SaveHistory.cs b/Assets/Fungus/Scripts/Utils/SaveHistory.cs
index 4e237686..2212fa28 100644
--- a/Assets/Fungus/Scripts/Utils/SaveHistory.cs
+++ b/Assets/Fungus/Scripts/Utils/SaveHistory.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
diff --git a/Assets/Fungus/Scripts/Utils/SavePointData.cs b/Assets/Fungus/Scripts/Utils/SavePointData.cs
index 5e63a351..1f5fa7e4 100644
--- a/Assets/Fungus/Scripts/Utils/SavePointData.cs
+++ b/Assets/Fungus/Scripts/Utils/SavePointData.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
#if UNITY_5_3_OR_NEWER
diff --git a/Assets/Fungus/Scripts/Utils/StringFormatter.cs b/Assets/Fungus/Scripts/Utils/StringFormatter.cs
index 2945319e..80f991cc 100644
--- a/Assets/Fungus/Scripts/Utils/StringFormatter.cs
+++ b/Assets/Fungus/Scripts/Utils/StringFormatter.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using System.Text;
diff --git a/Assets/Fungus/Scripts/Utils/TMProLinkAnimEffects.cs b/Assets/Fungus/Scripts/Utils/TMProLinkAnimEffects.cs
new file mode 100644
index 00000000..cacd7bcb
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/TMProLinkAnimEffects.cs
@@ -0,0 +1,436 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+#if UNITY_2018_1_OR_NEWER
+
+namespace Fungus
+{
+ ///
+ /// Samples and helpers for creating TMProLink animations
+ ///
+ namespace TMProLinkAnimEffects
+ {
+ ///
+ /// Used by BaseEffect and child classes to configure how locations and pivots are calculated
+ /// before being passed to internal functions.
+ ///
+ public enum TMPLinkAnimatorMode
+ {
+ PerCharacter,
+ PerWord,
+ PerSection,
+ PerLine,
+ }
+
+ ///
+ /// Use of this is not required, all that the TMProLinkAnimLookup requires is a matching signature of
+ /// void delegate(TMProLinkAnimator context, int start, int length). The base class however is used to
+ /// create all the sample effects as they all operate in a similar underlying fashion, with a custom mode
+ /// but ultimately on a character by character basis, doing a relative translation and color modifcation.
+ ///
+ /// Much of this class and its sample child effects are static functions to more easily allow reuse by
+ /// custom effects you may wish to make.
+ ///
+ public abstract class BaseEffect
+ {
+ public TMPLinkAnimatorMode mode;
+ protected TMProLinkAnimator CurrentContext { get; set; }
+ protected int CurrentStart { get; set; }
+ protected int CurrentLength { get; set; }
+
+ public virtual void DoEffect(TMProLinkAnimator context, int start, int length)
+ {
+ CurrentContext = context;
+ CurrentStart = start;
+ CurrentLength = length;
+
+ MeshVertUpdateLoop(context, start, length, TransFunc, ColorFunc, mode);
+ }
+
+ public virtual Matrix4x4 TransFunc(int index)
+ {
+ return Matrix4x4.identity;
+ }
+
+ public virtual Color32 ColorFunc(int index, Color32 col)
+ {
+ return col;
+ }
+
+ #region static helpers
+
+ ///
+ /// Helper for mesh vertex updating within a found link, adapted from TMPRo examples VertexJitter.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ static public void MeshVertUpdateLoop(TMProLinkAnimator context, int start, int length, System.Func transformFunc, System.Func colorFunc, TMPLinkAnimatorMode mode)
+ {
+ var tmproComponent = context.TMProComponent;
+ var textInfo = tmproComponent.textInfo;
+ var end = start + length;
+ var cachedMeshInfo = context.CachedMeshInfo;
+
+ Matrix4x4 matrix = Matrix4x4.identity;
+ Vector2 middle = Vector2.zero;
+ Color32 col = Color.white;
+ int wordIndex = -1;
+ int lineIndex = -1;
+
+ for (int i = start; i < end; i++)
+ {
+ //required as TMPro is putting non visible invalid elements in the charinfo array assuming I will follow this rule
+ // if we don't character 0 ends up getting an effect applied to it even though it shouldn't
+ if (!textInfo.characterInfo[i].isVisible) continue;
+
+ // Get the index of the material used by the current character.
+ int materialIndex = textInfo.characterInfo[i].materialReferenceIndex;
+
+ // Get the index of the first vertex used by this text element.
+ int vertexIndex = textInfo.characterInfo[i].vertexIndex;
+
+ // Get the cached vertices of the mesh used by this text element (character or sprite).
+ Vector3[] sourceVertices = cachedMeshInfo[materialIndex].vertices;
+ Color32[] vertexColors = cachedMeshInfo[materialIndex].colors32;
+
+ if (i == start && mode == TMPLinkAnimatorMode.PerSection)
+ {
+ matrix = transformFunc(start);
+ middle = CalcMidFromChars(context, start, end);
+ col = colorFunc(start, vertexColors[vertexIndex]);
+ }
+
+ // Determine the center point of each character at the baseline.
+ //Vector2 charMidBasline = new Vector2((sourceVertices[vertexIndex + 0].x + sourceVertices[vertexIndex + 2].x) / 2, charInfo.baseLine);
+ // Determine the center point of each character.
+ if (mode == TMPLinkAnimatorMode.PerCharacter)
+ {
+ middle = (sourceVertices[vertexIndex + 0] + sourceVertices[vertexIndex + 2]) / 2;
+ matrix = transformFunc(i);
+ col = colorFunc(i, vertexColors[vertexIndex]);
+ }
+ else if (mode == TMPLinkAnimatorMode.PerWord)
+ {
+ var newWordIndex = CalcWordFromChar(i, textInfo.wordInfo);
+ if (newWordIndex != -1 && wordIndex != newWordIndex)
+ {
+ wordIndex = newWordIndex;
+
+ middle = CalcMidFromChars(context, Mathf.Max(start, textInfo.wordInfo[wordIndex].firstCharacterIndex), Mathf.Min(end, textInfo.wordInfo[wordIndex].lastCharacterIndex));
+ matrix = transformFunc(i);
+ col = colorFunc(i, vertexColors[vertexIndex]);
+ }
+ }
+ else if (mode == TMPLinkAnimatorMode.PerLine)
+ {
+ var newLineIndex = textInfo.characterInfo[i].lineNumber;
+ if (newLineIndex != -1 && lineIndex != newLineIndex)
+ {
+ lineIndex = newLineIndex;
+
+ middle = CalcMidFromChars(context, Mathf.Max(start, textInfo.lineInfo[lineIndex].firstCharacterIndex), Mathf.Min(end, textInfo.lineInfo[lineIndex].lastCharacterIndex));
+ matrix = transformFunc(i);
+ col = colorFunc(i, vertexColors[vertexIndex]);
+ }
+ }
+
+ // Need to translate all 4 vertices of each quad to aligned with middle of character / baseline.
+ // This is needed so the matrix TRS is applied at the origin for each character.
+ Vector3 offset = middle;
+
+ Vector3[] destinationVertices = textInfo.meshInfo[materialIndex].vertices;
+ Color32[] destinationVertColors = textInfo.meshInfo[materialIndex].colors32;
+
+ destinationVertices[vertexIndex + 0] = sourceVertices[vertexIndex + 0] - offset;
+ destinationVertices[vertexIndex + 1] = sourceVertices[vertexIndex + 1] - offset;
+ destinationVertices[vertexIndex + 2] = sourceVertices[vertexIndex + 2] - offset;
+ destinationVertices[vertexIndex + 3] = sourceVertices[vertexIndex + 3] - offset;
+
+ destinationVertices[vertexIndex + 0] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 0]);
+ destinationVertices[vertexIndex + 1] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 1]);
+ destinationVertices[vertexIndex + 2] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 2]);
+ destinationVertices[vertexIndex + 3] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 3]);
+
+ destinationVertices[vertexIndex + 0] += offset;
+ destinationVertices[vertexIndex + 1] += offset;
+ destinationVertices[vertexIndex + 2] += offset;
+ destinationVertices[vertexIndex + 3] += offset;
+
+ destinationVertColors[vertexIndex + 0] = col;
+ destinationVertColors[vertexIndex + 1] = col;
+ destinationVertColors[vertexIndex + 2] = col;
+ destinationVertColors[vertexIndex + 3] = col;
+ }
+ }
+
+ ///
+ /// Same as calcing a character mid but averaging over all characters in the given character range
+ ///
+ ///
+ ///
+ ///
+ ///
+ static public Vector2 CalcMidFromChars(TMProLinkAnimator context, int start, int end)
+ {
+ Vector3 middle = Vector3.zero;
+ var chInfo = context.TMProComponent.textInfo.characterInfo;
+
+ for (int i = start; i < end; i++)
+ {
+ int materialIndex = chInfo[i].materialReferenceIndex;
+ int vertexIndex = chInfo[i].vertexIndex;
+ Vector3[] sourceVertices = context.CachedMeshInfo[materialIndex].vertices;
+ middle += (sourceVertices[vertexIndex + 0] + sourceVertices[vertexIndex + 2]) / 2;
+ }
+
+ return middle / (end - start);
+ }
+
+ ///
+ /// Determine which TMPro World a given character index is within
+ ///
+ ///
+ ///
+ ///
+ static public int CalcWordFromChar(int charIndex, TMPro.TMP_WordInfo[] wordInfo)
+ {
+ for (int i = 0; i < wordInfo.Length; i++)
+ {
+ //enforcing start letter results in punctuation attaching to the word to its left rather than its right.
+ // which is more desirable for english at least
+ if (charIndex >= wordInfo[i].firstCharacterIndex && wordInfo[i].lastCharacterIndex >= charIndex)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ ///
+ /// Determine which TMPro Line a given character index is within
+ ///
+ ///
+ ///
+ ///
+ static public int CalcLineFromChar(int charIndex, TMPro.TMP_WordInfo[] wordInfo)
+ {
+ for (int i = 0; i < wordInfo.Length; i++)
+ {
+ //enforcing start letter results in punctuation attaching to the word to its left rather than its right.
+ // which is more desirable for english at least
+ if (charIndex >= wordInfo[i].firstCharacterIndex && wordInfo[i].lastCharacterIndex >= charIndex)
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ #endregion static helpers
+ }
+
+ ///
+ /// Shake the element, by moving centre slightly and randomly rolling each update.
+ ///
+ public class ShakeEffect : BaseEffect
+ {
+ public float rotScale;
+ public Vector2 offsetScale = Vector2.one;
+
+ public override Matrix4x4 TransFunc(int index)
+ {
+ return ShakeTransformFunc(index, offsetScale, rotScale);
+ }
+
+ static public Matrix4x4 ShakeTransformFunc(int index, Vector2 positionOffsetScale, float rotDegScale)
+ {
+ return Matrix4x4.TRS(new Vector3(Random.Range(-.25f, .25f) * positionOffsetScale.x, Random.Range(-.25f, .25f), 0) * positionOffsetScale.y,
+ Quaternion.Euler(0, 0, Random.Range(-1f, 1f) * rotDegScale),
+ Vector3.one);
+ }
+ }
+
+ ///
+ /// Wiggle the position by over time using perlin noise to offset its centre.
+ ///
+ public class WiggleEffect : BaseEffect
+ {
+ public float speed = 1;
+ public Vector2 offsetScale = Vector2.one;
+
+ public override Matrix4x4 TransFunc(int index)
+ {
+ return WiggleTransformFunc(index, speed, offsetScale);
+ }
+
+ static public Matrix4x4 WiggleTransformFunc(int index, float speed, Vector2 wiggleScale)
+ {
+ const int SAFE_PRIME_A = 11;
+ const int SAFE_PRIME_B = 59;
+ //add a pingpong
+ var jitterOffset = new Vector3(Mathf.PerlinNoise(Time.time * speed + index * SAFE_PRIME_A, index * SAFE_PRIME_B),
+ Mathf.PerlinNoise(Time.time * speed + index * SAFE_PRIME_B, index * SAFE_PRIME_A),
+ 0);
+ jitterOffset *= 2;
+ jitterOffset -= new Vector3(1, 1, 0);
+
+ return Matrix4x4.TRS(jitterOffset * wiggleScale,
+ Quaternion.identity,
+ Vector3.one);
+ }
+ }
+
+ ///
+ /// Use a sine wave by time to offset the height of the element.
+ ///
+ public class WaveEffect : BaseEffect
+ {
+ public float speed, indexStep, scale;
+
+ public override Matrix4x4 TransFunc(int index)
+ {
+ return WaveTransformFunc(index, speed, indexStep, scale);
+ }
+
+ static public Matrix4x4 WaveTransformFunc(int index, float waveSpeed, float waveIndexStep, float waveScale)
+ {
+ return Matrix4x4.TRS(new Vector3(0, Mathf.Sin(Time.time * waveSpeed + index * waveIndexStep) * waveScale, 0),
+ Quaternion.identity,
+ Vector3.one);
+ }
+ }
+
+ ///
+ /// Use a sinewave to swing or pivot the element around its centre back n forth.
+ ///
+ public class PivotEffect : BaseEffect
+ {
+ public float speed, degScale;
+
+ public override Matrix4x4 TransFunc(int index)
+ {
+ return PivotTransformFunc(index, speed, degScale);
+ }
+
+ static public Matrix4x4 PivotTransformFunc(int index, float pivotSpeed, float pivotDegScale)
+ {
+ return Matrix4x4.TRS(Vector3.zero,
+ Quaternion.Euler(0, 0, Mathf.Sin(Time.time * pivotSpeed + index) * pivotDegScale),
+ Vector3.one);
+ }
+ }
+
+ ///
+ /// Use a sine wave to animate the H,S,V elements individually, modifying them from their starting color.
+ /// Use a sine wave to scale the element
+ ///
+ public class PulseEffect : BaseEffect
+ {
+ public float speed = 1, HSVIntensityScale = 1, indexStep = 1, hueScale = 1, saturationScale = 1, valueScale = 1;
+ public Vector3 scale = Vector2.zero;
+
+ public override Color32 ColorFunc(int index, Color32 col)
+ {
+ return HSVPulse(index, indexStep, speed, HSVIntensityScale, col, hueScale, saturationScale, valueScale);
+ }
+
+ public override Matrix4x4 TransFunc(int index)
+ {
+ return ScalePulse(index, indexStep, speed, scale);
+ }
+
+ static public Color32 HSVPulse(int index, float indexStep, float speed, float colScale, Color32 startingColor, float hueScale, float saturationScale, float valueScale)
+ {
+ float t = Mathf.Sin(Time.time * speed + index * indexStep) * colScale;
+ Color.RGBToHSV(startingColor, out float h, out float s, out float v);
+
+ var col = Color.HSVToRGB(Mathf.Repeat(h + t * hueScale, 1),
+ Mathf.Clamp01(s + t * saturationScale),
+ Mathf.Clamp01(v + t * valueScale));
+ return (Color32)col;
+ }
+
+ static public Matrix4x4 ScalePulse(int index, float indexStep, float speed, Vector3 scale)
+ {
+ float t = Mathf.Sin(Time.time * speed + index * indexStep);
+ return Matrix4x4.TRS(Vector3.zero,
+ Quaternion.identity,
+ Vector3.one + scale * t);
+ }
+ }
+
+ ///
+ /// Bounce up and down on an endless parabolic curve.
+ ///
+ public class BounceEffect : BaseEffect
+ {
+ public float indexStep = 1, speed = 1, scale = 1, fixedOffsetScale = 0.5f;
+
+ public override Matrix4x4 TransFunc(int index)
+ {
+ return Bounce(index, indexStep, speed, scale, fixedOffsetScale);
+ }
+
+ static public Matrix4x4 Bounce(int index, float indexStep, float speed, float scale, float fixedOffsetScale)
+ {
+ float t = (Time.time * speed + index * indexStep) % 2.0f;
+
+ t = -t * t + 2 * t;
+
+ return Matrix4x4.TRS(Vector3.up * t * scale + Vector3.down * fixedOffsetScale * scale,
+ Quaternion.identity,
+ Vector3.one);
+ }
+ }
+
+ ///
+ /// Create a staircase effect of the the elements.
+ ///
+ public class AscendEffect : BaseEffect
+ {
+ public float totalStep;
+
+ public override Matrix4x4 TransFunc(int index)
+ {
+ return StepTransformFunc(index, index - CurrentStart, totalStep / CurrentLength);
+ }
+
+ static public Matrix4x4 StepTransformFunc(int index, int stepNum, float stepHeight)
+ {
+ return Matrix4x4.TRS(Vector3.up * stepNum * stepHeight,
+ Quaternion.identity,
+ Vector3.one);
+ }
+ }
+
+ ///
+ /// Cycle the colors of the elements by forcing color to a roling Hue and fixed SV color value.
+ ///
+ public class RainbowEffect : BaseEffect
+ {
+ public float speed, indexStep, s, v;
+
+ public override Color32 ColorFunc(int index, Color32 col)
+ {
+ return CycleColor(index, speed, indexStep, s, v);
+ }
+
+ static public Color32 CycleColor(int index, float speed, float indexStep, float s, float v)
+ {
+ float h = Time.time * speed + index * indexStep;
+ var col = Color.HSVToRGB(h % 1.0f, s, v);
+ return (Color32)col;
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Utils/TMProLinkAnimEffects.cs.meta b/Assets/Fungus/Scripts/Utils/TMProLinkAnimEffects.cs.meta
new file mode 100644
index 00000000..24231d34
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/TMProLinkAnimEffects.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5a2f0563cd4feb744975e63982dc480c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Utils/TMProLinkAnimLookup.cs b/Assets/Fungus/Scripts/Utils/TMProLinkAnimLookup.cs
new file mode 100644
index 00000000..8cb48985
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/TMProLinkAnimLookup.cs
@@ -0,0 +1,104 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections.Generic;
+
+#if UNITY_2018_1_OR_NEWER
+
+namespace Fungus
+{
+ ///
+ /// Static lookup for Text Mesh Pro Link animations. TMPro tracks and holds information about
+ /// link tags in its text body and is recommended as one of the ways to achieve effects within
+ /// a body of text. Giving you the text within the link and the name/hash of the link id itself.
+ ///
+ /// Such that {link="shake"}this text will be marked up as within shake link{/link}.
+ ///
+ /// By assigning to the LinkHashToEffect dictionary with a key of TMPro.TMP_TextUtilities.GetSimpleHashCode("shake")
+ /// and a matching function signature that can then be used the the TMProLinkAnimator.
+ ///
+ /// See TMProLinkAnimEffects for sample basis for creating effects.
+ ///
+ public static class TMProLinkAnimLookup
+ {
+ //required signature for all TMProAnim functions for use in the lookup
+ public delegate void TMProAnimFunc(TMProLinkAnimator beh, int start, int length);
+
+ //static lookup for all tmpro link style lookups
+ //this is where additional effects would be added
+ static public Dictionary LinkHashToEffect = new Dictionary()
+ {
+ //comments left here for the effects that are added in the demo scene
+ /*
+ {TMPro.TMP_TextUtilities.GetSimpleHashCode("shake"),
+ new TMProLinkAnimEffects.ShakeEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerLine,
+ offsetScale = 2,
+ rotScale = 15
+ }.DoEffect },
+ {TMPro.TMP_TextUtilities.GetSimpleHashCode("wiggle"),
+ new TMProLinkAnimEffects.WiggleEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerSection,
+ scale = 5
+ }.DoEffect },
+ {TMPro.TMP_TextUtilities.GetSimpleHashCode("wave"),
+ new TMProLinkAnimEffects.WaveEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerCharacter,
+ speed = 10,
+ indexStep = 0.3f,
+ scale = 2
+ }.DoEffect },
+ {TMPro.TMP_TextUtilities.GetSimpleHashCode("pivot"),
+ new TMProLinkAnimEffects.PivotEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerWord,
+ speed = 10,
+ degScale = 15
+ }.DoEffect
+ },
+ {TMPro.TMP_TextUtilities.GetSimpleHashCode("rainbow"),
+ new TMProLinkAnimEffects.RainbowEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerCharacter,
+ speed = 2,
+ indexStep = 0.1f,
+ s = 0.8f,
+ v = 0.8f
+ }.DoEffect
+ },
+ {TMPro.TMP_TextUtilities.GetSimpleHashCode("ascend"),
+ new TMProLinkAnimEffects.AscendEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerCharacter,
+ totalStep = 10
+ }.DoEffect
+ },
+ */
+ };
+
+ static public void AddHelper(string linkIdText, TMProAnimFunc func)
+ {
+ LinkHashToEffect.Add(TMPro.TMP_TextUtilities.GetSimpleHashCode(linkIdText), func);
+ }
+
+ static public void AddHelper(string linkIdText, TMProLinkAnimEffects.BaseEffect baseEffect)
+ {
+ LinkHashToEffect.Add(TMPro.TMP_TextUtilities.GetSimpleHashCode(linkIdText), baseEffect.DoEffect);
+ }
+
+ static public void Remove(string linkIdText)
+ {
+ LinkHashToEffect.Remove(TMPro.TMP_TextUtilities.GetSimpleHashCode(linkIdText));
+ }
+
+ static public void RemoveAll()
+ {
+ LinkHashToEffect.Clear();
+ }
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Utils/TMProLinkAnimLookup.cs.meta b/Assets/Fungus/Scripts/Utils/TMProLinkAnimLookup.cs.meta
new file mode 100644
index 00000000..8ec124ce
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/TMProLinkAnimLookup.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3a3990bfc87d31047a6cc1e300dff1d7
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Utils/TMProLinkAnimator.cs b/Assets/Fungus/Scripts/Utils/TMProLinkAnimator.cs
new file mode 100644
index 00000000..40e47a4b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/TMProLinkAnimator.cs
@@ -0,0 +1,206 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+#if UNITY_2018_1_OR_NEWER
+
+namespace Fungus
+{
+ ///
+ /// Component that is automatically added to all tmpro texts that contain links. Caches
+ /// local data for that TMProText and uses the TMProLinkAnimLookup to the actual animation.
+ ///
+ [DisallowMultipleComponent]
+ public class TMProLinkAnimator : MonoBehaviour
+ {
+ #region Auto Add Component
+
+ ///
+ /// Ensure we are being notified of TMPro changes.
+ ///
+ [RuntimeInitializeOnLoadMethod]
+ public static void RegisterAutoAddTMPLinkAnim()
+ {
+ TMPro.TMPro_EventManager.TEXT_CHANGED_EVENT.Add(AutoAddTMPLinkAnim);
+ }
+
+ ///
+ /// Adds a suite of default link text animations. These can be removed via the
+ /// TMProLinkAnimLookup if desired.
+ ///
+ [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
+ public static void RegisterDefaultTMPLinkAnims()
+ {
+ TMProLinkAnimLookup.AddHelper("jitter", new TMProLinkAnimEffects.ShakeEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerCharacter,
+ offsetScale = new Vector2(1, 4),
+ rotScale = 10
+ });
+ TMProLinkAnimLookup.AddHelper("angry", new TMProLinkAnimEffects.ShakeEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerWord,
+ offsetScale = new Vector2(1, 8),
+ rotScale = 4
+ });
+ TMProLinkAnimLookup.AddHelper("spooky", new TMProLinkAnimEffects.WiggleEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerSection,
+ offsetScale = new Vector2(6, 10),
+ speed = 1.5f,
+ });
+ TMProLinkAnimLookup.AddHelper("unknowable", new TMProLinkAnimEffects.WiggleEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerCharacter,
+ offsetScale = new Vector2(4, 8),
+ speed = 1f,
+ });
+ TMProLinkAnimLookup.AddHelper("wave", new TMProLinkAnimEffects.WaveEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerCharacter,
+ speed = 10,
+ indexStep = 0.3f,
+ scale = 2
+ });
+ TMProLinkAnimLookup.AddHelper("swing", new TMProLinkAnimEffects.PivotEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerWord,
+ speed = 10,
+ degScale = 15
+ });
+ TMProLinkAnimLookup.AddHelper("bounce", new TMProLinkAnimEffects.BounceEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerWord,
+ speed = 4,
+ scale = 5,
+ });
+ TMProLinkAnimLookup.AddHelper("excited", new TMProLinkAnimEffects.BounceEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerCharacter,
+ speed = 7,
+ scale = 2,
+ indexStep = 11.0f / 3.0f,
+ });
+ TMProLinkAnimLookup.AddHelper("glow", new TMProLinkAnimEffects.PulseEffect()
+ {
+ mode = TMProLinkAnimEffects.TMPLinkAnimatorMode.PerWord,
+ speed = 4,
+ HSVIntensityScale = 0.15f,
+ hueScale = 0,
+ saturationScale = 0.1f,
+ scale = new Vector3(0.06f, 0.06f, 0),
+ });
+ }
+
+ ///
+ /// Called by TMPro when a text is changed, ensuring link animator is there and
+ /// that data is ready for it to use.
+ ///
+ ///
+ public static void AutoAddTMPLinkAnim(object obj)
+ {
+ if (Application.isPlaying)
+ {
+ var tmp = (obj as TMPro.TMP_Text);
+ if (forcedUpdater == null && tmp.textInfo.linkCount > 0)
+ {
+ var tmpa = tmp.GetComponent();
+ if (tmpa == null)
+ {
+ tmpa = tmp.gameObject.AddComponent();
+ tmpa.TMProComponent = tmp;
+ }
+
+ tmpa.SetDirty();
+ tmpa.UpdateAnimation();
+ }
+ }
+ }
+
+ ///
+ /// Cache of the TMProLinkAnimator that just forced an update of the TMProText, used to
+ /// prevent cyclic updates of TMPro mesh content.
+ ///
+ protected static TMProLinkAnimator forcedUpdater;
+
+ #endregion Auto Add Component
+
+ public TMPro.TMP_Text TMProComponent { get; protected set; }
+ public bool dirty = true;
+ protected bool needsToForceMeshUpdate = true;
+
+ public TMPro.TMP_MeshInfo[] CachedMeshInfo { get; protected set; }
+
+ public void SetDirty()
+ {
+ dirty = true;
+ }
+
+ protected void Awake()
+ {
+ if (TMProComponent == null)
+ {
+ TMProComponent = GetComponent();
+ }
+ }
+
+ protected void Update()
+ {
+ UpdateAnimation();
+ }
+
+ ///
+ /// If there is TMPro and a link to potentially animate then ask the AnimLookup for it
+ ///
+ protected void UpdateAnimation()
+ {
+ //could we anim
+ if (TMProComponent != null && enabled)
+ {
+ bool requiresVertexDataUpdate = false;
+
+ //for all found links
+ for (int i = 0; i < TMProComponent.textInfo.linkCount; i++)
+ {
+ var curLink = TMProComponent.textInfo.linkInfo[i];
+
+ //if a static lookup exists, ask it to run its animation with us as the context
+ if (TMProLinkAnimLookup.LinkHashToEffect.TryGetValue(curLink.hashCode, out TMProLinkAnimLookup.TMProAnimFunc animFunc))
+ {
+ //only update caches if we actually need it
+ HandleDirty();
+
+ animFunc(this, curLink.linkTextfirstCharacterIndex, curLink.linkTextLength);
+
+ requiresVertexDataUpdate = true;
+ }
+ }
+
+ // Push changes if we actually found a matching effect
+ if (requiresVertexDataUpdate)
+ {
+ TMProComponent.UpdateVertexData();
+ }
+ }
+ }
+
+ protected void HandleDirty()
+ {
+ //update internal cache if underlying data has changed
+ if (dirty)
+ {
+ if (needsToForceMeshUpdate)
+ {
+ forcedUpdater = this;
+ TMProComponent.ForceMeshUpdate();
+ forcedUpdater = null;
+ }
+ CachedMeshInfo = TMProComponent.textInfo.CopyMeshInfoVertexData();
+ dirty = false;
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Utils/TMProLinkAnimator.cs.meta b/Assets/Fungus/Scripts/Utils/TMProLinkAnimator.cs.meta
new file mode 100644
index 00000000..3d8db4f2
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/TMProLinkAnimator.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: beb7176ffd78d904497350708b9f8134
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/Utils/TextAdapter.cs b/Assets/Fungus/Scripts/Utils/TextAdapter.cs
index 0709066d..34f2f188 100644
--- a/Assets/Fungus/Scripts/Utils/TextAdapter.cs
+++ b/Assets/Fungus/Scripts/Utils/TextAdapter.cs
@@ -1,3 +1,6 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
using UnityEngine;
using UnityEngine.UI;
using System.Reflection;
@@ -84,7 +87,7 @@ namespace Fungus
}
#if UNITY_2018_1_OR_NEWER
- if(tmpro != null)
+ if (tmpro != null)
{
tmpro.richText = true;
}
@@ -164,7 +167,7 @@ namespace Fungus
{
return (textUI != null || inputField != null || textMesh != null || textComponent != null ||
#if UNITY_2018_1_OR_NEWER
- tmpro !=null ||
+ tmpro != null ||
#endif
writerTextDestination != null);
}
@@ -196,6 +199,54 @@ namespace Fungus
return false;
}
+ public bool SupportsHiddenCharacters()
+ {
+#if UNITY_2018_1_OR_NEWER
+ if (tmpro != null)
+ {
+ return true;
+ }
+#endif
+ return false;
+ }
+
+ public int RevealedCharacters
+ {
+ get
+ {
+#if UNITY_2018_1_OR_NEWER
+ if (tmpro != null)
+ {
+ return tmpro.maxVisibleCharacters;
+ }
+#endif
+ return 0;
+ }
+ set
+ {
+#if UNITY_2018_1_OR_NEWER
+ if (tmpro != null)
+ {
+ tmpro.maxVisibleCharacters = value;
+ }
+#endif
+ }
+ }
+
+ public int CharactersToReveal
+ {
+ get
+ {
+#if UNITY_2018_1_OR_NEWER
+ if (tmpro != null)
+ {
+ return tmpro.textInfo.characterCount;
+ }
+#endif
+ return 0;
+ }
+ }
+
public virtual string Text
{
get
diff --git a/Assets/Fungus/Scripts/Utils/TextTagParser.cs b/Assets/Fungus/Scripts/Utils/TextTagParser.cs
index c785b451..3faade90 100644
--- a/Assets/Fungus/Scripts/Utils/TextTagParser.cs
+++ b/Assets/Fungus/Scripts/Utils/TextTagParser.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -161,7 +161,15 @@ namespace Fungus
{
type = TokenType.AudioStop;
}
-
+ else if (tag.StartsWith("link="))
+ {
+ type = TokenType.LinkStart;
+ }
+ else if (tag.StartsWith("/link"))
+ {
+ type = TokenType.LinkEnd;
+ }
+
if (type != TokenType.Invalid)
{
TextTagToken token = new TextTagToken();
@@ -215,6 +223,7 @@ namespace Fungus
"\t{wp}, {wp=0.5} Wait on punctuation (seconds){/wp}\n" +
"\t{c} Clear\n" +
"\t{x} Exit, advance to the next command without waiting for input\n" +
+ "\t{link=id}link text{/link} link text\n" +
"\n" +
"\t{vpunch=10,0.5} Vertically punch screen (intensity,time)\n" +
"\t{hpunch=10,0.5} Horizontally punch screen (intensity,time)\n" +
diff --git a/Assets/Fungus/Scripts/Utils/TextTagToken.cs b/Assets/Fungus/Scripts/Utils/TextTagToken.cs
index 0d786e77..92edf3a9 100644
--- a/Assets/Fungus/Scripts/Utils/TextTagToken.cs
+++ b/Assets/Fungus/Scripts/Utils/TextTagToken.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using System.Collections.Generic;
@@ -68,6 +68,10 @@ namespace Fungus
AudioStop,
/// wvo
WaitForVoiceOver,
+ /// link start
+ LinkStart,
+ /// link end
+ LinkEnd,
}
///
diff --git a/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs b/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs
index 986892db..5c2111f8 100644
--- a/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs
+++ b/Assets/Fungus/Scripts/Utils/TextVariationHandler.cs
@@ -1,4 +1,7 @@
-using System.Collections.Generic;
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
diff --git a/Assets/Fungus/Scripts/Utils/VariableReference.cs b/Assets/Fungus/Scripts/Utils/VariableReference.cs
index e5c12ce8..bf80930d 100644
--- a/Assets/Fungus/Scripts/Utils/VariableReference.cs
+++ b/Assets/Fungus/Scripts/Utils/VariableReference.cs
@@ -1,4 +1,7 @@
-namespace Fungus
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
{
///
/// A simple struct wrapping a reference to a Fungus Variable. Allows for VariableReferenceDrawer.
diff --git a/Assets/Fungus/Scripts/Utils/VariableUtil.cs b/Assets/Fungus/Scripts/Utils/VariableUtil.cs
new file mode 100644
index 00000000..7744905b
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/VariableUtil.cs
@@ -0,0 +1,76 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public static class VariableUtil
+ {
+ public static string GetCompareOperatorDescription(CompareOperator compareOperator)
+ {
+#pragma warning disable CS0162 // Unreachable code detected
+ switch (compareOperator)
+ {
+ case CompareOperator.Equals:
+ return "==";
+ break;
+
+ case CompareOperator.NotEquals:
+ return "!=";
+ break;
+
+ case CompareOperator.LessThan:
+ return "<";
+ break;
+
+ case CompareOperator.GreaterThan:
+ return ">";
+ break;
+
+ case CompareOperator.LessThanOrEquals:
+ return "<=";
+ break;
+
+ case CompareOperator.GreaterThanOrEquals:
+ return ">=";
+ break;
+ }
+#pragma warning restore CS0162 // Unreachable code detected
+ return string.Empty;
+ }
+
+ public static string GetSetOperatorDescription(SetOperator setOperator)
+ {
+#pragma warning disable CS0162 // Unreachable code detected
+ switch (setOperator)
+ {
+ default:
+ case SetOperator.Assign:
+ return "=";
+ break;
+
+ case SetOperator.Negate:
+ return "=!";
+ break;
+
+ case SetOperator.Add:
+ return "+=";
+ break;
+
+ case SetOperator.Subtract:
+ return "-=";
+ break;
+
+ case SetOperator.Multiply:
+ return "*=";
+ break;
+
+ case SetOperator.Divide:
+ return "/=";
+ break;
+ }
+
+ return string.Empty;
+#pragma warning restore CS0162 // Unreachable code detected
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/Utils/VariableUtil.cs.meta b/Assets/Fungus/Scripts/Utils/VariableUtil.cs.meta
new file mode 100644
index 00000000..5a2006aa
--- /dev/null
+++ b/Assets/Fungus/Scripts/Utils/VariableUtil.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d27b5f388ed141c45bdb75a917febcc5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs b/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs
index d564385d..97ca4b16 100644
--- a/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/AnimatorVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -13,41 +13,6 @@ namespace Fungus
[System.Serializable]
public class AnimatorVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
- public static readonly SetOperator[] setOperators = { SetOperator.Assign };
-
- public virtual bool Evaluate(CompareOperator compareOperator, Animator value)
- {
- bool condition = false;
-
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- condition = Value == value;
- break;
- case CompareOperator.NotEquals:
- condition = Value != value;
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
- }
-
- return condition;
- }
-
- public override void Apply(SetOperator setOperator, Animator value)
- {
- switch (setOperator)
- {
- case SetOperator.Assign:
- Value = value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
- }
- }
}
///
@@ -84,7 +49,7 @@ namespace Fungus
{
if (animatorRef == null)
{
- return animatorVal.ToString();
+ return animatorVal != null ? animatorVal.ToString() : "Null";
}
else
{
diff --git a/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs b/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs
index 3cf056c9..76f6cb6a 100644
--- a/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/AudioSourceVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -13,41 +13,6 @@ namespace Fungus
[System.Serializable]
public class AudioSourceVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
- public static readonly SetOperator[] setOperators = { SetOperator.Assign };
-
- public virtual bool Evaluate(CompareOperator compareOperator, AudioSource value)
- {
- bool condition = false;
-
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- condition = Value == value;
- break;
- case CompareOperator.NotEquals:
- condition = Value != value;
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
- }
-
- return condition;
- }
-
- public override void Apply(SetOperator setOperator, AudioSource value)
- {
- switch (setOperator)
- {
- case SetOperator.Assign:
- Value = value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
- }
- }
}
///
@@ -84,7 +49,7 @@ namespace Fungus
{
if (audioSourceRef == null)
{
- return audioSourceVal.ToString();
+ return audioSourceVal != null ? audioSourceVal.ToString() : "Null";
}
else
{
diff --git a/Assets/Fungus/Scripts/VariableTypes/BaseVariableProperty.cs b/Assets/Fungus/Scripts/VariableTypes/BaseVariableProperty.cs
new file mode 100644
index 00000000..2f47ea9f
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/BaseVariableProperty.cs
@@ -0,0 +1,19 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using UnityEngine;
+
+namespace Fungus
+{
+ [AddComponentMenu("")]
+ public abstract class BaseVariableProperty : Command
+ {
+ public enum GetSet
+ {
+ Get,
+ Set,
+ }
+
+ public GetSet getOrSet = GetSet.Get;
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/BaseVariableProperty.cs.meta b/Assets/Fungus/Scripts/VariableTypes/BaseVariableProperty.cs.meta
new file mode 100644
index 00000000..d9b5ef93
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/BaseVariableProperty.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: c0b81b77632f7cd4a9925ab4d07618c1
+timeCreated: 1513473561
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/BooleanVariable.cs b/Assets/Fungus/Scripts/VariableTypes/BooleanVariable.cs
index 2c1da160..1e495cf1 100644
--- a/Assets/Fungus/Scripts/VariableTypes/BooleanVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/BooleanVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -13,45 +13,21 @@ namespace Fungus
[System.Serializable]
public class BooleanVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
- public static readonly SetOperator[] setOperators = { SetOperator.Assign, SetOperator.Negate };
-
- public virtual bool Evaluate(CompareOperator compareOperator, bool booleanValue)
+ public override bool IsArithmeticSupported(SetOperator setOperator)
{
- bool condition = false;
-
- bool lhs = Value;
- bool rhs = booleanValue;
-
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- condition = lhs == rhs;
- break;
- case CompareOperator.NotEquals:
- condition = lhs != rhs;
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
- }
-
- return condition;
+ return setOperator == SetOperator.Negate || base.IsArithmeticSupported(setOperator);
}
- public override void Apply(SetOperator setOperator, bool value)
+ public override void Apply(SetOperator op, bool value)
{
- switch (setOperator)
+ switch (op)
{
- case SetOperator.Assign:
- Value = value;
- break;
- case SetOperator.Negate:
- Value = !value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
+ case SetOperator.Negate:
+ Value = !value;
+ break;
+ default:
+ base.Apply(op, value);
+ break;
}
}
}
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection.meta b/Assets/Fungus/Scripts/VariableTypes/Collection.meta
new file mode 100644
index 00000000..059b2843
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 9efe8d23cd8ac9046a6e2b9f63ce780b
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs
new file mode 100644
index 00000000..3a6ac806
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs
@@ -0,0 +1,100 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System;
+using System.Collections;
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Provides a common and complete MonoBehavior based reference point for FungusCollection.
+ /// Fungus.GenericCollection inherits from this.
+ ///
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public abstract class Collection : MonoBehaviour, IFungusCollection
+ {
+ public abstract int Capacity { get; set; }
+ public abstract int Count { get; }
+ public bool IsFixedSize { get { return false; } }
+ public bool IsReadOnly { get { return false; } }
+ public bool IsSynchronized { get { return false; } }
+ public object SyncRoot { get { return null; } }
+ public string Name { get { return name; } }
+
+ public object this[int index] { get { return Get(index); } set { Set(index, value); } }
+
+ public abstract int Add(object o);
+
+ public abstract void Add(IFungusCollection rhsCol);
+
+ public abstract void AddUnique(object o);
+
+ public abstract void AddUnique(IFungusCollection rhsCol);
+
+ public abstract void Clear();
+
+ public abstract Type ContainedType();
+
+ public abstract bool Contains(object o);
+
+ public abstract bool ContainsAllOf(IFungusCollection rhsCol);
+
+ public abstract bool ContainsAllOfOrdered(IFungusCollection rhsCol);
+
+ public abstract bool ContainsAnyOf(IFungusCollection rhsCol);
+
+ public abstract void CopyFrom(IFungusCollection rhsCol);
+
+ public abstract void CopyFrom(System.Array array);
+
+ public abstract void CopyFrom(System.Collections.IList list);
+
+ public abstract void CopyTo(Array array, int index);
+
+ public abstract void Exclusive(IFungusCollection rhsCol);
+
+ public abstract object Get(int index);
+
+ public abstract void Get(int index, ref Variable variable);
+
+ public abstract IEnumerator GetEnumerator();
+
+ public abstract int IndexOf(object o);
+
+ public abstract void Insert(int index, object o);
+
+ public abstract void Intersection(IFungusCollection rhsCol);
+
+ public abstract bool IsCollectionCompatible(object o);
+
+ public abstract bool IsElementCompatible(object o);
+
+ public abstract int LastIndexOf(object o);
+
+ public abstract int Occurrences(object o);
+
+ public abstract void Remove(object o);
+
+ public abstract void RemoveAll(IFungusCollection rhsCol);
+
+ public abstract void RemoveAll(object o);
+
+ public abstract void RemoveAt(int index);
+
+ public abstract void Reserve(int count);
+
+ public abstract void Resize(int count);
+
+ public abstract void Reverse();
+
+ public abstract void Set(int index, object o);
+
+ public abstract void Shuffle();
+
+ public abstract void Sort();
+
+ public abstract void Unique();
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs.meta
new file mode 100644
index 00000000..0813a2cb
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a442c00dcdac2f74189524677670231b
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/Collider2DCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/Collider2DCollection.cs
new file mode 100644
index 00000000..f0146669
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/Collider2DCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class Collider2DCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/Collider2DCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/Collider2DCollection.cs.meta
new file mode 100644
index 00000000..6e23f050
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/Collider2DCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 731383c3611a5ed44ab997feeb990cd6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/ColliderCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/ColliderCollection.cs
new file mode 100644
index 00000000..013860d8
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/ColliderCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class ColliderCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/ColliderCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/ColliderCollection.cs.meta
new file mode 100644
index 00000000..bcfe0023
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/ColliderCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 29b65a983faf39e4db7e25a77610319f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/FloatCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/FloatCollection.cs
new file mode 100644
index 00000000..3a3a9d38
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/FloatCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class FloatCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/FloatCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/FloatCollection.cs.meta
new file mode 100644
index 00000000..795909bd
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/FloatCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f48297b98c3c1414c8e94ebe45883bb1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/GameObjectCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/GameObjectCollection.cs
new file mode 100644
index 00000000..06b0a9f2
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/GameObjectCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class GameObjectCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/GameObjectCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/GameObjectCollection.cs.meta
new file mode 100644
index 00000000..074a1b4b
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/GameObjectCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 150bd15698fd79541ace6f07d5304837
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs
new file mode 100644
index 00000000..7a44a80d
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs
@@ -0,0 +1,452 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+using System;
+using System.Collections;
+using System.Linq;
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// The meat of the Fungus Collection. Internally uses a List of given type, simplest example
+ /// being IntCollection. Provides some type specific additions to the base Collection for
+ /// increasing speed and safety.
+ ///
+ /// Uses Promote methods to convert from objects or other collection or Fungus.Variable types
+ /// being passed in, will attempt to do compatability for you, such as if you give an
+ /// IntCollection an int or a Fungus.IntVariable, either works as the Promote is aware
+ /// of Fungus.VariableBase. Will also allow mixing some operations between
+ /// GenericCollection, T[], and List.
+ ///
+ ///
+ [AddComponentMenu("")]
+ public class GenericCollection : Collection
+ {
+ [SerializeField]
+ protected System.Collections.Generic.List collection = new System.Collections.Generic.List();
+
+ public override int Capacity
+ {
+ get
+ {
+ return collection.Capacity;
+ }
+ set
+ {
+ collection.Capacity = value;
+ }
+ }
+
+ public override int Count { get { return collection.Count; } }
+
+ public override int Add(object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ return Add(t);
+ }
+ return -1;
+ }
+
+ public int Add(T t)
+ {
+ return (collection as System.Collections.IList).Add(t);
+ }
+
+ public override void Add(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ for (int i = 0; i < rhs.collection.Count; i++)
+ {
+ Add(rhs.collection[i]);
+ }
+ }
+ }
+
+ public override void AddUnique(object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ if (!collection.Contains(t))
+ {
+ collection.Add(t);
+ }
+ }
+ }
+
+ public void AddUnique(T t)
+ {
+ if (!collection.Contains(t))
+ {
+ Add(t);
+ }
+ }
+
+ public override void AddUnique(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ for (int i = 0; i < rhs.collection.Count; i++)
+ {
+ AddUnique(rhs.collection[i]);
+ }
+ }
+ }
+
+ public override void Clear()
+ {
+ collection.Clear();
+ }
+
+ public override System.Type ContainedType()
+ {
+ return typeof(T);
+ }
+
+ public override bool Contains(object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ return collection.Contains(t);
+ }
+ return false;
+ }
+
+ public override bool ContainsAllOf(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ for (int i = 0; i < rhs.collection.Count; i++)
+ {
+ if (!collection.Contains(rhs.collection[i]))
+ return false;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public override bool ContainsAllOfOrdered(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ if (rhs.Count == Count)
+ {
+ for (int i = 0; i < rhs.collection.Count; i++)
+ {
+ if (!rhs.collection[i].Equals(collection[i]))
+ return false;
+ }
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public override bool ContainsAnyOf(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ for (int i = 0; i < rhs.collection.Count; i++)
+ {
+ if (collection.Contains(rhs.collection[i]))
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public override void CopyFrom(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ collection.Clear();
+ collection.AddRange(rhs.collection);
+ }
+ }
+
+ public override void CopyFrom(Array array)
+ {
+ foreach (var item in array)
+ {
+ Add(item);
+ }
+ }
+
+ public override void CopyFrom(IList list)
+ {
+ foreach (var item in list)
+ {
+ Add(item);
+ }
+ }
+
+ public override void CopyTo(System.Array array, int index)
+ {
+ (collection as System.Collections.IList).CopyTo(array, index);
+ }
+
+ public override void Exclusive(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ //if its in both, remove, if its only in 1 keep
+ for (int i = 0; i < rhs.collection.Count; i++)
+ {
+ var item = rhs.collection[i];
+ if (!collection.Remove(item))
+ {
+ collection.Add(item);
+ }
+ }
+ }
+ }
+
+ public override object Get(int index)
+ {
+ return collection[index];
+ }
+
+ public override void Get(int index, ref Variable variable)
+ {
+ if (variable is VariableBase)
+ {
+ VariableBase vt = variable as VariableBase;
+ vt.Value = collection[index];
+ }
+ else
+ {
+ Debug.LogError("Collection cannot get variable " + variable.Key + ". Is not matching type:" + typeof(T).Name);
+ }
+ }
+
+ public override System.Collections.IEnumerator GetEnumerator()
+ {
+ return collection.GetEnumerator();
+ }
+
+ public virtual T GetSafe(int index)
+ {
+ return collection[index];
+ }
+
+ public override int IndexOf(object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ return collection.IndexOf(t);
+ }
+ return -1;
+ }
+
+ public override void Insert(int index, object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ collection.Insert(index, t);
+ }
+ }
+
+ public override void Intersection(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ //only things that are in us and in rhs remain
+ for (int i = collection.Count - 1; i >= 0; i--)
+ {
+ if (!rhs.Contains(collection[i]))
+ {
+ collection.RemoveAt(i);
+ }
+ }
+ }
+ }
+
+ public override bool IsCollectionCompatible(object o)
+ {
+ if (o is GenericCollection || o is System.Collections.Generic.IList)
+ return true;
+
+ var ot = o.GetType();
+ var ote = ot.GetElementType();
+ var otgs = ot.GetGenericArguments();
+
+ //element type only works for arrays, need to use getgenerictype with ilist<>T
+ if (o is System.Array)
+ {
+ return ote is T || ote is Fungus.VariableBase;
+ }
+ else if (o is System.Collections.IList && otgs.Length > 0)
+ {
+ return otgs[0] == typeof(T) || otgs[0].IsSubclassOf(typeof(Fungus.VariableBase));
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public override bool IsElementCompatible(object o)
+ {
+ return o is T || o is VariableBase;
+ }
+
+ public override int LastIndexOf(object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ return collection.LastIndexOf(t);
+ }
+ return -1;
+ }
+
+ public override int Occurrences(object o)
+ {
+ int retval = 0;
+ var t = Promote(o);
+ if (t != null)
+ {
+ for (int i = 0; i < collection.Count; i++)
+ {
+ if (collection[i].Equals(t))
+ retval++;
+ }
+ }
+ return retval;
+ }
+
+ public override void Remove(object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ collection.Remove(t);
+ }
+ }
+
+ public override void RemoveAll(object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ collection.RemoveAll(x => x.Equals(t));
+ }
+ }
+
+ public override void RemoveAll(IFungusCollection rhsCol)
+ {
+ var rhs = Promote(rhsCol);
+ if (rhs != null)
+ {
+ for (int i = rhsCol.Count - 1; i >= 0; i--)
+ {
+ collection.RemoveAll(x => x.Equals(rhs.collection[i]));
+ }
+ }
+ }
+
+ public override void RemoveAt(int index)
+ {
+ collection.RemoveAt(index);
+ }
+
+ public override void Reserve(int count)
+ {
+ collection.Capacity = count;
+ }
+
+ public override void Resize(int count)
+ {
+ var toAdd = count - collection.Count;
+ if (toAdd > 0)
+ collection.AddRange(System.Linq.Enumerable.Repeat(default(T), toAdd));
+ }
+
+ public override void Reverse()
+ {
+ collection.Reverse();
+ }
+
+ public override void Set(int index, object o)
+ {
+ var t = Promote(o);
+ if (t != null)
+ {
+ collection[index] = t;
+ }
+ }
+
+ public virtual void Set(int index, T value)
+ {
+ collection[index] = value;
+ }
+
+ public override void Shuffle()
+ {
+ for (int i = 0; i < collection.Count; i++)
+ {
+ var tmp = collection[i];
+ var rnd = UnityEngine.Random.Range(0, collection.Count);
+ collection[i] = collection[rnd];
+ collection[rnd] = tmp;
+ }
+ }
+
+ public override void Sort()
+ {
+ collection.Sort();
+ }
+
+ public override void Unique()
+ {
+ collection = collection.Distinct().ToList();
+ }
+
+ protected virtual T Promote(object o)
+ {
+ if (o is T)
+ {
+ return (T)o;
+ }
+ else if (o is VariableBase)
+ {
+ var oAs = o as VariableBase;
+ return (T)oAs.Value;
+ }
+
+ Debug.LogError("Collection cannot promote " + o.GetType().Name + " to " + typeof(T).Name);
+ return default(T);
+ }
+
+ protected virtual GenericCollection Promote(IFungusCollection col)
+ {
+ if (col is GenericCollection)
+ {
+ return (GenericCollection)col;
+ }
+
+ Debug.LogError("Collection cannot promote " + col.GetType().Name + " to " + this.GetType().Name);
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs.meta
new file mode 100644
index 00000000..64210af0
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5f1b7585d9e20fb4fa2af08c7d122c43
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/IntCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/IntCollection.cs
new file mode 100644
index 00000000..583c0e5e
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/IntCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class IntCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/IntCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/IntCollection.cs.meta
new file mode 100644
index 00000000..8f5e3e1b
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/IntCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 221f0f261cfcb8a40b9f79cbc51a9148
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/IntVarCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/IntVarCollection.cs
new file mode 100644
index 00000000..a0147c2e
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/IntVarCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class IntVarCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/IntVarCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/IntVarCollection.cs.meta
new file mode 100644
index 00000000..4363aa2e
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/IntVarCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a852e2fd041ceda439efd62fd08491ca
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/StringCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/StringCollection.cs
new file mode 100644
index 00000000..e66c4b1a
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/StringCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class StringCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/StringCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/StringCollection.cs.meta
new file mode 100644
index 00000000..01df8232
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/StringCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5a160a99a0d1b6a48847f6d7ff25dac3
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/TransformCollection.cs b/Assets/Fungus/Scripts/VariableTypes/Collection/TransformCollection.cs
new file mode 100644
index 00000000..21e5cc71
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/TransformCollection.cs
@@ -0,0 +1,9 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+namespace Fungus
+{
+ public class TransformCollection : GenericCollection
+ {
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collection/TransformCollection.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collection/TransformCollection.cs.meta
new file mode 100644
index 00000000..f6bfbfa6
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collection/TransformCollection.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 65f1198eb774e9b48816b995d01e5053
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/CollectionVariable.cs b/Assets/Fungus/Scripts/VariableTypes/CollectionVariable.cs
new file mode 100644
index 00000000..b88aef31
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/CollectionVariable.cs
@@ -0,0 +1,61 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Collection variable type.
+ ///
+ [VariableInfo("Other", "Collection")]
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public class CollectionVariable : VariableBase
+ { }
+
+ ///
+ /// Container for a Collection variable reference or constant value.
+ ///
+ [System.Serializable]
+ public struct CollectionData
+ {
+ [SerializeField]
+ [VariableProperty("", typeof(CollectionVariable))]
+ public CollectionVariable collectionRef;
+
+ [SerializeField]
+ public Fungus.Collection collectionVal;
+
+ public static implicit operator Fungus.Collection(CollectionData CollectionData)
+ {
+ return CollectionData.Value;
+ }
+
+ public CollectionData(Fungus.Collection v)
+ {
+ collectionVal = v;
+ collectionRef = null;
+ }
+
+ public Fungus.Collection Value
+ {
+ get { return (collectionRef == null) ? collectionVal : collectionRef.Value; }
+ set { if (collectionRef == null) { collectionVal = value; } else { collectionRef.Value = value; } }
+ }
+
+ public string GetDescription()
+ {
+ if (collectionRef == null)
+ {
+ return collectionVal != null ? collectionVal.ToString() : "Null";
+ }
+ else
+ {
+ return collectionRef.Key;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/CollectionVariable.cs.meta b/Assets/Fungus/Scripts/VariableTypes/CollectionVariable.cs.meta
new file mode 100644
index 00000000..99b1f728
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/CollectionVariable.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4511d925e22af8c4a85a568153258f84
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collider2DVariable.cs b/Assets/Fungus/Scripts/VariableTypes/Collider2DVariable.cs
new file mode 100644
index 00000000..6158ec6a
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collider2DVariable.cs
@@ -0,0 +1,61 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Collider2D variable type.
+ ///
+ [VariableInfo("Other", "Collider2D")]
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public class Collider2DVariable : VariableBase
+ { }
+
+ ///
+ /// Container for a Collider2D variable reference or constant value.
+ ///
+ [System.Serializable]
+ public struct Collider2DData
+ {
+ [SerializeField]
+ [VariableProperty("", typeof(Collider2DVariable))]
+ public Collider2DVariable collider2DRef;
+
+ [SerializeField]
+ public UnityEngine.Collider2D collider2DVal;
+
+ public static implicit operator UnityEngine.Collider2D(Collider2DData Collider2DData)
+ {
+ return Collider2DData.Value;
+ }
+
+ public Collider2DData(UnityEngine.Collider2D v)
+ {
+ collider2DVal = v;
+ collider2DRef = null;
+ }
+
+ public UnityEngine.Collider2D Value
+ {
+ get { return (collider2DRef == null) ? collider2DVal : collider2DRef.Value; }
+ set { if (collider2DRef == null) { collider2DVal = value; } else { collider2DRef.Value = value; } }
+ }
+
+ public string GetDescription()
+ {
+ if (collider2DRef == null)
+ {
+ return collider2DVal != null ? collider2DVal.ToString() : "Null";
+ }
+ else
+ {
+ return collider2DRef.Key;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collider2DVariable.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collider2DVariable.cs.meta
new file mode 100644
index 00000000..ac7c3476
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collider2DVariable.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: a3f274bcd518c0647b0d9ce7c8f3ab84
+timeCreated: 1517559095
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/ColliderVariable.cs b/Assets/Fungus/Scripts/VariableTypes/ColliderVariable.cs
new file mode 100644
index 00000000..7d2e43ed
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/ColliderVariable.cs
@@ -0,0 +1,61 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Collider variable type.
+ ///
+ [VariableInfo("Other", "Collider")]
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public class ColliderVariable : VariableBase
+ { }
+
+ ///
+ /// Container for a Collider variable reference or constant value.
+ ///
+ [System.Serializable]
+ public struct ColliderData
+ {
+ [SerializeField]
+ [VariableProperty("", typeof(ColliderVariable))]
+ public ColliderVariable colliderRef;
+
+ [SerializeField]
+ public UnityEngine.Collider colliderVal;
+
+ public static implicit operator UnityEngine.Collider(ColliderData ColliderData)
+ {
+ return ColliderData.Value;
+ }
+
+ public ColliderData(UnityEngine.Collider v)
+ {
+ colliderVal = v;
+ colliderRef = null;
+ }
+
+ public UnityEngine.Collider Value
+ {
+ get { return (colliderRef == null) ? colliderVal : colliderRef.Value; }
+ set { if (colliderRef == null) { colliderVal = value; } else { colliderRef.Value = value; } }
+ }
+
+ public string GetDescription()
+ {
+ if (colliderRef == null)
+ {
+ return colliderVal != null ? colliderVal.ToString() : "Null";
+ }
+ else
+ {
+ return colliderRef.Key;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/ColliderVariable.cs.meta b/Assets/Fungus/Scripts/VariableTypes/ColliderVariable.cs.meta
new file mode 100644
index 00000000..c704ec31
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/ColliderVariable.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 0057f41f38d80eb42994d709097bab6c
+timeCreated: 1517559091
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collision2DVariable.cs b/Assets/Fungus/Scripts/VariableTypes/Collision2DVariable.cs
new file mode 100644
index 00000000..3b38944b
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collision2DVariable.cs
@@ -0,0 +1,18 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Collision2D variable type.
+ ///
+ [VariableInfo("Other", "Collision2D", IsPreviewedOnly = true)]
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public class Collision2DVariable : VariableBase
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Collision2DVariable.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Collision2DVariable.cs.meta
new file mode 100644
index 00000000..4b06a6e2
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Collision2DVariable.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 303f39102fa585240b75ba39909c0420
+timeCreated: 1517559039
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/CollisionVariable.cs b/Assets/Fungus/Scripts/VariableTypes/CollisionVariable.cs
new file mode 100644
index 00000000..41edb5e3
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/CollisionVariable.cs
@@ -0,0 +1,18 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Collision variable type.
+ ///
+ [VariableInfo("Other", "Collision", IsPreviewedOnly = true)]
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public class CollisionVariable : VariableBase
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/CollisionVariable.cs.meta b/Assets/Fungus/Scripts/VariableTypes/CollisionVariable.cs.meta
new file mode 100644
index 00000000..15644cf9
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/CollisionVariable.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: ab82206607c7ce145899c6dded6ed656
+timeCreated: 1517559033
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/ColorVariable.cs b/Assets/Fungus/Scripts/VariableTypes/ColorVariable.cs
index eb30ba44..d9050e97 100644
--- a/Assets/Fungus/Scripts/VariableTypes/ColorVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/ColorVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -14,57 +14,30 @@ namespace Fungus
[System.Serializable]
public class ColorVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
- public static readonly SetOperator[] setOperators = {
- SetOperator.Assign,
- SetOperator.Add,
- SetOperator.Subtract,
- SetOperator.Multiply
- };
-
- protected static bool ColorsEqual(Color a, Color b) {
- return ColorUtility.ToHtmlStringRGBA(a) == ColorUtility.ToHtmlStringRGBA(b);
- }
-
- public virtual bool Evaluate(CompareOperator compareOperator, Color value)
+ public override bool IsArithmeticSupported(SetOperator setOperator)
{
- bool condition = false;
-
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- condition = ColorsEqual(Value, value);
- break;
- case CompareOperator.NotEquals:
- condition = !ColorsEqual(Value, value);
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
- }
-
- return condition;
+ return setOperator != SetOperator.Negate;
}
public override void Apply(SetOperator setOperator, Color value)
{
switch (setOperator)
{
- case SetOperator.Assign:
- Value = value;
- break;
- case SetOperator.Add:
- Value += value;
- break;
- case SetOperator.Subtract:
- Value -= value;
- break;
- case SetOperator.Multiply:
- Value *= value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
+ case SetOperator.Add:
+ Value += value;
+ break;
+ case SetOperator.Subtract:
+ Value -= value;
+ break;
+ case SetOperator.Multiply:
+ Value *= value;
+ break;
+ case SetOperator.Divide:
+ Value *= new Color(1.0f/value.r, 1.0f / value.g, 1.0f / value.b, 1.0f / value.a);
+ break;
+ default:
+ base.Apply(setOperator, value);
+ break;
}
}
}
diff --git a/Assets/Fungus/Scripts/VariableTypes/ControllerColliderHitVariable.cs b/Assets/Fungus/Scripts/VariableTypes/ControllerColliderHitVariable.cs
new file mode 100644
index 00000000..e2d2b846
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/ControllerColliderHitVariable.cs
@@ -0,0 +1,18 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// ControllerColliderHit variable type.
+ ///
+ [VariableInfo("Other", "ControllerColliderHit", IsPreviewedOnly = true)]
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public class ControllerColliderHitVariable : VariableBase
+ { }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/ControllerColliderHitVariable.cs.meta b/Assets/Fungus/Scripts/VariableTypes/ControllerColliderHitVariable.cs.meta
new file mode 100644
index 00000000..6bf4d06d
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/ControllerColliderHitVariable.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1697e3d2923d7a04992d32e821365308
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/FloatVariable.cs b/Assets/Fungus/Scripts/VariableTypes/FloatVariable.cs
index 083e2528..7e9bb88a 100644
--- a/Assets/Fungus/Scripts/VariableTypes/FloatVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/FloatVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -13,80 +13,68 @@ namespace Fungus
[System.Serializable]
public class FloatVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = {
- CompareOperator.Equals,
- CompareOperator.NotEquals,
- CompareOperator.LessThan,
- CompareOperator.GreaterThan,
- CompareOperator.LessThanOrEquals,
- CompareOperator.GreaterThanOrEquals
- };
- public static readonly SetOperator[] setOperators = {
- SetOperator.Assign,
- SetOperator.Add,
- SetOperator.Subtract,
- SetOperator.Multiply,
- SetOperator.Divide
- };
+ public override bool IsArithmeticSupported(SetOperator setOperator)
+ {
+ return true;
+ }
- public virtual bool Evaluate(CompareOperator compareOperator, float floatValue)
+ public override bool IsComparisonSupported()
{
- float lhs = Value;
- float rhs = floatValue;
-
- bool condition = false;
-
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- condition = lhs == rhs;
- break;
- case CompareOperator.NotEquals:
- condition = lhs != rhs;
- break;
- case CompareOperator.LessThan:
- condition = lhs < rhs;
- break;
- case CompareOperator.GreaterThan:
- condition = lhs > rhs;
- break;
- case CompareOperator.LessThanOrEquals:
- condition = lhs <= rhs;
- break;
- case CompareOperator.GreaterThanOrEquals:
- condition = lhs >= rhs;
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
- }
-
- return condition;
+ return true;
}
public override void Apply(SetOperator setOperator, float value)
{
switch (setOperator)
{
- case SetOperator.Assign:
- Value = value;
- break;
- case SetOperator.Add:
- Value += value;
- break;
- case SetOperator.Subtract:
- Value -= value;
- break;
- case SetOperator.Multiply:
- Value *= value;
- break;
- case SetOperator.Divide:
- Value /= value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
+ case SetOperator.Negate:
+ Value = Value * -1;
+ break;
+ case SetOperator.Add:
+ Value += value;
+ break;
+ case SetOperator.Subtract:
+ Value -= value;
+ break;
+ case SetOperator.Multiply:
+ Value *= value;
+ break;
+ case SetOperator.Divide:
+ Value /= value;
+ break;
+ default:
+ base.Apply(setOperator, value);
+ break;
+ }
+ }
+
+ public override bool Evaluate(CompareOperator compareOperator, float value)
+ {
+ float lhs = Value;
+ float rhs = value;
+
+ bool condition = false;
+
+ switch (compareOperator)
+ {
+ case CompareOperator.LessThan:
+ condition = lhs < rhs;
+ break;
+ case CompareOperator.GreaterThan:
+ condition = lhs > rhs;
+ break;
+ case CompareOperator.LessThanOrEquals:
+ condition = lhs <= rhs;
+ break;
+ case CompareOperator.GreaterThanOrEquals:
+ condition = lhs >= rhs;
+ break;
+ default:
+ condition = base.Evaluate(compareOperator, base.value);
+ break;
}
+
+ return condition;
}
}
diff --git a/Assets/Fungus/Scripts/VariableTypes/GameObjectVariable.cs b/Assets/Fungus/Scripts/VariableTypes/GameObjectVariable.cs
index f4b3538f..c5a7821e 100644
--- a/Assets/Fungus/Scripts/VariableTypes/GameObjectVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/GameObjectVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -14,44 +14,6 @@ namespace Fungus
[System.Serializable]
public class GameObjectVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
- public static readonly SetOperator[] setOperators = { SetOperator.Assign };
-
- public virtual bool Evaluate(CompareOperator compareOperator, GameObject gameObjectValue)
- {
- GameObject lhs = Value;
- GameObject rhs = gameObjectValue;
-
- bool condition = false;
-
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- condition = lhs == rhs;
- break;
- case CompareOperator.NotEquals:
- condition = lhs != rhs;
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
- }
-
- return condition;
- }
-
- public override void Apply(SetOperator setOperator, GameObject value)
- {
- switch (setOperator)
- {
- case SetOperator.Assign:
- Value = value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
- }
- }
}
///
@@ -88,7 +50,7 @@ namespace Fungus
{
if (gameObjectRef == null)
{
- return gameObjectVal.ToString();
+ return gameObjectVal != null ? gameObjectVal.ToString() : "Null";
}
else
{
diff --git a/Assets/Fungus/Scripts/VariableTypes/IntegerVariable.cs b/Assets/Fungus/Scripts/VariableTypes/IntegerVariable.cs
index 06726b58..43932395 100644
--- a/Assets/Fungus/Scripts/VariableTypes/IntegerVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/IntegerVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -11,83 +11,71 @@ namespace Fungus
[VariableInfo("", "Integer")]
[AddComponentMenu("")]
[System.Serializable]
- public class IntegerVariable : VariableBase
+ public class IntegerVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = {
- CompareOperator.Equals,
- CompareOperator.NotEquals,
- CompareOperator.LessThan,
- CompareOperator.GreaterThan,
- CompareOperator.LessThanOrEquals,
- CompareOperator.GreaterThanOrEquals
- };
- public static readonly SetOperator[] setOperators = {
- SetOperator.Assign,
- SetOperator.Add,
- SetOperator.Subtract,
- SetOperator.Multiply,
- SetOperator.Divide
- };
+ public override bool IsArithmeticSupported(SetOperator setOperator)
+ {
+ return true;
+ }
+
+ public override bool IsComparisonSupported()
+ {
+ return true;
+ }
- public virtual bool Evaluate(CompareOperator compareOperator, int integerValue)
+ public override void Apply(SetOperator setOperator, int value)
+ {
+ switch (setOperator)
+ {
+ case SetOperator.Negate:
+ Value = Value * -1;
+ break;
+ case SetOperator.Add:
+ Value += value;
+ break;
+ case SetOperator.Subtract:
+ Value -= value;
+ break;
+ case SetOperator.Multiply:
+ Value *= value;
+ break;
+ case SetOperator.Divide:
+ Value /= value;
+ break;
+ default:
+ base.Apply(setOperator, value);
+ break;
+ }
+ }
+
+ public override bool Evaluate(CompareOperator compareOperator, int value)
{
int lhs = Value;
- int rhs = integerValue;
+ int rhs = value;
bool condition = false;
switch (compareOperator)
{
- case CompareOperator.Equals:
- condition = lhs == rhs;
- break;
- case CompareOperator.NotEquals:
- condition = lhs != rhs;
- break;
- case CompareOperator.LessThan:
- condition = lhs < rhs;
- break;
- case CompareOperator.GreaterThan:
- condition = lhs > rhs;
- break;
- case CompareOperator.LessThanOrEquals:
- condition = lhs <= rhs;
- break;
- case CompareOperator.GreaterThanOrEquals:
- condition = lhs >= rhs;
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
+ case CompareOperator.LessThan:
+ condition = lhs < rhs;
+ break;
+ case CompareOperator.GreaterThan:
+ condition = lhs > rhs;
+ break;
+ case CompareOperator.LessThanOrEquals:
+ condition = lhs <= rhs;
+ break;
+ case CompareOperator.GreaterThanOrEquals:
+ condition = lhs >= rhs;
+ break;
+ default:
+ condition = base.Evaluate(compareOperator, value);
+ break;
}
return condition;
}
-
- public override void Apply(SetOperator setOperator, int value)
- {
- switch (setOperator)
- {
- case SetOperator.Assign:
- Value = value;
- break;
- case SetOperator.Add:
- Value += value;
- break;
- case SetOperator.Subtract:
- Value -= value;
- break;
- case SetOperator.Multiply:
- Value *= value;
- break;
- case SetOperator.Divide:
- Value /= value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
- }
- }
}
///
diff --git a/Assets/Fungus/Scripts/VariableTypes/MaterialVariable.cs b/Assets/Fungus/Scripts/VariableTypes/MaterialVariable.cs
index 5617a655..f35a122f 100644
--- a/Assets/Fungus/Scripts/VariableTypes/MaterialVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/MaterialVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -14,41 +14,6 @@ namespace Fungus
[System.Serializable]
public class MaterialVariable : VariableBase
{
- public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals };
- public static readonly SetOperator[] setOperators = { SetOperator.Assign };
-
- public virtual bool Evaluate(CompareOperator compareOperator, Material value)
- {
- bool condition = false;
-
- switch (compareOperator)
- {
- case CompareOperator.Equals:
- condition = Value == value;
- break;
- case CompareOperator.NotEquals:
- condition = Value != value;
- break;
- default:
- Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
- break;
- }
-
- return condition;
- }
-
- public override void Apply(SetOperator setOperator, Material value)
- {
- switch (setOperator)
- {
- case SetOperator.Assign:
- Value = value;
- break;
- default:
- Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
- break;
- }
- }
}
///
@@ -85,7 +50,7 @@ namespace Fungus
{
if (materialRef == null)
{
- return materialVal.ToString();
+ return materialVal != null ? materialVal.ToString() : "Null";
}
else
{
diff --git a/Assets/Fungus/Scripts/VariableTypes/Matrix4x4Variable.cs b/Assets/Fungus/Scripts/VariableTypes/Matrix4x4Variable.cs
new file mode 100644
index 00000000..e852ad64
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Matrix4x4Variable.cs
@@ -0,0 +1,94 @@
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
+// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
+
+/*This script has been, partially or completely, generated by the Fungus.GenerateVariableWindow*/
+
+using UnityEngine;
+
+namespace Fungus
+{
+ ///
+ /// Matrix4x4 variable type.
+ ///
+ [VariableInfo("Other", "Matrix4x4", IsPreviewedOnly = true)]
+ [AddComponentMenu("")]
+ [System.Serializable]
+ public class Matrix4x4Variable : VariableBase
+ {
+ public override bool IsArithmeticSupported(SetOperator setOperator)
+ {
+ return setOperator == SetOperator.Multiply || base.IsArithmeticSupported(setOperator);
+ }
+
+ public override void Apply(SetOperator setOperator, Matrix4x4 value)
+ {
+ Matrix4x4 local = Value;
+
+ switch (setOperator)
+ {
+ case SetOperator.Add:
+ Debug.LogWarning("Matrix4x4 Add not supported");
+ break;
+
+ case SetOperator.Subtract:
+ Debug.LogWarning("Matrix4x4 Subtract not supported");
+ break;
+
+ case SetOperator.Multiply:
+ Value = local * value;
+ break;
+
+ case SetOperator.Divide:
+ Debug.LogWarning("Matrix4x4 Divide not supported");
+ break;
+
+ default:
+ base.Apply(setOperator, value);
+ break;
+ }
+ }
+ }
+
+ ///
+ /// Container for a Matrix4x4 variable reference or constant value.
+ ///
+ [System.Serializable]
+ public struct Matrix4x4Data
+ {
+ [SerializeField]
+ [VariableProperty("", typeof(Matrix4x4Variable))]
+ public Matrix4x4Variable matrix4x4Ref;
+
+ [SerializeField]
+ public UnityEngine.Matrix4x4 matrix4x4Val;
+
+ public static implicit operator UnityEngine.Matrix4x4(Matrix4x4Data Matrix4x4Data)
+ {
+ return Matrix4x4Data.Value;
+ }
+
+ public Matrix4x4Data(UnityEngine.Matrix4x4 v)
+ {
+ matrix4x4Val = v;
+ matrix4x4Ref = null;
+ }
+
+ public UnityEngine.Matrix4x4 Value
+ {
+ get { return (matrix4x4Ref == null) ? matrix4x4Val : matrix4x4Ref.Value; }
+ set { if (matrix4x4Ref == null) { matrix4x4Val = value; } else { matrix4x4Ref.Value = value; } }
+ }
+
+ public string GetDescription()
+ {
+ if (matrix4x4Ref == null)
+ {
+ return matrix4x4Val.ToString();
+ }
+ else
+ {
+ return matrix4x4Ref.Key;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Fungus/Scripts/VariableTypes/Matrix4x4Variable.cs.meta b/Assets/Fungus/Scripts/VariableTypes/Matrix4x4Variable.cs.meta
new file mode 100644
index 00000000..2c468872
--- /dev/null
+++ b/Assets/Fungus/Scripts/VariableTypes/Matrix4x4Variable.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 92a3ae3fceb40f24db63f0e4085f39cc
+timeCreated: 1513473561
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Fungus/Scripts/VariableTypes/ObjectVariable.cs b/Assets/Fungus/Scripts/VariableTypes/ObjectVariable.cs
index 39d6df3f..8e732334 100644
--- a/Assets/Fungus/Scripts/VariableTypes/ObjectVariable.cs
+++ b/Assets/Fungus/Scripts/VariableTypes/ObjectVariable.cs
@@ -1,4 +1,4 @@
-// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
+// This code is part of the Fungus library (https://github.com/snozbot/fungus)
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
@@ -14,41 +14,6 @@ namespace Fungus
[System.Serializable]
public class ObjectVariable : VariableBase