Skip to content

Instantly share code, notes, and snippets.

Avatar

Jibran Syed JISyed

View GitHub Profile
@JISyed
JISyed / InputManagerCloner.cs
Created Apr 14, 2017
Technique to clone Unity's InputManager into a ScripableObject in order to extract data for use in code
View InputManagerCloner.cs
using UnityEngine;
using UnityEditor;
namespace XboxCtrlrInput.Editor
{
/// <summary>
/// Clones Unity's Input Manager into a new file at /Assets/Plugins/InputManagerClone.asset
/// </summary>
/// <remarks>
/// Do NOT modify!!!
@JISyed
JISyed / SnippetsXcodeCpp.cpp
Created Apr 4, 2016
A collection of C++ snippets that are useful for Xcode
View SnippetsXcodeCpp.cpp
//==================================================================
/// <#Insert description of new class here#>
class <#NewClassName#>
{
public:
//
// Essentials
//
@JISyed
JISyed / LoadShaderFromFile.cpp
Created Dec 7, 2013
A little helper function to load an OpenGL shader file (can be any text formatted file) to a C-String. The returned string has to be deleted by the caller when not needed anymore. You need: #include <iostream> #include <fstream>
View LoadShaderFromFile.cpp
const char* ReadShaderFileToMemory(const char* filePath)
{
const char * shaderFileBuffer = NULL;
std::ifstream inSdrFileStream(filePath);
if(inSdrFileStream)
{
// Get length of shader file by seeking and telling (offset of 0)
inSdrFileStream.seekg(0, inSdrFileStream.end);
unsigned long fileLength = (unsigned long) inSdrFileStream.tellg() + 1;
@JISyed
JISyed / MoveCameraInertia.cs
Last active Jun 9, 2019
Similar to MoveCamera.cs (https://gist.github.com/JISyed/5017805), except with inertia. This makes the camera gradually come to a smooth stop when stopping the camera movement.
View MoveCameraInertia.cs
// Credit to damien_oconnell from http://forum.unity3d.com/threads/39513-Click-drag-camera-movement
// for using the mouse displacement for calculating the amount of camera movement and panning code.
using UnityEngine;
using System.Collections;
public class MoveCamera : MonoBehaviour
{
//
@JISyed
JISyed / gradually_turn.gml
Created Sep 5, 2013
GameMaker script (GML) that makes an object gradually turn towards a target object at the specified speed. A tutorial explaining this code can be found here: http://jibransyed.wordpress.com/2013/09/05/game-maker-gradually-rotating-an-object-towards-a-target/
View gradually_turn.gml
// gradually_turn.gml
// --------
// Gradually turns an object towards its target
//
// FORMAT:
// gradually_turn(objToTurn, target, turnSpeed, accuracy);
//
// <objToTurn> takes an object
// <target> takes an object
@JISyed
JISyed / MoveCamera.cs
Last active Apr 15, 2021
Camera movement script in Unity3D. Supports rotating, panning, and zooming. Attach to the main camera. Tutorial explaining code: http://jibransyed.wordpress.com/2013/02/22/rotating-panning-and-zooming-a-camera-in-unity/
View MoveCamera.cs
// Credit to damien_oconnell from http://forum.unity3d.com/threads/39513-Click-drag-camera-movement
// for using the mouse displacement for calculating the amount of camera movement and panning code.
using UnityEngine;
using System.Collections;
public class MoveCamera : MonoBehaviour
{
//
// VARIABLES