Chris Gregan
7 years ago
committed by
GitHub
48 changed files with 5645 additions and 0 deletions
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f60f5e8a5f80d644eb2f33cdbf2d7bd7 |
||||
folderAsset: yes |
||||
timeCreated: 1501747644 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,50 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when the desired OnAnimator* message for the monobehaviour is received. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Animator", |
||||
"The block will execute when the desired OnAnimator* message for the monobehaviour is received.")] |
||||
[AddComponentMenu("")] |
||||
public class AnimatorState : EventHandler |
||||
{ |
||||
|
||||
[System.Flags] |
||||
public enum AnimatorMessageFlags |
||||
{ |
||||
OnAnimatorIK = 1 << 0, |
||||
OnAnimatorMove = 1 << 1, |
||||
} |
||||
|
||||
[Tooltip("Which of the OnAnimator messages to trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected AnimatorMessageFlags FireOn = AnimatorMessageFlags.OnAnimatorMove; |
||||
|
||||
[Tooltip("IK layer to trigger on. Negative is all.")] |
||||
[SerializeField] |
||||
protected int IKLayer = 1; |
||||
|
||||
private void OnAnimatorIK(int layer) |
||||
{ |
||||
if ((FireOn & AnimatorMessageFlags.OnAnimatorIK) != 0 && |
||||
(IKLayer == layer || IKLayer < 0) ) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnAnimatorMove() |
||||
{ |
||||
if ((FireOn & AnimatorMessageFlags.OnAnimatorMove) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ed7ff13fa21e8d94fbdc0aedae2c95c9 |
||||
timeCreated: 1500890783 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,64 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when the desired OnApplication message for the monobehaviour is received. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Application", |
||||
"The block will execute when the desired OnApplication message for the monobehaviour is received.")] |
||||
[AddComponentMenu("")] |
||||
public class ApplicationState : EventHandler |
||||
{ |
||||
|
||||
[System.Flags] |
||||
public enum ApplicationMessageFlags |
||||
{ |
||||
OnApplicationGetFocus = 1 << 0, |
||||
OnApplicationLoseFocus = 1 << 1, |
||||
OnApplicationPause = 1 << 2, |
||||
OnApplicationResume = 1 << 3, |
||||
OnApplicationQuit = 1 << 4, |
||||
} |
||||
|
||||
[Tooltip("Which of the Application messages to trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected ApplicationMessageFlags FireOn = ApplicationMessageFlags.OnApplicationQuit; |
||||
|
||||
private void OnApplicationFocus(bool focus) |
||||
{ |
||||
if ( |
||||
(focus && ((FireOn & ApplicationMessageFlags.OnApplicationGetFocus) != 0)) |
||||
|| |
||||
(!focus && ((FireOn & ApplicationMessageFlags.OnApplicationLoseFocus) != 0)) |
||||
) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnApplicationPause(bool pause) |
||||
{ |
||||
if ( |
||||
(pause && (( FireOn & ApplicationMessageFlags.OnApplicationPause) != 0)) |
||||
|| |
||||
(!pause && ((FireOn & ApplicationMessageFlags.OnApplicationResume) != 0)) |
||||
) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnApplicationQuit() |
||||
{ |
||||
if((FireOn & ApplicationMessageFlags.OnApplicationQuit) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: a4abc7ea9602fa041b47cd2c64fd5a7c |
||||
timeCreated: 1500770156 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,34 @@
|
||||
using UnityEngine; |
||||
using UnityEngine.UI; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
|
||||
/// <summary> |
||||
/// Base class for all of our physics event handlers |
||||
/// </summary> |
||||
[AddComponentMenu("")] |
||||
public abstract class BasePhysicsEventHandler : TagFilteredEventHandler |
||||
{ |
||||
[System.Flags] |
||||
public enum PhysicsMessageType |
||||
{ |
||||
Enter = 1 << 0, |
||||
Stay = 1 << 1, |
||||
Exit = 1 << 2, |
||||
} |
||||
|
||||
[Tooltip("Which of the 3d physics messages to we trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected PhysicsMessageType FireOn = PhysicsMessageType.Enter; |
||||
|
||||
protected void ProcessCollider(PhysicsMessageType from, string tagOnOther) |
||||
{ |
||||
if ((from & FireOn) != 0) |
||||
{ |
||||
ProcessTagFilter(tagOnOther); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 21884184fa1f9934f83fc4c966811e46 |
||||
timeCreated: 1500723476 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,22 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when tag filtered OnControllerColliderHit is received. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"CharacterCollider", |
||||
"The block will execute when tag filtered OnCharacterColliderHit is received")] |
||||
[AddComponentMenu("")] |
||||
public class CharacterControllerCollide : TagFilteredEventHandler |
||||
{ |
||||
|
||||
private void OnControllerColliderHit(ControllerColliderHit hit) |
||||
{ |
||||
ProcessTagFilter(hit.gameObject.tag); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d70204a08ba195943a1e21ec64d17bd5 |
||||
timeCreated: 1500890236 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,31 @@
|
||||
using UnityEngine; |
||||
using UnityEngine.UI; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
|
||||
/// <summary> |
||||
/// The block will execute when a 3d physics collision matching some basic conditions is met |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Collision", |
||||
"The block will execute when a 3d physics collision matching some basic conditions is met.")] |
||||
[AddComponentMenu("")] |
||||
public class Collision : BasePhysicsEventHandler |
||||
{ |
||||
private void OnCollisionEnter(UnityEngine.Collision collision) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Enter, collision.collider.tag); |
||||
} |
||||
|
||||
private void OnCollisionStay(UnityEngine.Collision collision) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Stay, collision.collider.tag); |
||||
} |
||||
|
||||
private void OnCollisionExit(UnityEngine.Collision collision) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Exit, collision.collider.tag); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d3b4d2ce0fcd12448ab6b4492be6ca77 |
||||
timeCreated: 1500107193 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,30 @@
|
||||
using UnityEngine; |
||||
using UnityEngine.UI; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when a 2d physics collision matching some basic conditions is met |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Collision2D", |
||||
"The block will execute when a 2d physics collision matching some basic conditions is met.")] |
||||
[AddComponentMenu("")] |
||||
public class Collision2D : BasePhysicsEventHandler |
||||
{ |
||||
private void OnCollisionEnter2D(UnityEngine.Collision2D collision) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Enter, collision.collider.tag); |
||||
} |
||||
|
||||
private void OnCollisionStay2D(UnityEngine.Collision2D collision) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Stay, collision.collider.tag); |
||||
} |
||||
|
||||
private void OnCollisionExit2D(UnityEngine.Collision2D collision) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Exit, collision.collider.tag); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: c23faba06619da442a984c0c71a87df4 |
||||
timeCreated: 1500112113 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,77 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when the desired OnMouse* message for the monobehaviour is received |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Mouse", |
||||
"The block will execute when the desired OnMouse* message for the monobehaviour is received")] |
||||
[AddComponentMenu("")] |
||||
public class Mouse : EventHandler |
||||
{ |
||||
|
||||
[System.Flags] |
||||
public enum MouseMessageFlags |
||||
{ |
||||
OnMouseDown = 1 << 0, |
||||
OnMouseDrag = 1 << 1, |
||||
OnMouseEnter = 1 << 2, |
||||
OnMouseExit = 1 << 3, |
||||
OnMouseOver = 1 << 4, |
||||
OnMouseUp = 1 << 5, |
||||
OnMouseUpAsButton = 1 << 6, |
||||
} |
||||
|
||||
[Tooltip("Which of the Mouse messages to trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected MouseMessageFlags FireOn = MouseMessageFlags.OnMouseUpAsButton; |
||||
|
||||
private void OnMouseDown() |
||||
{ |
||||
HandleTriggering(MouseMessageFlags.OnMouseDown); |
||||
} |
||||
|
||||
private void OnMouseDrag() |
||||
{ |
||||
HandleTriggering(MouseMessageFlags.OnMouseDrag); |
||||
} |
||||
|
||||
private void OnMouseEnter() |
||||
{ |
||||
HandleTriggering(MouseMessageFlags.OnMouseEnter); |
||||
} |
||||
|
||||
private void OnMouseExit() |
||||
{ |
||||
HandleTriggering(MouseMessageFlags.OnMouseExit); |
||||
} |
||||
|
||||
private void OnMouseOver() |
||||
{ |
||||
HandleTriggering(MouseMessageFlags.OnMouseOver); |
||||
} |
||||
|
||||
private void OnMouseUp() |
||||
{ |
||||
HandleTriggering(MouseMessageFlags.OnMouseUp); |
||||
} |
||||
|
||||
private void OnMouseUpAsButton() |
||||
{ |
||||
HandleTriggering(MouseMessageFlags.OnMouseUpAsButton); |
||||
} |
||||
|
||||
private void HandleTriggering(MouseMessageFlags from) |
||||
{ |
||||
if((from & FireOn) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: dfcefb900be84c948bbe013dc8ffefb5 |
||||
timeCreated: 1500723160 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,46 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when the desired OnParticle message for the monobehaviour is received. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Particle", |
||||
"The block will execute when the desired OnParticle message for the monobehaviour is received.")] |
||||
[AddComponentMenu("")] |
||||
public class Particle : TagFilteredEventHandler |
||||
{ |
||||
|
||||
[System.Flags] |
||||
public enum ParticleMessageFlags |
||||
{ |
||||
OnParticleCollision = 1 << 0, |
||||
OnParticleTrigger = 1 << 1, |
||||
|
||||
} |
||||
|
||||
[Tooltip("Which of the Rendering messages to trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected ParticleMessageFlags FireOn = ParticleMessageFlags.OnParticleCollision; |
||||
|
||||
private void OnParticleCollision(GameObject other) |
||||
{ |
||||
if ((FireOn & ParticleMessageFlags.OnParticleCollision) != 0) |
||||
{ |
||||
ProcessTagFilter(other.tag); |
||||
} |
||||
} |
||||
|
||||
private void OnParticleTrigger() |
||||
{ |
||||
if ((FireOn & ParticleMessageFlags.OnParticleTrigger) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: e33f54c502fbc974ab0e725f4ce0ec17 |
||||
timeCreated: 1500889191 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,96 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when the desired Rendering related message for the monobehaviour is received. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Render", |
||||
"The block will execute when the desired Rendering related message for the monobehaviour is received.")] |
||||
[AddComponentMenu("")] |
||||
public class Render : EventHandler |
||||
{ |
||||
|
||||
[System.Flags] |
||||
public enum RenderMessageFlags |
||||
{ |
||||
OnPostRender = 1 << 0, |
||||
OnPreCull = 1 << 1, |
||||
OnPreRender = 1 << 2, |
||||
//OnRenderImage = 1 << 3, |
||||
OnRenderObject = 1 << 4, |
||||
OnWillRenderObject = 1 << 5, |
||||
OnBecameInvisible = 1 << 6, |
||||
OnBecameVisible = 1 << 7, |
||||
} |
||||
|
||||
[Tooltip("Which of the Rendering messages to trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected RenderMessageFlags FireOn = RenderMessageFlags.OnWillRenderObject; |
||||
|
||||
private void OnPostRender() |
||||
{ |
||||
if((FireOn & RenderMessageFlags.OnPostRender) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnPreCull() |
||||
{ |
||||
if ((FireOn & RenderMessageFlags.OnPreCull) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnPreRender() |
||||
{ |
||||
if ((FireOn & RenderMessageFlags.OnPreRender) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnRenderImage(RenderTexture source, RenderTexture destination) |
||||
{ |
||||
//TODO |
||||
} |
||||
|
||||
private void OnRenderObject() |
||||
{ |
||||
if ((FireOn & RenderMessageFlags.OnRenderObject) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnWillRenderObject() |
||||
{ |
||||
if ((FireOn & RenderMessageFlags.OnWillRenderObject) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnBecameInvisible() |
||||
{ |
||||
if ((FireOn & RenderMessageFlags.OnBecameInvisible) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnBecameVisible() |
||||
{ |
||||
if ((FireOn & RenderMessageFlags.OnBecameVisible) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f398676485e82e34398f24b0f502aace |
||||
timeCreated: 1500809136 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,31 @@
|
||||
using UnityEngine; |
||||
using UnityEngine.UI; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Base class for all of our physics event handlers |
||||
/// </summary> |
||||
[AddComponentMenu("")] |
||||
public abstract class TagFilteredEventHandler : EventHandler |
||||
{ |
||||
[Tooltip("Only fire the event if one of the tags match. Empty means any will fire.")] |
||||
[SerializeField] |
||||
protected string[] tagFilter; |
||||
|
||||
protected void ProcessTagFilter(string tagOnOther) |
||||
{ |
||||
if (tagFilter.Length == 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
else |
||||
{ |
||||
if (System.Array.IndexOf(tagFilter, tagOnOther) != -1) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: e092863ceee1e37438e7c5238299fcc3 |
||||
timeCreated: 1500890048 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,45 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when the desired OnTransform related message for the monobehaviour is received. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Transform", |
||||
"The block will execute when the desired OnTransform related message for the monobehaviour is received.")] |
||||
[AddComponentMenu("")] |
||||
public class TransformChanged : EventHandler |
||||
{ |
||||
|
||||
[System.Flags] |
||||
public enum TransformMessageFlags |
||||
{ |
||||
OnTransformChildrenChanged = 1 << 0, |
||||
OnTransformParentChanged = 1 << 1, |
||||
} |
||||
|
||||
[Tooltip("Which of the OnTransformChanged messages to trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected TransformMessageFlags FireOn = TransformMessageFlags.OnTransformChildrenChanged | TransformMessageFlags.OnTransformParentChanged; |
||||
|
||||
private void OnTransformChildrenChanged() |
||||
{ |
||||
if ((FireOn & TransformMessageFlags.OnTransformChildrenChanged) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void OnTransformParentChanged() |
||||
{ |
||||
if ((FireOn & TransformMessageFlags.OnTransformParentChanged) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 3e7a2be9924b35c4eb6853121a323026 |
||||
timeCreated: 1500883183 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,30 @@
|
||||
using UnityEngine; |
||||
using UnityEngine.UI; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when a 3d physics trigger matching some basic conditions is met. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Trigger", |
||||
"The block will execute when a 3d physics trigger matching some basic conditions is met.")] |
||||
[AddComponentMenu("")] |
||||
public class Trigger : BasePhysicsEventHandler |
||||
{ |
||||
private void OnTriggerEnter(Collider col) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Enter, col.tag); |
||||
} |
||||
|
||||
private void OnTriggerStay(Collider col) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Stay, col.tag); |
||||
} |
||||
|
||||
private void OnTriggerExit(Collider col) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Exit, col.tag); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: a98f5f89242e80d42865cdf1912beda3 |
||||
timeCreated: 1500111643 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,31 @@
|
||||
using UnityEngine; |
||||
using UnityEngine.UI; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute when a 2d physics trigger matching some basic conditions is met. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Trigger2D", |
||||
"The block will execute when a 2d physics trigger matching some basic conditions is met.")] |
||||
[AddComponentMenu("")] |
||||
public class Trigger2D : BasePhysicsEventHandler |
||||
{ |
||||
private void OnTriggerEnter2D(Collider2D col) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Enter, col.tag); |
||||
} |
||||
|
||||
private void OnTriggerStay2D(Collider2D col) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Stay, col.tag); |
||||
} |
||||
|
||||
private void OnTriggerExit2D(Collider2D col) |
||||
{ |
||||
ProcessCollider(PhysicsMessageType.Exit, col.tag); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 78c1a9f24ac376a47838385391f83acc |
||||
timeCreated: 1500112113 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,54 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// The block will execute every chosen Update, or FixedUpdate or LateUpdate. |
||||
/// </summary> |
||||
[EventHandlerInfo("MonoBehaviour", |
||||
"Update", |
||||
"The block will execute every chosen Update, or FixedUpdate or LateUpdate.")] |
||||
[AddComponentMenu("")] |
||||
public class UpdateTick : EventHandler |
||||
{ |
||||
|
||||
[System.Flags] |
||||
public enum UpdateMessageFlags |
||||
{ |
||||
Update = 1 << 0, |
||||
FixedUpdate = 1 << 1, |
||||
LateUpdate = 1 << 2, |
||||
} |
||||
|
||||
[Tooltip("Which of the Update messages to trigger on.")] |
||||
[SerializeField] |
||||
[EnumFlag] |
||||
protected UpdateMessageFlags FireOn = UpdateMessageFlags.Update; |
||||
|
||||
private void Update() |
||||
{ |
||||
if((FireOn & UpdateMessageFlags.Update) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void FixedUpdate() |
||||
{ |
||||
if ((FireOn & UpdateMessageFlags.FixedUpdate) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
|
||||
private void LateUpdate() |
||||
{ |
||||
if ((FireOn & UpdateMessageFlags.LateUpdate) != 0) |
||||
{ |
||||
ExecuteBlock(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d2fbef54b0b0adb41ab9b447a8f3cbdb |
||||
timeCreated: 1500790366 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,48 @@
|
||||
//from http://wiki.unity3d.com/index.php/EnumFlagPropertyDrawer |
||||
|
||||
//placed in fungus namespace to avoid collisions with your own |
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using UnityEditor; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
[CustomPropertyDrawer(typeof(EnumFlagAttribute))] |
||||
public class EnumFlagDrawer : PropertyDrawer |
||||
{ |
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) |
||||
{ |
||||
EnumFlagAttribute flagSettings = (EnumFlagAttribute)attribute; |
||||
Enum targetEnum = GetBaseProperty<Enum>(property); |
||||
|
||||
string propName = flagSettings.enumName; |
||||
if (string.IsNullOrEmpty(propName)) |
||||
propName = property.name; |
||||
|
||||
EditorGUI.BeginProperty(position, label, property); |
||||
Enum enumNew = EditorGUI.EnumMaskField(position, propName, targetEnum); |
||||
property.intValue = (int)Convert.ChangeType(enumNew, targetEnum.GetType()); |
||||
EditorGUI.EndProperty(); |
||||
} |
||||
|
||||
static T GetBaseProperty<T>(SerializedProperty prop) |
||||
{ |
||||
// Separate the steps it takes to get to this property |
||||
string[] separatedPaths = prop.propertyPath.Split('.'); |
||||
|
||||
// Go down to the root of this serialized property |
||||
System.Object reflectionTarget = prop.serializedObject.targetObject as object; |
||||
// Walk down the path to get the target object |
||||
foreach (var path in separatedPaths) |
||||
{ |
||||
var t = reflectionTarget.GetType(); |
||||
//with support for private types via https://gist.github.com/ChemiKhazi/11395776 |
||||
FieldInfo fieldInfo = t.GetField(path, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); |
||||
reflectionTarget = fieldInfo.GetValue(reflectionTarget); |
||||
} |
||||
return (T)reflectionTarget; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 7409906689b3fb843b5997940f2dd461 |
||||
timeCreated: 1501747644 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,20 @@
|
||||
//from http://wiki.unity3d.com/index.php/EnumFlagPropertyDrawer |
||||
|
||||
//placed in fungus namespace to avoid collisions with your own |
||||
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
public class EnumFlagAttribute : PropertyAttribute |
||||
{ |
||||
public string enumName; |
||||
|
||||
public EnumFlagAttribute() { } |
||||
|
||||
public EnumFlagAttribute(string name) |
||||
{ |
||||
enumName = name; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 57825a740e17fa646a703ee1e6161520 |
||||
timeCreated: 1501747644 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: bb3a484d61ab6254381a068eaf6dddfe |
||||
folderAsset: yes |
||||
timeCreated: 1501747644 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,75 @@
|
||||
%YAML 1.1 |
||||
%TAG !u! tag:unity3d.com,2011: |
||||
--- !u!21 &2100000 |
||||
Material: |
||||
serializedVersion: 6 |
||||
m_ObjectHideFlags: 0 |
||||
m_PrefabParentObject: {fileID: 0} |
||||
m_PrefabInternal: {fileID: 0} |
||||
m_Name: Blank |
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} |
||||
m_ShaderKeywords: |
||||
m_LightmapFlags: 4 |
||||
m_EnableInstancingVariants: 0 |
||||
m_CustomRenderQueue: -1 |
||||
stringTagMap: {} |
||||
disabledShaderPasses: [] |
||||
m_SavedProperties: |
||||
serializedVersion: 3 |
||||
m_TexEnvs: |
||||
- _BumpMap: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _DetailAlbedoMap: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _DetailMask: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _DetailNormalMap: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _EmissionMap: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _MainTex: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _MetallicGlossMap: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _OcclusionMap: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
- _ParallaxMap: |
||||
m_Texture: {fileID: 0} |
||||
m_Scale: {x: 1, y: 1} |
||||
m_Offset: {x: 0, y: 0} |
||||
m_Floats: |
||||
- _BumpScale: 1 |
||||
- _Cutoff: 0.5 |
||||
- _DetailNormalMapScale: 1 |
||||
- _DstBlend: 0 |
||||
- _GlossMapScale: 1 |
||||
- _Glossiness: 0.5 |
||||
- _GlossyReflections: 1 |
||||
- _Metallic: 0 |
||||
- _Mode: 0 |
||||
- _OcclusionStrength: 1 |
||||
- _Parallax: 0.02 |
||||
- _SmoothnessTextureChannel: 0 |
||||
- _SpecularHighlights: 1 |
||||
- _SrcBlend: 1 |
||||
- _UVSec: 0 |
||||
- _ZWrite: 1 |
||||
m_Colors: |
||||
- _Color: {r: 0.35349885, g: 0.2793103, b: 1, a: 1} |
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 44484ce9e8d1f90479abca9c377b9a1c |
||||
timeCreated: 1501234351 |
||||
licenseType: Free |
||||
NativeFormatImporter: |
||||
mainObjectFileID: 2100000 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,13 @@
|
||||
%YAML 1.1 |
||||
%TAG !u! tag:unity3d.com,2011: |
||||
--- !u!134 &13400000 |
||||
PhysicMaterial: |
||||
m_ObjectHideFlags: 0 |
||||
m_PrefabParentObject: {fileID: 0} |
||||
m_PrefabInternal: {fileID: 0} |
||||
m_Name: Bouncy |
||||
dynamicFriction: 0.6 |
||||
staticFriction: 0.6 |
||||
bounciness: 0.4 |
||||
frictionCombine: 0 |
||||
bounceCombine: 0 |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 2150f8a2365e2df43be3dbad67a48487 |
||||
timeCreated: 1500107071 |
||||
licenseType: Free |
||||
NativeFormatImporter: |
||||
mainObjectFileID: 13400000 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,10 @@
|
||||
%YAML 1.1 |
||||
%TAG !u! tag:unity3d.com,2011: |
||||
--- !u!62 &6200000 |
||||
PhysicsMaterial2D: |
||||
m_ObjectHideFlags: 0 |
||||
m_PrefabParentObject: {fileID: 0} |
||||
m_PrefabInternal: {fileID: 0} |
||||
m_Name: Bouncy |
||||
friction: 0.4 |
||||
bounciness: 0.6 |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ee8f7489dfdc8f04ab459adf2cdf2051 |
||||
timeCreated: 1500106982 |
||||
licenseType: Free |
||||
NativeFormatImporter: |
||||
mainObjectFileID: 6200000 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2 |
||||
guid: c05250d33e43ca04788384771b988143 |
||||
timeCreated: 1500111340 |
||||
licenseType: Free |
||||
AudioImporter: |
||||
serializedVersion: 6 |
||||
defaultSettings: |
||||
loadType: 0 |
||||
sampleRateSetting: 0 |
||||
sampleRateOverride: 44100 |
||||
compressionFormat: 1 |
||||
quality: 1 |
||||
conversionMode: 0 |
||||
platformSettingOverrides: {} |
||||
forceToMono: 0 |
||||
normalize: 1 |
||||
preloadAudioData: 1 |
||||
loadInBackground: 0 |
||||
3D: 1 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 85e52f4d86ab48841a4622d873337298 |
||||
timeCreated: 1500106840 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 93d0684591bc1c14dbad2b7dd9f454bb |
||||
timeCreated: 1500106840 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,24 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
namespace Examples |
||||
{ |
||||
public class SpriteColorChangeFromFungusMouseEvent : MonoBehaviour |
||||
{ |
||||
private SpriteRenderer rend; |
||||
|
||||
private void Start() |
||||
{ |
||||
rend = GetComponent<SpriteRenderer>(); |
||||
} |
||||
|
||||
void OnMouseEventFromFungus() |
||||
{ |
||||
rend.color = Color.HSVToRGB(Random.value, Random.Range(0.7f, 0.9f), Random.Range(0.7f, 0.9f)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 11b68bc7e4989f44d98199af76edd420 |
||||
timeCreated: 1501755452 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Loading…
Reference in new issue