diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable.cs new file mode 100644 index 00000000..fa3a62e0 --- /dev/null +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable.cs @@ -0,0 +1,45 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace Fungus +{ + [CommandInfo("Sprite", + "Set Draggable 2D", + "Sets a Draggable2D component to be draggable / non-draggable.")] + [AddComponentMenu("")] + public class SetDraggable2D : Command + { + [Tooltip("Reference to Draggable2D component on a gameobject")] + public Draggable2D targetDraggable2D; + + [Tooltip("Set to true to enable the component")] + public BooleanData activeState; + + public override void OnEnter() + { + if (targetDraggable2D != null) + { + targetDraggable2D.dragEnabled = activeState.Value; + } + + Continue(); + } + + public override string GetSummary() + { + if (targetDraggable2D == null) + { + return "Error: No Draggable2D component selected"; + } + + return targetDraggable2D.gameObject.name; + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable.cs.meta b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable.cs.meta new file mode 100644 index 00000000..1f19c7df --- /dev/null +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c987b33e737044fb185f6ae869a7bc17 +timeCreated: 1453469154 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Sprite/SpriteTests.unity b/Assets/Tests/Sprite/SpriteTests.unity index 772a7429..5b99a06b 100644 --- a/Assets/Tests/Sprite/SpriteTests.unity +++ b/Assets/Tests/Sprite/SpriteTests.unity @@ -143,6 +143,21 @@ SpriteRenderer: m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 +--- !u!115 &161440402 +MonoScript: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: + serializedVersion: 4 + m_Script: + m_DefaultReferences: {} + m_Icon: {fileID: 0} + m_ExecutionOrder: 0 + m_ClassName: SetDraggable2D + m_Namespace: Fungus + m_AssemblyName: Assembly-CSharp.dll + m_IsEditorScript: 0 --- !u!114 &162619748 MonoBehaviour: m_ObjectHideFlags: 0 @@ -349,6 +364,126 @@ MonoBehaviour: checkMethods: 1 m_ActionBase: {fileID: 1472816438} checksPerformed: 0 +--- !u!1 &625047147 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 625047148} + - 114: {fileID: 625047151} + - 114: {fileID: 625047150} + - 114: {fileID: 625047149} + - 114: {fileID: 625047152} + m_Layer: 0 + m_Name: Flowchart + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &625047148 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 625047147} + 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: 1892781631} + m_RootOrder: 1 +--- !u!114 &625047149 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 11462346, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 625047147} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3} + m_Name: + m_EditorClassIdentifier: + parentBlock: {fileID: 625047150} +--- !u!114 &625047150 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 625047147} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3} + m_Name: + m_EditorClassIdentifier: + nodeRect: + serializedVersion: 2 + x: 67 + y: 70 + width: 120 + height: 40 + itemId: 0 + blockName: Start + description: + eventHandler: {fileID: 625047149} + commandList: + - {fileID: 625047152} +--- !u!114 &625047151 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 625047147} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 1.0 + scrollPos: {x: 0, y: 0} + variablesScrollPos: {x: 0, y: 0} + variablesExpanded: 1 + blockViewHeight: 400 + zoom: 1 + scrollViewRect: + serializedVersion: 2 + x: -343 + y: -340 + width: 1114 + height: 859 + selectedBlock: {fileID: 0} + selectedCommands: [] + variables: [] + description: Test if the SetDraggable command sets the Drag Enabled property + stepPause: 0 + colorCommands: 1 + hideComponents: 1 + saveSelection: 1 + localizationId: + hideCommands: [] +--- !u!114 &625047152 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 625047147} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 161440402} + m_Name: + m_EditorClassIdentifier: + itemId: 1 + errorMessage: + indentLevel: 0 + targetDraggable2D: {fileID: 1178281937} + activeState: + booleanRef: {fileID: 0} + booleanVal: 0 --- !u!1 &647587210 GameObject: m_ObjectHideFlags: 0 @@ -527,6 +662,23 @@ SpriteRenderer: m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 +--- !u!114 &733558333 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2586c8e41f35d2f4fadde53020bf4207, type: 3} + m_Name: + m_EditorClassIdentifier: + go: {fileID: 1178281935} + thisPropertyPath: Draggable2D.dragEnabled + compareToType: 1 + other: {fileID: 0} + otherPropertyPath: + constantValueGeneric: 0 --- !u!1 &744934489 GameObject: m_ObjectHideFlags: 0 @@ -668,6 +820,118 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_RootOrder: 4 +--- !u!1 &1178281935 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 100000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, type: 2} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1178281936} + - 212: {fileID: 1178281940} + - 61: {fileID: 1178281939} + - 50: {fileID: 1178281938} + - 114: {fileID: 1178281937} + m_Layer: 0 + m_Name: DraggableSprite + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1178281936 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 400000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1178281935} + 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: 1892781631} + m_RootOrder: 0 +--- !u!114 &1178281937 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 11400000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1178281935} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 18a0e492e94664ec0ac44d252c40e3a7, type: 3} + m_Name: + m_EditorClassIdentifier: + dragEnabled: 1 + returnOnCancelled: 1 + returnOnCompleted: 1 + returnDuration: 1 + hoverCursor: {fileID: 0} +--- !u!50 &1178281938 +Rigidbody2D: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 5000000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1178281935} + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_IsKinematic: 1 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!61 &1178281939 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 6100000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1178281935} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_Offset: {x: 0, y: 0} + serializedVersion: 2 + m_Size: {x: 3, y: 3} +--- !u!212 &1178281940 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 21200000, guid: 4d55f86cf3b124c8fb1158da26ffa96d, + type: 2} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1178281935} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_ReflectionProbeUsage: 0 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 --- !u!1 &1307141168 GameObject: m_ObjectHideFlags: 0 @@ -841,6 +1105,55 @@ MonoBehaviour: platformsToIgnore: [] dynamic: 0 dynamicTypeName: +--- !u!1 &1455730991 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1455730992} + - 114: {fileID: 1455730993} + m_Layer: 0 + m_Name: TestAssertions + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1455730992 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1455730991} + 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: 1892781631} + m_RootOrder: 2 +--- !u!114 &1455730993 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1455730991} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8bafa54482a87ac4cbd7ff1bfd1ac93a, type: 3} + m_Name: + m_EditorClassIdentifier: + checkAfterTime: 1 + repeatCheckTime: 0 + repeatEveryTime: 1 + checkAfterFrames: 1 + repeatCheckFrame: 1 + repeatEveryFrame: 1 + hasFailed: 0 + checkMethods: 1 + m_ActionBase: {fileID: 733558333} + checksPerformed: 0 --- !u!114 &1472816438 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1159,6 +1472,58 @@ SpriteRenderer: m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 +--- !u!1 &1892781629 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1892781631} + - 114: {fileID: 1892781630} + m_Layer: 0 + m_Name: SetDraggable2DTest + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1892781630 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1892781629} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b1dba0b27b0864740a8720e920aa88c0, type: 3} + m_Name: + m_EditorClassIdentifier: + timeout: 5 + ignored: 0 + succeedAfterAllAssertionsAreExecuted: 1 + expectException: 0 + expectedExceptionList: + succeedWhenExceptionIsThrown: 0 + includedPlatforms: -1 + platformsToIgnore: [] + dynamic: 0 + dynamicTypeName: +--- !u!4 &1892781631 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1892781629} + 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: 1178281936} + - {fileID: 625047148} + - {fileID: 1455730992} + m_Father: {fileID: 0} + m_RootOrder: 7 --- !u!1 &1894706150 GameObject: m_ObjectHideFlags: 0 @@ -1387,7 +1752,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3} m_Name: m_EditorClassIdentifier: - selectedFlowchart: {fileID: 647587214} + selectedFlowchart: {fileID: 625047151} --- !u!4 &2126790767 Transform: m_ObjectHideFlags: 1