Compare commits
No commits in common. "d57961f5f1e3779c8c60694096e81ebc5a99b297" and "bca2922a586077f92e1b256a806a312710ec1063" have entirely different histories.
d57961f5f1
...
bca2922a58
|
@ -1,4 +1,4 @@
|
||||||
# Trigger
|
# Trigger
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
1. [State Module](https://git.syntriax.com/Syntriax/State)
|
1. [ToggleState Module](https://git.syntriax.com/Syntriax/ToggleState)
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Syntriax.Modules.Trigger
|
||||||
private void OnDrawGizmosSelected()
|
private void OnDrawGizmosSelected()
|
||||||
{
|
{
|
||||||
if (UnityEditor.EditorApplication.isPlaying)
|
if (UnityEditor.EditorApplication.isPlaying)
|
||||||
Gizmos.color = previousTriggerCount > 0 && StateEnable.IsEnabled ? Color.green : Color.red;
|
Gizmos.color = previousTriggerCount > 0 ? Color.green : Color.red;
|
||||||
else
|
else
|
||||||
Gizmos.color = TriggerCount > 0 ? Color.green : Color.red;
|
Gizmos.color = TriggerCount > 0 ? Color.green : Color.red;
|
||||||
Gizmos.DrawWireCube(transform.position, transform.lossyScale);
|
Gizmos.DrawWireCube(transform.position, transform.lossyScale);
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Syntriax.Modules.Trigger
|
||||||
private void OnDrawGizmosSelected()
|
private void OnDrawGizmosSelected()
|
||||||
{
|
{
|
||||||
if (UnityEditor.EditorApplication.isPlaying)
|
if (UnityEditor.EditorApplication.isPlaying)
|
||||||
Gizmos.color = previousTriggerCount > 0 && StateEnable.IsEnabled ? Color.green : Color.red;
|
Gizmos.color = previousTriggerCount > 0 ? Color.green : Color.red;
|
||||||
else
|
else
|
||||||
Gizmos.color = TriggerCount > 0 ? Color.green : Color.red;
|
Gizmos.color = TriggerCount > 0 ? Color.green : Color.red;
|
||||||
Gizmos.matrix = transform.localToWorldMatrix;
|
Gizmos.matrix = transform.localToWorldMatrix;
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Syntriax.Modules.Trigger
|
||||||
private void OnDrawGizmosSelected()
|
private void OnDrawGizmosSelected()
|
||||||
{
|
{
|
||||||
if (UnityEditor.EditorApplication.isPlaying)
|
if (UnityEditor.EditorApplication.isPlaying)
|
||||||
Gizmos.color = previousTriggerCount > 0 && StateEnable.IsEnabled ? Color.green : Color.red;
|
Gizmos.color = previousTriggerCount > 0 ? Color.green : Color.red;
|
||||||
else
|
else
|
||||||
Gizmos.color = TriggerCount > 0 ? Color.green : Color.red;
|
Gizmos.color = TriggerCount > 0 ? Color.green : Color.red;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Syntriax.Modules.State;
|
using Syntriax.Modules.ToggleState;
|
||||||
|
|
||||||
namespace Syntriax.Modules.Trigger
|
namespace Syntriax.Modules.Trigger
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace Syntriax.Modules.Trigger
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (!StateEnable.IsEnabledNullChecked())
|
if (!ToggleStateMember.IsToggledNullChecked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IsTrigerred = colliderTrigger.Check();
|
IsTrigerred = colliderTrigger.Check();
|
||||||
|
|
|
@ -45,17 +45,5 @@ namespace Syntriax.Modules.Trigger
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
private State.IStateEnable stateEnable = null;
|
|
||||||
public State.IStateEnable StateEnable
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
stateEnable = stateEnable ?? GetComponent<State.IStateEnable>() ?? gameObject.AddComponent<State.StateEnableMonoBehaviour>();
|
|
||||||
return stateEnable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using Syntriax.Modules.State;
|
using Syntriax.Modules.ToggleState;
|
||||||
|
|
||||||
namespace Syntriax.Modules.Trigger
|
namespace Syntriax.Modules.Trigger
|
||||||
{
|
{
|
||||||
public interface ITrigger
|
public interface ITrigger
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <see cref="IStateEnable"/> to switch on or off
|
/// Member <see cref="IToggleState"/> to switch on or off
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IStateEnable StateEnable { get; }
|
IToggleState ToggleStateMember { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called everytime the IsTrigerred field is changed
|
/// Called everytime the IsTrigerred field is changed
|
||||||
|
|
|
@ -1,43 +1,22 @@
|
||||||
using System;
|
using System;
|
||||||
using Syntriax.Modules.State;
|
using Syntriax.Modules.ToggleState;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Syntriax.Modules.Trigger
|
namespace Syntriax.Modules.Trigger
|
||||||
{
|
{
|
||||||
public class TriggerBase : MonoBehaviour, ITrigger
|
public class TriggerBase : MonoBehaviour, ITrigger
|
||||||
{
|
{
|
||||||
|
public IToggleState ToggleStateMember { get; protected set; } = new ToggleStateMember(true);
|
||||||
|
|
||||||
public Action<bool> OnTriggerStateChanged { get; set; } = null;
|
public Action<bool> OnTriggerStateChanged { get; set; } = null;
|
||||||
|
|
||||||
private IStateEnable stateEnable = null;
|
|
||||||
public IStateEnable StateEnable
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (stateEnable == null)
|
|
||||||
{
|
|
||||||
stateEnable = GetComponent<IStateEnable>() ?? gameObject.AddComponent<StateEnableMonoBehaviour>();
|
|
||||||
stateEnable.OnEnabledChanged += OnEnabledChanged;
|
|
||||||
}
|
|
||||||
return stateEnable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnabledChanged(bool enabled)
|
|
||||||
{
|
|
||||||
if (enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_isTrigerred = false;
|
|
||||||
OnTriggerStateChanged?.Invoke(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _isTrigerred = false;
|
private bool _isTrigerred = false;
|
||||||
public bool IsTrigerred
|
public bool IsTrigerred
|
||||||
{
|
{
|
||||||
get => _isTrigerred;
|
get => _isTrigerred;
|
||||||
protected set
|
protected set
|
||||||
{
|
{
|
||||||
if (value == _isTrigerred || !StateEnable.IsEnabledNullChecked())
|
if (value == _isTrigerred || !ToggleStateMember.IsToggledNullChecked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_isTrigerred = value;
|
_isTrigerred = value;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.syntriax.trigger",
|
"name": "com.syntriax.trigger",
|
||||||
"version": "0.7.0",
|
"version": "0.6.4",
|
||||||
"displayName": "Trigger Module",
|
"displayName": "Trigger Module",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"documentationUrl": "https://git.syntriax.com/Syntriax/Trigger.git",
|
"documentationUrl": "https://git.syntriax.com/Syntriax/Trigger.git",
|
||||||
|
|
Loading…
Reference in New Issue