Skip to content

Instantly share code, notes, and snippets.

View h-sigma's full-sized avatar

Harshdeep Singh h-sigma

  • India
View GitHub Profile
@h-sigma
h-sigma / index.js
Created September 11, 2023 08:07
Basic File Transform as Node Script
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const filePath = process.argv[2];
if (!filePath) {
console.error('Please provide the path to the file to transform.');
process.exit(1);
}
require('@rushstack/eslint-patch/modern-module-resolution');
module.exports = {
root: true,
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'plugin:prettier/recommended',
'@vue/eslint-config-prettier',
@h-sigma
h-sigma / package.json
Created November 29, 2022 18:15
Component Library setup
//partial
"files": [
"src",
"dist"
],
"types": "./dist/types/index.d.ts",
"module": "./dist/mega-components-lib.es.js",
"exports": {
".": {
public interface ITimeProvider
{
float renderDeltaTime { get; }
float fixedDeltaTime { get; } //ideally, do not include this, and use Time.fixedDeltaTime always
float renderTime { get; }
float fixedTime { get; }
}
public class TimeProvider : MonoBehavior
{
@h-sigma
h-sigma / ReadMe.md
Last active June 8, 2020 21:30
An Attribute to use a c# property to get/set the value on a serialized field in the Unity Editor.

Drop ThroughPropertyAttribute.cs anywhere in Assets.

Drop ThroughPropertyDrawer.cs anywhere inside an Editor folder in Assets.

Attach Test to a gameobject to make sure it works. See the code in Test for an example.

Features:

  • Displays field as readonly if setter is missing.
  • Works with non-public getter/setters.
@h-sigma
h-sigma / DisplayAsEulerAttribute.cs
Last active June 7, 2020 19:30
An attribute in Unity to display radians, vectors, and quaternions in the form of human-readable Euler angles in the Editor.
using UnityEngine;
namespace Utility
{
public class DisplayAsEulerAttribute : PropertyAttribute
{
public float min;
public float max;
public DisplayAsEulerAttribute(float min = 0, float max = 359.9999f)
using System.Linq;
using UnityEditor;
namespace Editor.EditorScripts
{
public static class MenuItemsCollection
{
[MenuItem("GameObject/Replace", priority = 21)]
public static void ReplaceObjectInHierarchy(MenuCommand menuCommand)
{
@h-sigma
h-sigma / InterfaceAttribute.cs
Last active May 28, 2020 12:54
An attribute for MonoBehaviour's that restricts assigning in the editor to MB's deriving from a specific interface.
/*
* Author: Harshdeep Singh, https://github.com/h-sigma
* Year: 2020
* Description: An attribute for MonoBehaviour's that restricts assigning in the editor to MB's deriving from a specific interface.
* Use:
* [Interface(typeof<IHealth>)]
* public MonoBehaviour health;
* Note: This hasn't been bug tested, and it is a very simplistic way to do the job. If required or requested, I may choose to improve it.
*/
@h-sigma
h-sigma / PatternMatch.hpp
Created October 24, 2019 05:57
Matches (possibly) enum values to function calls for patterns.
#include <vector>
#include <functional>
template<typename ENUM>
class PatternMatch
{
public:
PatternMatch() = default;
template<typename Func, ENUM ...Enums> void bindFunc(Func);