Skip to content

Instantly share code, notes, and snippets.

View RiskyWilhelm's full-sized avatar
😃

Yunus Yıldız RiskyWilhelm

😃
  • 10:28 (UTC +03:00)
View GitHub Profile
@RiskyWilhelm
RiskyWilhelm / DateTimeUtils.cs
Created November 29, 2024 13:50
Unity Utils (C# >= 9)
using System;
public static class DateTimeUtils
{
/// <summary> By default, <see cref="DateTimeExtensions"/> and <see cref="DateTimeUtils"/> will offset the hour by this value to match Cardinal Direction. Means, degree of zero will equal to 18:00 in a circle </summary>
public const float DefaultOffsetHour = 18f;
public const float ExactHourDegree = (360f / 24f); // 1 hour = 15 degree
public const float ExactMinutePoint = (ExactHourDegree / 60f); // 1 min = 0,25 degree
@RiskyWilhelm
RiskyWilhelm / BoxCollider2DExtensions.cs
Created November 29, 2024 13:35
Unity Extensions (C# >= 9) - My "Unity Utils" are required
using UnityEngine;
public static class BoxCollider2DExtensions
{
public static Vector2 GetRandomPoint(this BoxCollider2D a)
{
Vector2 extents = a.bounds.extents;
Vector2 localPoint = new (
Random.Range(-extents.x, extents.x),
@RiskyWilhelm
RiskyWilhelm / VectorRangeAttribute.cs
Last active July 9, 2024 17:01
Unity Vector Range/Limiter Attribute (C#>=9)
using UnityEngine;
/// <summary> Customizes the field shown in inspector and clamps the values as <see cref="RangeAttribute"/> does </summary>
public sealed partial class VectorRangeAttribute : PropertyAttribute
{
public readonly (float minX, float maxX, float minY, float maxY, float minZ, float maxZ, float minW, float maxW) clamped;
public VectorRangeAttribute
(
@RiskyWilhelm
RiskyWilhelm / TimeType.cs
Last active November 29, 2024 13:38
Unity Simple Timer/TimerRandomized (C# >= 9)
public enum TimeType
{
None,
Scaled,
Unscaled,
}