Browse Source

added dragableobject list to two commands

master
vjs22334 5 years ago
parent
commit
bb08b4594c
  1. 29
      Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs
  2. 30
      Assets/Fungus/Scripts/EventHandlers/DragStarted.cs

29
Assets/Fungus/Scripts/EventHandlers/DragCancelled.cs

@ -2,6 +2,8 @@
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using System.Collections.Generic;
namespace Fungus
{
@ -24,7 +26,7 @@ namespace Fungus
}
[Tooltip("Draggable object to listen for drag events on")]
[SerializeField] protected Draggable2D draggableObject;
[SerializeField] protected List<Draggable2D> draggableObjects;
protected EventDispatcher eventDispatcher;
@ -51,20 +53,35 @@ namespace Fungus
public virtual void OnDragCancelled(Draggable2D draggableObject)
{
if (draggableObject == this.draggableObject)
for (int i = 0; i < this.draggableObjects.Count; i++)
{
ExecuteBlock();
if (draggableObject == this.draggableObjects[i])
{
ExecuteBlock();
}
}
}
public override string GetSummary()
{
if (draggableObject != null)
string summary = "Dragable: ";
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

30
Assets/Fungus/Scripts/EventHandlers/DragStarted.cs

@ -2,6 +2,7 @@
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using System.Collections.Generic;
namespace Fungus
{
@ -23,10 +24,11 @@ namespace Fungus
}
}
[SerializeField] protected Draggable2D draggableObject;
[SerializeField] protected List<Draggable2D> draggableObjects;
protected EventDispatcher eventDispatcher;
protected virtual void OnEnable()
{
eventDispatcher = FungusManager.Instance.EventDispatcher;
@ -53,20 +55,36 @@ namespace Fungus
/// </summary>
public virtual void OnDragStarted(Draggable2D draggableObject)
{
if (draggableObject == this.draggableObject)
for (int i = 0; i < this.draggableObjects.Count; i++)
{
ExecuteBlock();
if (draggableObject == this.draggableObjects[i])
{
ExecuteBlock();
}
}
}
public override string GetSummary()
{
if (draggableObject != null)
string summary = "Dragable: ";
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

Loading…
Cancel
Save