Browse Source

Change Property, Drag, and Collection 2017 & c#4

master
Steve Halliwell 5 years ago
parent
commit
c5dc1667ac
  1. 8
      Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs
  2. 2
      Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs
  3. 2
      Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs
  4. 2
      Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs
  5. 3
      Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs
  6. 6
      Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs
  7. 6
      Assets/Fungus/Scripts/EventHandlers/DragEntered.cs
  8. 6
      Assets/Fungus/Scripts/EventHandlers/DragExited.cs
  9. 12
      Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs
  10. 2
      Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs
  11. 12
      Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs
  12. 4
      Assets/Tests/PlayMode/FungusPlayModeTest.cs

8
Assets/Fungus/Scripts/Commands/Property/AnimatorProperty.cs

@ -191,9 +191,11 @@ namespace Fungus
case Property.FireEvents:
iob.Value = target.fireEvents;
break;
case Property.KeepAnimatorControllerStateOnDisable:
#if UNITY_2019_2_OR_NEWER
case Property.KeepAnimatorControllerStateOnDisable:
iob.Value = target.keepAnimatorControllerStateOnDisable;
break;
#endif
default:
Debug.Log("Unsupported get or set attempted");
break;
@ -245,10 +247,12 @@ namespace Fungus
case Property.FireEvents:
target.fireEvents = iob.Value;
break;
#if UNITY_2019_2_OR_NEWER
case Property.KeepAnimatorControllerStateOnDisable:
target.keepAnimatorControllerStateOnDisable = iob.Value;
break;
default:
#endif
default:
Debug.Log("Unsupported get or set attempted");
break;
}

2
Assets/Fungus/Scripts/Commands/Property/Collision2DProperty.cs

@ -87,9 +87,11 @@ namespace Fungus
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;

2
Assets/Fungus/Scripts/Commands/Property/QuaternionProperty.cs

@ -66,9 +66,11 @@ namespace Fungus
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;

2
Assets/Fungus/Scripts/Commands/Property/TextureProperty.cs

@ -60,9 +60,11 @@ namespace Fungus
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;

3
Assets/Fungus/Scripts/Editor/CustomVariableDrawerLookup.cs

@ -43,8 +43,9 @@ namespace Fungus.EditorUtils
/// <param name="prop"></param>
public static void DrawCustomOrPropertyField(System.Type type, Rect rect, SerializedProperty prop)
{
System.Action<UnityEngine.Rect, UnityEditor.SerializedProperty> drawer = null;
//delegate actual drawing to the variableInfo
var foundDrawer = typeToDrawer.TryGetValue(type, out System.Action<UnityEngine.Rect, UnityEditor.SerializedProperty> drawer);
var foundDrawer = typeToDrawer.TryGetValue(type, out drawer);
if (foundDrawer)
{
drawer(rect, prop);

6
Assets/Fungus/Scripts/EventHandlers/DragCompleted.cs

@ -16,7 +16,7 @@ namespace Fungus
"Drag Completed",
"The block will execute when the player drags an object and successfully drops it on a target object.")]
[AddComponentMenu("")]
[ExecuteAlways]
[ExecuteInEditMode]
public class DragCompleted : EventHandler, ISerializationCallbackReceiver
{
public class DragCompletedEvent
@ -57,7 +57,7 @@ namespace Fungus
protected virtual void OnEnable()
{
if (Application.IsPlaying(this))
if (Application.isPlaying)
{
eventDispatcher = FungusManager.Instance.EventDispatcher;
@ -74,7 +74,7 @@ namespace Fungus
protected virtual void OnDisable()
{
if (Application.IsPlaying(this))
if (Application.isPlaying)
{
eventDispatcher.RemoveListener<DragCompletedEvent>(OnDragCompletedEvent);
eventDispatcher.RemoveListener<DragEntered.DragEnteredEvent>(OnDragEnteredEvent);

6
Assets/Fungus/Scripts/EventHandlers/DragEntered.cs

@ -16,7 +16,7 @@ namespace Fungus
"Drag Entered",
"The block will execute when the player is dragging an object which starts touching the target object.")]
[AddComponentMenu("")]
[ExecuteAlways]
[ExecuteInEditMode]
public class DragEntered : EventHandler, ISerializationCallbackReceiver
{
public class DragEnteredEvent
@ -53,7 +53,7 @@ namespace Fungus
protected virtual void OnEnable()
{
if (Application.IsPlaying(this))
if (Application.isPlaying)
{
eventDispatcher = FungusManager.Instance.EventDispatcher;
@ -63,7 +63,7 @@ namespace Fungus
protected virtual void OnDisable()
{
if (Application.IsPlaying(this))
if (Application.isPlaying)
{
eventDispatcher.RemoveListener<DragEnteredEvent>(OnDragEnteredEvent);

6
Assets/Fungus/Scripts/EventHandlers/DragExited.cs

@ -16,7 +16,7 @@ namespace Fungus
"Drag Exited",
"The block will execute when the player is dragging an object which stops touching the target object.")]
[AddComponentMenu("")]
[ExecuteAlways]
[ExecuteInEditMode]
public class DragExited : EventHandler, ISerializationCallbackReceiver
{
public class DragExitedEvent
@ -53,7 +53,7 @@ namespace Fungus
protected virtual void OnEnable()
{
if (Application.IsPlaying(this))
if (Application.isPlaying)
{
eventDispatcher = FungusManager.Instance.EventDispatcher;
@ -63,7 +63,7 @@ namespace Fungus
protected virtual void OnDisable()
{
if (Application.IsPlaying(this))
if (Application.isPlaying)
{
eventDispatcher.RemoveListener<DragExitedEvent>(OnDragEnteredEvent);

12
Assets/Fungus/Scripts/VariableTypes/Collection/Collection.cs

@ -17,13 +17,13 @@ namespace Fungus
{
public abstract int Capacity { get; set; }
public abstract int Count { get; }
public bool IsFixedSize => false;
public bool IsReadOnly => false;
public bool IsSynchronized => false;
public object SyncRoot => null;
public string Name => name;
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 => Get(index); set => Set(index, value); }
public object this[int index] { get { return Get(index); } set { Set(index, value); } }
public abstract int Add(object o);

2
Assets/Fungus/Scripts/VariableTypes/Collection/GenericCollection.cs

@ -38,7 +38,7 @@ namespace Fungus
}
}
public override int Count => collection.Count;
public override int Count { get { return collection.Count; } }
public override int Add(object o)
{

12
Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs

@ -33,10 +33,22 @@ namespace Fungus
Value -= value;
break;
case SetOperator.Multiply:
#if UNITY_2019_2_OR_NEWER
Value *= value;
#else
var tmpM = Value;
tmpM.Scale(value);
Value = tmpM;
#endif
break;
case SetOperator.Divide:
#if UNITY_2019_2_OR_NEWER
Value /= value;
#else
var tmpD = Value;
tmpD.Scale(new Vector2(1.0f / value.x, 1.0f / value.y));
Value = tmpD;
#endif
break;
default:
base.Apply(setOperator, value);

4
Assets/Tests/PlayMode/FungusPlayModeTest.cs

@ -1,6 +1,7 @@
// This code is part of the Fungus library (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_2019_2_OR_NEWER
using NUnit.Framework;
using System.Collections;
using UnityEngine.TestTools;
@ -28,4 +29,5 @@ namespace Fungus.Tests
yield return EditorUtils.TestUtils.RunPrefabFlowchartTests("VarSetTest", true);
}
}
}
}
#endif
Loading…
Cancel
Save