Skip to content

Instantly share code, notes, and snippets.

View dsjs-web's full-sized avatar
💭
It's now or never

DSJS dsjs-web

💭
It's now or never
View GitHub Profile
using UnityEngine;
using UnityEngine.EventSystems;
public class FixedButton : MonoBehaviour, IPointerUpHandler, IPointerDownHandler
{
[HideInInspector]
public bool Pressed;
// Use this for initialization
void Start()
@MattRix
MattRix / ObjExporter.cs
Last active April 4, 2025 21:48
Exports Unity meshes to an obj file
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using System.Text;
public class ObjExporterScript
{
private static int StartIndex = 0;
import Foundation
import RxSwift
class Ref<E> {
private let value : Variable<E>
private let q = dispatch_queue_create("net.chrisfarber.Ref<\(E.self)>", DISPATCH_QUEUE_SERIAL)
init(i:E) {
value = Variable(i)
}
@MattRix
MattRix / PhysicsFollower.cs
Last active August 10, 2025 08:03
A thing you can use to make a rigidbody move towards a position reliably
using UnityEngine;
using System.Collections;
using System;
[RequireComponent (typeof(Rigidbody))]
public class PhysicsFollower : MonoBehaviour
{
public Transform target;
Rigidbody rb;
Shader "Example/Decal" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" "Queue"="Geometry+1" "ForceNoShadowCasting"="True" }
LOD 200
Offset -1, -1
CGPROGRAM
@HugoGresse
HugoGresse / MainActivity.java
Created March 2, 2016 11:06
changeFragment
/**
* Change the current displayed fragment by a new one.
* - if the fragment is in backstack, it will pop it
* - if the fragment is already displayed (trying to change the fragment with the same), it will not do anything
*
* @param frag the new fragment to display
* @param saveInBackstack if we want the fragment to be in backstack
* @param animate if we want a nice animation or not
*/
@enghqii
enghqii / NormalMap.shader
Created December 12, 2015 02:23
NormalMap shader Unity
Shader "Custom/NormalMapShader" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_LightColor("LightColor", Color) = (1,1,1,1)
_MainTex("Albedo (RGB)", 2D) = "white" {}
_SpecularMap("SpecularMap (RGB)", 2D) = "white" {}
_NormalMap("NormalMap", 2D) = "white" {}
_MainLightPosition("MainLightPosition", Vector) = (0,0,0,0)
}
SubShader{
@nigelbrady
nigelbrady / TapCharacterController.cs
Last active April 6, 2023 11:35
Simple Tap-To-Move Character Controller for Unity
using UnityEngine;
using System.Collections;
using System.Linq;
public class TapCharacterController : MonoBehaviour
{
public delegate void MotionEventHandler (GameObject sender);
public delegate void TargetHandler (GameObject sender,GameObject target);
@McFunkypants
McFunkypants / FlyCamera.cs
Created November 7, 2014 21:59
New Script FlyCamera add to any camera obj: instant unity editor style wasd rightclick debug cam
using UnityEngine;
using System.Collections;
public class FlyCamera : MonoBehaviour {
/*
Writen by Windexglow 11-13-10. Use it, edit it, steal it I don't care.
Converted to C# 27-02-13 - no credit wanted.
Simple flycam I made, since I couldn't find any others made public.
Made simple to use (drag and drop, done) for regular keyboard layout
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Created October 24, 2014 07:14
Extension methods for working with Configurable Joints for Unity
using UnityEngine;
public static class ConfigurableJointExtensions
{
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{