0.2.0
This commit is contained in:
commit
4bb4e71ef7
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 488baa4b12357c44d83fcdba794ce57c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Syntriax.Modules.State
|
||||||
|
{
|
||||||
|
public interface IStateEnable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Called everytime the <see cref="IsEnabled"/>> field is changed
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The new value of <see cref="IsEnabled"/>></value>
|
||||||
|
Action<bool> OnEnabledChanged { get; set; }
|
||||||
|
|
||||||
|
bool IsEnabled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5be36869d5a2d95418a7db5213b80ccf
|
guid: 9017443f63486e0438e09eeb335eb8bc
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace Syntriax.Modules.State
|
||||||
|
{
|
||||||
|
public static class IStateEnableExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the provided parameter <see cref="IStateEnable"/> is enabled, if the parameter is null returns the nullValue parameter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="StateEnable"><see cref="IStateEnable"/> to be checked if enabled or not</param>
|
||||||
|
/// <param name="nullValue">The value that will be returned if <see cref="IEnabledState"/> is null. Default value: true</param>
|
||||||
|
/// <returns><see cref="IStateEnable"/>'s toggle value, or if null return nullValue parameter</returns>
|
||||||
|
public static bool IsEnabledNullChecked(this IStateEnable stateEnable, bool nullValue = true)
|
||||||
|
=> stateEnable == null ? nullValue : stateEnable.IsEnabled;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 174255e0fce0b3a4e8b5e34afa96ffd3
|
guid: ff97669ed76e39540b7aa38be50a5e1a
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Syntriax.Modules.State
|
||||||
|
{
|
||||||
|
public class StateEnableMember : IStateEnable
|
||||||
|
{
|
||||||
|
private bool _isEnabled = true;
|
||||||
|
|
||||||
|
public StateEnableMember() { }
|
||||||
|
public StateEnableMember(bool isEnabled) => IsEnabled = isEnabled;
|
||||||
|
|
||||||
|
public bool IsEnabled
|
||||||
|
{
|
||||||
|
get => _isEnabled;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == _isEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isEnabled = value;
|
||||||
|
OnEnabledChanged?.Invoke(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action<bool> OnEnabledChanged { get; set; } = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: d603bc1aca0fb74498aaa2270e82135b
|
guid: 39e2c42e15ad5304db28ad23b5cb666f
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Syntriax.Modules.State
|
||||||
|
{
|
||||||
|
public class StateEnableMonoBehaviour : MonoBehaviour, IStateEnable
|
||||||
|
{
|
||||||
|
private bool _isEnabled = true;
|
||||||
|
public bool IsEnabled
|
||||||
|
{
|
||||||
|
get => _isEnabled;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == _isEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isEnabled = value;
|
||||||
|
OnEnabledChanged?.Invoke(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action<bool> OnEnabledChanged { get; set; } = null;
|
||||||
|
|
||||||
|
protected void Awake()
|
||||||
|
=> OnEnabledChanged += (state) => enabled = state;
|
||||||
|
|
||||||
|
protected void OnEnable() => IsEnabled = true;
|
||||||
|
protected void OnDisable() => IsEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: d321123fb56053e49b20da45bfda3a65
|
guid: d72fab208f04d2f4983894530293b606
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -1,15 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Syntriax.Modules.ToggleState
|
|
||||||
{
|
|
||||||
public interface IToggleState
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Called everytime the IsToggled field is changed
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The new value of IsToggled</value>
|
|
||||||
Action<bool> OnToggleStateChanged { get; set; }
|
|
||||||
|
|
||||||
bool IsToggled { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
namespace Syntriax.Modules.ToggleState
|
|
||||||
{
|
|
||||||
public static class IToggleStateExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Checks if the provided parameter IToggleState is toggled, if the parameter is null returns the nullValue parameter
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="toggleState">IToggleState to be checked if toggled or not</param>
|
|
||||||
/// <param name="nullValue">The value that will be returned if toggleState is null. Default value: true</param>
|
|
||||||
/// <returns>IToggleState's toggle value, or if null return nullValue parameter</returns>
|
|
||||||
public static bool IsToggledNullChecked(this IToggleState toggleState, bool nullValue = true)
|
|
||||||
=> toggleState == null ? nullValue : toggleState.IsToggled;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"name": "Syntriax.Modules.State"
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Syntriax.Modules.ToggleState"
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Syntriax.Modules.ToggleState
|
|
||||||
{
|
|
||||||
public class ToggleStateMember : IToggleState
|
|
||||||
{
|
|
||||||
private bool _isToggled = true;
|
|
||||||
|
|
||||||
public ToggleStateMember() { }
|
|
||||||
public ToggleStateMember(bool isToggled) => IsToggled = isToggled;
|
|
||||||
|
|
||||||
public bool IsToggled
|
|
||||||
{
|
|
||||||
get => _isToggled;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == _isToggled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_isToggled = value;
|
|
||||||
OnToggleStateChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action<bool> OnToggleStateChanged { get; set; } = null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Syntriax.Modules.ToggleState
|
|
||||||
{
|
|
||||||
public class ToggleStateMonoBehaviour : MonoBehaviour, IToggleState
|
|
||||||
{
|
|
||||||
private bool _isToggled = true;
|
|
||||||
public bool IsToggled
|
|
||||||
{
|
|
||||||
get => _isToggled;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == _isToggled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_isToggled = value;
|
|
||||||
OnToggleStateChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action<bool> OnToggleStateChanged { get; set; } = null;
|
|
||||||
|
|
||||||
protected void Awake()
|
|
||||||
=> OnToggleStateChanged += (state) => enabled = state;
|
|
||||||
|
|
||||||
protected void OnEnable() => IsToggled = true;
|
|
||||||
protected void OnDisable() => IsToggled = false;
|
|
||||||
}
|
|
||||||
}
|
|
10
package.json
10
package.json
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "com.syntriax.toggle-state",
|
"name": "com.syntriax.state",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"displayName": "Toggle State Module",
|
"displayName": "State Module",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"documentationUrl": "https://git.syntriax.com/Syntriax/ToggleState.git",
|
"documentationUrl": "https://git.syntriax.com/Syntriax/State.git",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"keywords": ["Toggle State", "Switch"],
|
"keywords": ["State"],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Syntriax",
|
"name": "Syntriax",
|
||||||
"email": "Syntriax@gmail.com",
|
"email": "Syntriax@gmail.com",
|
||||||
|
|
Loading…
Reference in New Issue