Namespace LoM.Super
Included in the base framework
This namespace is the base for all Super Frameworks and Plugins.
Should be included in all Scripts in the Project.
Classes
ConditionAttribute
Attribute to specify conditions for a field or property.
NOTE: Use this to create your own custom conditions.
EditableIfAttribute
Attribute to make a field editable if a condition is met.
Note: If the target field is a bool it will check for true/false, otherwise it will check if the field is not null.
[SerializeField] private bool m_UseFeature;
[SerializeField, EditableIf("m_UseFeature")] private Transform m_ObjectReference; // Will only be editable if m_UseFeature is true.
Known Issue:
Sometimes the Inspector Window will not update the field when the condition is met.
Until solved, this behaviour can be fixed by deselecting and reselecting the item to refresh the inspector manually.
HDRColorAttribute
Attribute to mark a field as a HDR color.
LabelAttribute
Attribute to specify a custom label for a field or property.
LayerAttribute
Use this attribute to make a field a layer field.
Only works on int fields.
LazySingletonBehaviour<T>
A singleton MonoBehaviour that inherits from SuperBehaviour.
NOTE: This will create a new instance if one does not exist.
See SingletonBehaviour<T> for more information on how to use this class.
PropertyHDRColorAttribute
Attribute to make a field be drawn as HDR color field.
PropertyHeaderAttribute
Attribute to specify a header for a property. Is drawn above the property.
PropertyLayerAttribute
Attribute to make a property a layer field. Only works on int fields.
PropertyRangeAttribute
Attribute to specify a range for a property. Only works for float and int.
PropertySpaceAttribute
Use this attribute to add a space between properties in the inspector.
PropertyTagAttribute
Use this attribute to make a field a tag field. Only works on string fields.
PropertyTextAreaAttribute
Attribute to make a field be drawn as a text area. Only works on string fields.
[PropertyTextArea(3, 10)]
public string text;
PropertyTooltipAttribute
Attribute to specify a tooltip for a property.
ReadOnlyAttribute
Use this attribute to make a field read-only in the inspector.
SerializePropertyAttribute
Use this attribute to enable properties to be shown like fields in the inspector.
WARNING: This does NOT serialize or save the property in any way.
Due to to the limition mentioned above the attributes are only editable in the play mode.
Any changes made to the properties in edit mode will not be saved.
[SerializeProperty]
public int PlayerHealth => m_PlayerHealth;
NOTE: It will still not be editable in edit mode.
[SerializeProperty]
public int PlayerHealth { get; set; }
ShowIfAttribute
Attribute to show or hide a field based on a condition.
Note: If the target field is a bool it will check for true/false, otherwise it will check if the field is not null.
[SerializeField] private bool m_UseFeature;
[SerializeField, ShowIf("m_UseFeature")] private Transform m_ObjectReference; // Will only be visible if m_UseFeature is true.
Known Issue:
Sometimes the Inspector Window will not update the field when the condition is met.
Until solved, this behaviour can be fixed by deselecting and reselecting the item to refresh the inspector manually.
SingletonBehaviour<T>
A singleton MonoBehaviour that inherits from SuperBehaviour.
Implements a thread-safe singleton pattern as a inheritable base class.
public class GameManager : SingletonBehaviour<GameManager>
{
// ...
}
This approach ensures that each subclass (GameManager, UIManager, etc.) functions as a singleton, inheriting the singleton behavior from the base Manager class.
// Base class with generic type parameter T for singleton management
public class Manager<T> : SingletonBehaviour<T> where T : SuperBehaviour { }
// Derived singleton classes
public class GameManager : Manager<GameManager> { }
public class UIManager : Manager<UIManager> { }
SuperBehaviour
SuperBehaviour is a MonoBehaviour that provides some additional functionality.
It provides a cached version of the transform and gameObject properties.
It also enables the use of SuperEditor and SerializedProperties.
SuperRectTransform
Represents a UGUI RectTransform
This class is used to simplify the access to the RectTransform of a UGUI GameObject, it provides a more intuitive way to access the RectTransform properties as they behave exactly like in the Inspector.
// Stretch All
SuperRectTransform transform = GetComponent<RectTransform>();
transform.Left = 10;
transform.Right = 10;
transform.Bottom = 10;
transform.Top = 10;
// Center
SuperRectTransform transform = GetComponent<RectTransform>();
transform.PosX = 10;
transform.PosY = 10;
transform.Width = 100;
transform.Height = 100;
TagAttribute
Use this attribute to make a field a tag field. Only works on string fields.
UGUIAnchorExtensions
UGUIExtensions
Enums
UGUIAnchor
Represents the anchor of a RectTransform as shown in the Inspector