From 769f0ffabb2cadab3ace72717c5a52a6d71ffd08 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 23 Aug 2016 16:15:22 +0100 Subject: [PATCH] Refactored sprite comments --- Assets/Fungus/Sprite/Scripts/Clickable2D.cs | 11 +++--- .../Sprite/Scripts/Commands/FadeSprite.cs | 5 +-- .../Sprite/Scripts/Commands/SetClickable2D.cs | 5 +-- .../Sprite/Scripts/Commands/SetCollider.cs | 4 ++- .../Sprite/Scripts/Commands/SetDraggable2D.cs | 5 +-- .../Sprite/Scripts/Commands/SetLayerOrder.cs | 5 +-- .../Sprite/Scripts/Commands/SetMouseCursor.cs | 4 ++- .../Sprite/Scripts/Commands/SetSpriteOrder.cs | 4 ++- .../Sprite/Scripts/Commands/ShowSprite.cs | 5 +-- Assets/Fungus/Sprite/Scripts/Draggable2D.cs | 16 ++++----- .../Scripts/EventHandlers/DragCancelled.cs | 6 ++-- .../Scripts/EventHandlers/DragCompleted.cs | 6 ++-- .../Scripts/EventHandlers/DragEntered.cs | 4 ++- .../Scripts/EventHandlers/DragExited.cs | 4 ++- .../Scripts/EventHandlers/DragStarted.cs | 6 ++-- .../Scripts/EventHandlers/ObjectClicked.cs | 4 ++- Assets/Fungus/Sprite/Scripts/Parallax.cs | 35 +++++++++---------- Assets/Fungus/Sprite/Scripts/SpriteFader.cs | 14 ++++---- 18 files changed, 78 insertions(+), 65 deletions(-) diff --git a/Assets/Fungus/Sprite/Scripts/Clickable2D.cs b/Assets/Fungus/Sprite/Scripts/Clickable2D.cs index cb5b99fc..50651132 100644 --- a/Assets/Fungus/Sprite/Scripts/Clickable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Clickable2D.cs @@ -8,16 +8,15 @@ using UnityEngine.EventSystems; namespace Fungus { - /** - * Detects mouse clicks and touches on a Game Object, and sends an event to all Flowchart event handlers in the scene. - * The Game Object must have a Collider or Collider2D component attached. - * Use in conjunction with the ObjectClicked Flowchart event handler. - */ + /// + /// Detects mouse clicks and touches on a Game Object, and sends an event to all Flowchart event handlers in the scene. + /// The Game Object must have a Collider or Collider2D component attached. + /// Use in conjunction with the ObjectClicked Flowchart event handler. + /// public class Clickable2D : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler { [Tooltip("Is object clicking enabled")] [SerializeField] protected bool clickEnabled = true; - public bool ClickEnabled { set { clickEnabled = value; } } [Tooltip("Mouse texture to use when hovering mouse over object")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs b/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs index 2ecd3d6e..85e3518c 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs @@ -5,11 +5,12 @@ using UnityEngine; using UnityEngine.Serialization; -using System; -using System.Collections; namespace Fungus { + /// + /// Fades a sprite to a target color over a period of time. + /// [CommandInfo("Sprite", "Fade Sprite", "Fades a sprite to a target color over a period of time.")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs index 60549c29..9cc1abdf 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs @@ -4,11 +4,12 @@ */ using UnityEngine; -using System.Collections; -using System.Collections.Generic; namespace Fungus { + /// + /// Sets a Clickable2D component to be clickable / non-clickable. + /// [CommandInfo("Sprite", "Set Clickable 2D", "Sets a Clickable2D component to be clickable / non-clickable.")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs index afc94a7c..c955e3cd 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs @@ -4,11 +4,13 @@ */ using UnityEngine; -using System.Collections; using System.Collections.Generic; namespace Fungus { + /// + /// Sets all collider (2d or 3d) components on the target objects to be active / inactive. + /// [CommandInfo("Sprite", "Set Collider", "Sets all collider (2d or 3d) components on the target objects to be active / inactive")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs index 3f093b04..4fe9ccc9 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetDraggable2D.cs @@ -4,11 +4,12 @@ */ using UnityEngine; -using System.Collections; -using System.Collections.Generic; namespace Fungus { + /// + /// Sets a Draggable2D component to be draggable / non-draggable. + /// [CommandInfo("Sprite", "Set Draggable 2D", "Sets a Draggable2D component to be draggable / non-draggable.")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs index 05af3412..0710b63e 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetLayerOrder.cs @@ -4,11 +4,12 @@ */ using UnityEngine; -using System.Collections; -using System.Collections.Generic; namespace Fungus { + /// + /// Sets the Renderer sorting layer of every child of a game object. Applies to all Renderers (including mesh, skinned mesh, and sprite). + /// [CommandInfo("Sprite", "Set Sorting Layer", "Sets the Renderer sorting layer of every child of a game object. Applies to all Renderers (including mesh, skinned mesh, and sprite).")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs index 0848a21d..7968d11c 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetMouseCursor.cs @@ -4,10 +4,12 @@ */ using UnityEngine; -using System.Collections; namespace Fungus { + /// + /// Sets the mouse cursor sprite. + /// [CommandInfo("Sprite", "Set Mouse Cursor", "Sets the mouse cursor sprite.")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs b/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs index 071a10e3..b0702ebe 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/SetSpriteOrder.cs @@ -4,11 +4,13 @@ */ using UnityEngine; -using System.Collections; using System.Collections.Generic; namespace Fungus { + /// + /// Controls the render order of sprites by setting the Order In Layer property of a list of sprites. + /// [CommandInfo("Sprite", "Set Sprite Order", "Controls the render order of sprites by setting the Order In Layer property of a list of sprites.")] diff --git a/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs b/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs index 6f2a9184..0ec19789 100644 --- a/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs +++ b/Assets/Fungus/Sprite/Scripts/Commands/ShowSprite.cs @@ -5,11 +5,12 @@ using UnityEngine; using UnityEngine.Serialization; -using System; -using System.Collections; namespace Fungus { + /// + /// Makes a sprite visible / invisible by setting the color alpha. + /// [CommandInfo("Sprite", "Show Sprite", "Makes a sprite visible / invisible by setting the color alpha.")] diff --git a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs index 5eed6e1a..03119322 100644 --- a/Assets/Fungus/Sprite/Scripts/Draggable2D.cs +++ b/Assets/Fungus/Sprite/Scripts/Draggable2D.cs @@ -10,19 +10,17 @@ using UnityEngine.Serialization; namespace Fungus { - - /** - * Detects drag and drop interactions on a Game Object, and sends events to all Flowchart event handlers in the scene. - * The Game Object must have Collider2D & RigidBody components attached. - * The Collider2D must have the Is Trigger property set to true. - * The RigidBody would typically have the Is Kinematic property set to true, unless you want the object to move around using physics. - * Use in conjunction with the Drag Started, Drag Completed, Drag Cancelled, Drag Entered & Drag Exited event handlers. - */ + /// + /// Detects drag and drop interactions on a Game Object, and sends events to all Flowchart event handlers in the scene. + /// The Game Object must have Collider2D & RigidBody components attached. + /// The Collider2D must have the Is Trigger property set to true. + /// The RigidBody would typically have the Is Kinematic property set to true, unless you want the object to move around using physics. + /// Use in conjunction with the Drag Started, Drag Completed, Drag Cancelled, Drag Entered & Drag Exited event handlers. + /// public class Draggable2D : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler, IPointerExitHandler { [Tooltip("Is object dragging enabled")] [SerializeField] protected bool dragEnabled = true; - public bool DragEnabled { get { return dragEnabled; } set { dragEnabled = value; } } [Tooltip("Move object back to its starting position when drag is cancelled")] diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs index 9cac6617..38d61aaa 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCancelled.cs @@ -4,12 +4,12 @@ */ using UnityEngine; -using System; -using System.Collections; -using System.Collections.Generic; namespace Fungus { + /// + /// The block will execute when the player drags an object and releases it without dropping it on a target object. + /// [EventHandlerInfo("Sprite", "Drag Cancelled", "The block will execute when the player drags an object and releases it without dropping it on a target object.")] diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs index 29011142..a4c5d4a1 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragCompleted.cs @@ -4,12 +4,12 @@ */ using UnityEngine; -using System; -using System.Collections; -using System.Collections.Generic; namespace Fungus { + /// + /// The block will execute when the player drags an object and successfully drops it on a target object. + /// [EventHandlerInfo("Sprite", "Drag Completed", "The block will execute when the player drags an object and successfully drops it on a target object.")] diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs index ef15f252..66f6e57d 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragEntered.cs @@ -10,7 +10,9 @@ using System.Collections.Generic; namespace Fungus { - + /// + /// The block will execute when the player is dragging an object which starts touching the target object. + /// [EventHandlerInfo("Sprite", "Drag Entered", "The block will execute when the player is dragging an object which starts touching the target object.")] diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs index aad6653d..80532455 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragExited.cs @@ -10,7 +10,9 @@ using System.Collections.Generic; namespace Fungus { - + /// + /// The block will execute when the player is dragging an object which stops touching the target object. + /// [EventHandlerInfo("Sprite", "Drag Exited", "The block will execute when the player is dragging an object which stops touching the target object.")] diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs index 01f257c7..2dd5fc6b 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/DragStarted.cs @@ -4,12 +4,12 @@ */ using UnityEngine; -using System; -using System.Collections; -using System.Collections.Generic; namespace Fungus { + /// + /// The block will execute when the player starts dragging an object. + /// [EventHandlerInfo("Sprite", "Drag Started", "The block will execute when the player starts dragging an object.")] diff --git a/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs b/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs index 0adf3e89..287add55 100644 --- a/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs +++ b/Assets/Fungus/Sprite/Scripts/EventHandlers/ObjectClicked.cs @@ -4,10 +4,12 @@ */ using UnityEngine; -using System.Collections; namespace Fungus { + /// + /// The block will execute when the user clicks or taps on the clickable object. + /// [EventHandlerInfo("Sprite", "Object Clicked", "The block will execute when the user clicks or taps on the clickable object.")] diff --git a/Assets/Fungus/Sprite/Scripts/Parallax.cs b/Assets/Fungus/Sprite/Scripts/Parallax.cs index 730c299b..bd8c86c8 100644 --- a/Assets/Fungus/Sprite/Scripts/Parallax.cs +++ b/Assets/Fungus/Sprite/Scripts/Parallax.cs @@ -4,33 +4,32 @@ */ using UnityEngine; -using System.Collections; namespace Fungus { - /** - * Attach this component to a sprite object to apply a simple parallax scrolling effect. - * The horizontal and vertical parallax offset is calculated based on the distance from the camera to the position of the background sprite. - * The scale parallax is calculated based on the ratio of the camera size to the size of the background sprite. This gives a 'dolly zoom' effect. - * Accelerometer based parallax is also applied on devices that support it. - */ + /// + /// Attach this component to a sprite object to apply a simple parallax scrolling effect. + /// The horizontal and vertical parallax offset is calculated based on the distance from the camera to the position of the background sprite. + /// The scale parallax is calculated based on the ratio of the camera size to the size of the background sprite. This gives a 'dolly zoom' effect. + /// Accelerometer based parallax is also applied on devices that support it. + /// public class Parallax : MonoBehaviour { - /** - * The background sprite which this sprite is layered on top of. - * The position of this sprite is used to calculate the parallax offset. - */ + /// + /// The background sprite which this sprite is layered on top of. + /// The position of this sprite is used to calculate the parallax offset. + /// [SerializeField] protected SpriteRenderer backgroundSprite; - /** - * Scale factor for calculating the parallax offset. - */ + /// + /// Scale factor for calculating the parallax offset. + /// [SerializeField] protected Vector2 parallaxScale = new Vector2(0.25f, 0f); - /** - * Scale factor for calculating parallax offset based on device accelerometer tilt angle. - * Set this to 0 to disable the accelerometer parallax effect. - */ + /// + /// Scale factor for calculating parallax offset based on device accelerometer tilt angle. + /// Set this to 0 to disable the accelerometer parallax effect. + /// [SerializeField] protected float accelerometerScale = 0.5f; protected Vector3 startPosition; diff --git a/Assets/Fungus/Sprite/Scripts/SpriteFader.cs b/Assets/Fungus/Sprite/Scripts/SpriteFader.cs index 78c6ca1c..61fe0a8c 100644 --- a/Assets/Fungus/Sprite/Scripts/SpriteFader.cs +++ b/Assets/Fungus/Sprite/Scripts/SpriteFader.cs @@ -9,10 +9,10 @@ using System.Collections; namespace Fungus { - /** - * Transitions a sprite from its current color to a target color. - * An offset can be applied to slide the sprite in while changing color. - */ + /// + /// Transitions a sprite from its current color to a target color. + /// An offset can be applied to slide the sprite in while changing color. + /// [RequireComponent (typeof (SpriteRenderer))] public class SpriteFader : MonoBehaviour { @@ -27,9 +27,9 @@ namespace Fungus protected Action onFadeComplete; - /** - * Attaches a SpriteFader component to a sprite object to transition its color over time. - */ + /// + /// Attaches a SpriteFader component to a sprite object to transition its color over time. + /// public static void FadeSprite(SpriteRenderer spriteRenderer, Color targetColor, float duration, Vector2 slideOffset, Action onComplete = null) { if (spriteRenderer == null)