Skip to content

Instantly share code, notes, and snippets.

@marcteys
marcteys / SetPositionFromObject.cs
Last active August 29, 2015 14:14
Set uGUI rectTransform position from 3D object to 2D screen
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
[ExecuteInEditMode]
public class SetPositionFromObject : MonoBehaviour
{
public Canvas can;
public Camera cam;
@marcteys
marcteys / ExtensionMethods.cs
Last active February 16, 2019 08:13
Extension Method Unity
using UnityEngine;
using System.Collections;
public static class ExtensionMethods {
public static Vector3 GetScreenPosition(Transform transform, Canvas canvas, Camera cam)
{
Vector3 pos;
@marcteys
marcteys / BlinkShader.cs
Last active July 6, 2017 18:42
Unity Shader Trick
using UnityEngine;
using System.Collections;
public class BlinkShader : MonoBehaviour
{
public float fadeSpeed = 2f;
public float highIntensity = 2f;
public float lowIntensity = 0.5f;
public float changeMargin = 0.2f;
public bool blinkOn;
@marcteys
marcteys / dissolve.shader
Created January 24, 2015 17:02
Shader collections
Shader "Dissolve/Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_DissolveTex ("Dissolve (R)", 2D) = "white" {}
}
SubShader {
Tags {"IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 300
@marcteys
marcteys / DisableSystemUI.cs
Created March 26, 2015 14:52
FullScreenAndroid
using UnityEngine;
public class DisableSystemUI : MonoBehaviour
{
#if UNITY_ANDROID
static AndroidJavaObject activityInstance;
static AndroidJavaObject windowInstance;
static AndroidJavaObject viewInstance;
const int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2;
@marcteys
marcteys / ScrollRectBlured.cs
Last active August 29, 2015 14:17
Create a blured effect on ScrollRect / Unity
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ScrollRectBlured : MonoBehaviour {
ScrollRect scrollRect;
public UnityEngine.UI.Image startBlur;
public UnityEngine.UI.Image endBlur;
@marcteys
marcteys / PreventClickOnDrag.cs
Created March 28, 2015 17:29
Prevent Click on ScrollRect
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections;
public class PreventClickOnDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler {
private ScrollRect sr;
private CanvasGroup cg;
@marcteys
marcteys / NetworkManager.cs
Last active August 29, 2015 14:20
Easy network unity
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public bool setupServer = false;
void Start ()
{
@marcteys
marcteys / up
Created June 4, 2015 14:18
Auto update packages.json
npm install -g npm-check-updates
npm-check-updates -u
npm install
using UnityEngine;
using System.Collections;
public class UnityClick : MonoBehaviour {
public LayerMask terrainLayer;
void Update()
{
if ( Input.GetMouseButtonDown(0))