Skip to content

Instantly share code, notes, and snippets.

View DataGreed's full-sized avatar
👾
practicing magic

Alexey Strelkov DataGreed

👾
practicing magic
View GitHub Profile
@DataGreed
DataGreed / JoystickTester.cs
Created July 6, 2019 21:40
find out gamepad thumbstick and button mapping in Unity on your platform
// Arowx.com 2013 - free to use and improve!
using UnityEngine;
using System.Collections;
public class JoystickTester : MonoBehaviour {
public TextMesh joysticks;
public TextMesh[] inputText;
public TextMesh[] buttonText;
adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG
@DataGreed
DataGreed / paddedTime.js
Created June 26, 2019 15:42
Local time with leading zeroes (string padding)
var someDate = new Date("Wed Jun 26 2019 09:08:32 GMT+0100")
result = `${String(someDate.getHours()).padStart(2,"0")}:${String(someDate.getMinutes()).padStart(2,"0")}` // returns "09:08"
@DataGreed
DataGreed / CustomPrefabImporterEditor.cs
Created June 5, 2019 18:08 — forked from TJHeuvel/CustomPrefabImporterEditor.cs
Custom inspector window for Unity prefabs that allows you to (multi) edit them.
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
using UnityEngine;
using System.Reflection;
using System;
using System.Collections;
using System.Linq;
using Object = UnityEngine.Object;
using System.Collections.Generic;
@DataGreed
DataGreed / ColliderToFit.cs
Last active June 3, 2019 13:12
#Unity adjust box collider to children object bounds
using UnityEngine;
using UnityEditor;
using System.Collections;
public class ColliderToFit : MonoBehaviour {
[MenuItem("My Tools/BoxCollider/Fit to Children")]
static void FitToChildren() {
foreach (GameObject rootGameObject in Selection.gameObjects) {
if (!(rootGameObject.collider is BoxCollider))
@DataGreed
DataGreed / lookAtAdjustment.cs
Created May 22, 2019 00:13
fix lookAt position
bullet.transform.rotation = Quaternion.Euler( 90, 0, 0 ) * Quaternion.LookAt( target.transform.position - bullet.transform.position ) ;
// OR
//bullet.transform.rotation = Quaternion.LookAt( target.transform.position - bullet.transform.position ) * Quaternion.Euler( 90, 0, 0 ) ;
@DataGreed
DataGreed / UnityStencilledObject.shader
Created May 14, 2019 19:10 — forked from ewandennis/UnityStencilledObject.shader
A simple surface shader for Unity which honours a specific stencil buffer value
Shader "Custom/Stencilled" {
Properties {
_StencilMask("Stencil mask", Int) = 0
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
@DataGreed
DataGreed / UnityStencilMask.shader
Created May 14, 2019 19:10 — forked from ewandennis/UnityStencilMask.shader
A simple stencil buffer masking shader for Unity
Shader "Custom/StencilMask" {
Properties {
_StencilMask("Stencil mask", Int) = 0
}
SubShader {
Tags {
"RenderType" = "Opaque"
"Queue" = "Geometry-100"
}
@DataGreed
DataGreed / placeholder.cs
Created April 27, 2019 20:33
look at point
public void LookAtPoint2d(Vector2 targetPoint, int degreesCompensation=0)
{
Vector3 dir = (targetPoint - (Vector2)transform.position).normalized;
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - degreesCompensation;
torsoAnimator.gameObject.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
@DataGreed
DataGreed / locustfile.py
Created April 18, 2019 12:34
Locust.io trace all web requests and responses
# coding=utf-8
from locust.clients import HttpSession
from locust import HttpLocust
class LoggedHttpSession(HttpSession):
def __init__(self, base_url, debug=True, *args, **kwargs):
"""
Custom HttpSession client that saves all request and responses data for debugging
"""
self.debug = debug