All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- If you are inspecting the values of a script that has one of CinderUtil's custom attribute drawers, like
[Disabled]/[DisabledOnPlay]
when the patent object gets destroyed, you'll get the following Editor only exception:SerializedObject target has been destroyed
.
v1.3.4 - 2024-06-01
- More
ServiceLocator
methods:bool TryGet<T>(out service)
: Safelly tries to retrieve the registered service. Returns false if it was unable to find the service.Deregister<T>(service, @unsafe = false)
: Attempts to deregister the provided service. By default it will throw an exception if the registered service instance was different from the provided servide. If running in unsafe mode, the service will be deregistered regardless.
v1.3.3 - 2024-05-06
- Moved
GetRandom()
andGetRandom(RNG)
from being extension methods on enumerated types, to being generic methods in theUtils
class.
v1.3.2 - 2024-05-06
- Added more methods to the
Utils
class.GenerateSeed()
: Generates a random integer to use as a seed.
- Added extension methods:
- CollectionExtensions:
AddAll(items)
: Adds all the elements in the target IEnumerable to the collection.GetRandom(RNG)
: Alternative toGetRandom()
that uses the providedSystem.Random
instead ofUnityEngine.Random
.
- EnumExtensions:
GetRandom()
: Return a random enum variant.GetRandom(RNG)
: Alternative toGetRandom()
that uses the providedSystem.Random
instead ofUnityEngine.Random
.
- CollectionExtensions:
v1.3.1 - 2024-05-04
- Added more methods to the
Utils
class.GetMouseViewportPos2D()
,GetNormalizedMouseViewportPos2D()
: Returns the mouse's position in the viewport.
v1.3.0 - 2024-05-03
-
Added extension methods:
- TypeExtensions:
Type.HasAttribute<TAttr>()
: Check via Reflection if a Type has a specificAttribute
.Type.IsMonoBehaviour()
: Check via Reflection if a Type extendsMonoBehaviour
.
- TypeExtensions:
-
Added a basic
ServiceLocator
utility under theCinderUtils.Services
namespace:-
IService
interface to define new services. -
MonoBehaviourService
base class that extends bothMonoBehaviour
andIService
for ease of use. -
Register<T>(service, @unsafe = false)
: Will try to register a service. By default it will throw an exception if the service was already registered. If running in unsafe mode, the service reference will be overriden instead. -
Get<T>(forced = false)
: Will try to get the reference to the specified service. By default it will throw an exception if the service was not registered. If running in forced mode, the service will be insantiated if not found instead. -
[AutoRegisteredService]
Attribute: Services marked with this Attribute will be initialized on theServiceLocator.Initialize()
method. This method is automatically called on theSubsystemRegistration
runtime phase.IService
s will be instantiated and the instance will be cached in the case that the class is not also aMonoBehaviour
.MonoBehaviourService
s (Or any class that extends bothMonoBehaviour
andIService
) will have aGameObject
created for them if there wasn't one already present. If using theMonoBehaviourService
base class, on Awake it will be marked withDontDestroyOnLoad()
.
-
AssemblyUtils
: Removed reduntant Assembly cache, as it added unnecesary complexity.PredefinedAssembly
andPredefinedAssemblyCache
.
v1.2.0 - 2024-05-02
- Added a
Utils
static class under theCinderUtils
namespace for general utilities.GetMousePos2D()
,GetMousePos3D()
: Return the the world coordinates of the mouse.ShootMouseRay3D(out hit)
: Shoot a Raycast from the camera in the direction of the mouse.SecondsToFormattedMinutes(int secs)
,SecondsToFormattedHours(int secs)
: Formats seconds to strings in theMM:ss
andHH:MM:ss
formats respectively.
- Added
MY_DEBUG
define for use by the user. Can can be toggled with theEnable 'MY_DEBUG'
/Disable 'MY_DEBUG'
entries on theCinderUtils
menu. - Added extension methods:
- VectorExtensions:
- For
Vector3
andVector3Int
:Vector3.Offset(offsetVector)
: Offsets the vector's XYZ components by adding another vector to it, and returns it.Vector3.OffsetX(offset)
: Offsets the vector's X component by some amount, and returns it.Vector3.OffsetY(offset)
: Offsets the vector's Y component by some amount, and returns it.Vector3.OffsetZ(offset)
: Offsets the vector's Z component by some amount, and returns it.
- For
Vector2
andVector2Int
:Vector2.Offset(offsetVector)
: Offsets the vector's XY components by adding another vector to it, and returns it.Vector2.OffsetX(offset)
: Offsets the vector's X component by some amount, and returns it.Vector2.OffsetY(offset)
: Offsets the vector's Y component by some amount, and returns it.
- For
- CollectionExtensions:
ICollection.LoopingGet(int i)
IDictionary.GetValue(key, defaultValue = default)
- VectorExtensions:
v1.1.2 - 2024-04-24
- Added extension methods:
- TypeExtensions:
Type.Is<T>()
: Reflection alternative tosomeObj is SomeType
. Usage would besomeObj.GetType().Is<SomeType>()
.
- TypeExtensions:
v1.1.1 - 2024-04-14
- Added
CinderConfigurationMenu
class as general place to add menu entries for the package. - Added
CINDER_DEBUG
define that can be toggled with theEnable Debug Mode
/Disable Debug Mode
entries on theCinderUtils
menu. - Created
CinderDebug
static class for general use. All the methods will be ignored without theCINDER_DEBUG
define being set.
- Internal library logging now make use
CinderDebug
instead ofUnityEngine.Debug
, making it dependant on theCINDER_DEBUG
define.
v1.1.0 - 2024-04-10
- Created a generic
EventBus
system under theCinderUtils.Events
namespace:- To declare an event type, implement the
IEvent
interface for some type (be it a class or a struct). - Making use of the static
EventBus
class, you canRegister<T>(EventBinding<T> binding)
bindings to recieve events, orRaise<T>(T event)
an event so that it gets propagated across bindings. - All events are sent through the
EventBus<T>
corresponding to the type parameterT
of theRaise<T>()
, tho you could pass in a an event object of a derived class through the base clases's channel if you cast the object. - To recieve events, you must create an
EventBinding<T>
, to which you register handler methods to theOnEvent
andOnEventNotify
events, and thenRegister()
the binding on theEventBus
. Make sure toDeregister()
the binding when the object gets destroyed or disabled.
- To declare an event type, implement the
- Added examples for the event system under
Samples~/Events
. - Created some Reflection utilities under the
CinderUtils.Reflection
namespace:AssemblyUtils
Used to retrieve Types from the game's Assemblies:PredefinedAssembly
: Used to be able to index into thePredefinedAssemblyCache
.PredefinedAssemblyCache
: Easily accesible cache with the Assemblies of unity's predefined assemblies.GetSubtypesOf<T>(bool, ICollection<PredefinedAssembly>)
: Used to get all the subtypes of some TypeT
. Used internally to manage theEventBus
cleanup.
- Moved basic code examples from
Samples~/Basic
toSamples~/General
.
v1.0.2 - 2024-02-07
- Added base class for custom property drawers:
CinderPropertyDrawer
. - Added extension methods:
- EnumeratorExtensions:
IEnumerator.ToEnumerable()
: Converts an IEnumerator to an IEnumerable.
- TransformExtensions:
Transform.Children()
: Returns anIEnumerable
of all the child Transforms of that transform.
- GameObjectExtensions:
GameObject.OrNull()
: Returns the object or null if the object is null or deinitializing.GameObject.Children()
: Returns anIEnumerable
of all the child GameObjects of that GameObject.
- EnumeratorExtensions:
- Improved
[ConditionalField]
attributes to take values asobject
, without converting tostring
internally, this allows to check fornull
. - Improved examples for the
ConditionalFieldAttribute
. - Made custom property drawers (
[Disabled]
,[DisabledOnPlay]
,[ConditionalField]
) extendCinderPropertyDrawer
.
v1.0.1 - 2024-02-06
- Added basic code examples under
Samples~/Basic
. - Added
UPM Git Extension
to package dependencies.
- Updated
.gitignore
to ignore more IDE cache directories (.vscode
and.idea
). - Updated keywords on the
package.json
.
v1.0.0 - 2024-02-06
- Created basic unity package with AssemblyDefinitions for the
Editor
andRuntime
code. - The namespace for the
Runtime
AssemblyDefinition is:CinderUtils
. - The namespace for the
Editor
AssemblyDefinition is:CinderUtils.Editor
. - Added utility functions via extension methods under the
CinderUtils.Extensions
namespace.- CollectionExtensions:
ICollection.GetRandom()
- EnumeratorExtensions:
IEnumerable.NullOrEmpty()
IEnumerable.ForEach(Action action)
IEnumerable.ToDebugString()
- CollectionExtensions:
- Implemented some utility attributes with
CustomPropertyDrawer
to enable more editor customization.[Disabled]
: Disables the field on the Editor, while still being visible.[DisabledOnPlay]
: Disables the field on the Editor while the Application is running, or the Editor is changing states.[ConditionalField]
: Shows the anotated field only if the value of the target field matches one of the passed values, otherwise it will be hidden. This behaviour can be reversed with theinverse
flag. NOTE: It's anabstact
class withinternal
constructor, use[ShowIf]
and[HideIf]
instead.[ShowIf]
and[HideIf]
, which are variants of[ConditionalField]
that set theinverse
flag accordingly.