Added MonoHooks + ColliderType + bug fixes

This commit is contained in:
Adam Ramberg 2018-12-12 20:54:17 +01:00
parent c6b240cebb
commit 81209d83b5
35 changed files with 293 additions and 2 deletions

View File

@ -8,7 +8,7 @@ namespace UnityAtoms
{
protected override bool AreEqual(T t1, T t2)
{
return t1.Equals(t2);
return (t1 == null && t2 == null) || (t1 != null && t1.Equals(t2));
}
}
}

View File

@ -18,6 +18,12 @@ namespace UnityAtoms
protected abstract bool AreEqual(T first, T second);
private void OnEnable()
{
if (Changed == null) return;
Changed.Raise(Value);
}
public bool SetValue(T value)
{
if (!AreEqual(this.value, value))

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 19a3e6ed503f94466baa77a854e3ccf6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
using UnityEngine;
namespace UnityAtoms
{
[CreateAssetMenu(menuName = "Unity Atoms/Collider/Event", fileName = "ColliderEvent", order = CreateAssetMenuUtils.Order.EVENT)]
public class ColliderEvent : GameEvent<Collider> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9a0a99be4f0e5466e85ab5428c8b4c22
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
using UnityEngine;
namespace UnityAtoms
{
public abstract class ColliderGameObjectAction : GameAction<Collider, GameObject> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b93e5af67c0004a378b9efbea3b2cae2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
using UnityEngine;
namespace UnityAtoms
{
[CreateAssetMenu(menuName = "Unity Atoms/Collider/Event with GameObject", fileName = "ColliderGameObjectEvent", order = CreateAssetMenuUtils.Order.EVENT_WITH_GO)]
public class ColliderGameObjectEvent : GameEvent<Collider, GameObject> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97acb23837b164301851f57d79bc7731
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
using UnityEngine;
namespace UnityAtoms
{
public class ColliderGameObjectListener : GameEventListener<Collider, GameObject, ColliderGameObjectAction, ColliderGameObjectEvent, UnityColliderGameObjectEvent> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 777a7f3042ff1464d939cac8b14987bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
using System;
using UnityEngine.Events;
using UnityEngine;
namespace UnityAtoms
{
[Serializable]
public class UnityColliderGameObjectEvent : UnityEvent<Collider, GameObject> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 228a51df221d041fb8c3075c0a7c6ff5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,3 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

View File

@ -0,0 +1,21 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace UnityAtoms
{
public static class MonoBehaviourExtensions
{
public static void WaitThenDo(this MonoBehaviour mb, float delay, Action onComplete)
{
mb.StartCoroutine(Routine(delay, onComplete));
}
static IEnumerator Routine(float delay, Action onComplete)
{
yield return new WaitForSeconds(delay);
onComplete();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b9bb3a029ccc8479ab6abba932404203
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,5 @@
using UnityEngine;
using UnityAtoms.Utils;
namespace UnityAtoms
{

View File

@ -7,7 +7,7 @@ namespace UnityAtoms
{
protected override bool AreEqual(GameObject first, GameObject second)
{
return first.GetInstanceID() == second.GetInstanceID();
return (first == null && second == null) || first != null && second != null && first.GetInstanceID() == second.GetInstanceID();
}
}
}

View File

@ -0,0 +1,6 @@
using UnityEngine;
namespace UnityAtoms
{
public abstract class ColliderHook : MonoHook<ColliderEvent, ColliderGameObjectEvent, Collider, GameObjectGameObjectFunction> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6178fc51652f042a4842d227c32e3ec8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,12 @@
using UnityEngine;
namespace UnityAtoms
{
public class OnTriggerEnterHook : ColliderHook
{
private void OnTriggerEnter(Collider other)
{
OnHook(other);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee605babb03dd4a9aa98b28757d00047
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,12 @@
using UnityEngine;
namespace UnityAtoms
{
public class OnTriggerStayHook : ColliderHook
{
private void OnTriggerStay(Collider other)
{
OnHook(other);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1008d086c876a4a198f56bb01beed940
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityAtoms;
public class CreateStringVariableOnAwake : CreateVariableOnAwake<string, StringVariable, StringEvent, StringStringEvent,
StringListener, StringStringListener, StringAction, StringStringAction,
StringVariableAction, StringVariableGameObjectAction, UnityStringEvent, UnityStringStringEvent>
{
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0450d456d77ba41698db58950a60ef38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,4 @@
namespace UnityAtoms
{
public abstract class StringStringAction : GameAction<string, string> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0fad6e346f8f94ec79db7926d050eafa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
using UnityEngine;
namespace UnityAtoms
{
public class StringStringListener : GameEventListener<string, string, StringStringAction, StringStringEvent, UnityStringStringEvent> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 476a9677f1c584b518fefac787fd9387
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,4 @@
namespace UnityAtoms
{
public abstract class StringVariableAction : GameAction<StringVariable> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 886ad0495656944c69e086799d1d111d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
using UnityEngine;
namespace UnityAtoms
{
public abstract class StringVariableGameObjectAction : GameAction<StringVariable, GameObject> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 819aa72b755dd44e4ac7200ec0594b62
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -5,4 +5,7 @@ namespace UnityAtoms
{
[Serializable]
public class UnityStringEvent : UnityEvent<string> { }
[Serializable]
public class UnityStringStringEvent : UnityEvent<string, string> { }
}