Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using UnityEngine.UI;
public class Controller : MonoBehaviour {
// To display output of the alert box
public Text reply;
// To store context of the main activity that Unity3D is running
private AndroidJavaObject activityContext = null;
package com.plugin.android.dialogboxmodule;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.view.ContextThemeWrapper;
import com.unity3d.player.UnityPlayer;
using UnityEngine;
public class CallToast : MonoBehaviour {
// To store context of the main activity that Unity3D is running
private AndroidJavaObject activityContext = null;
// To store the instance of the class
private AndroidJavaObject toastExample = null;
Shader "UnityCoder/Rays2"
{
Properties
{
tDiffuse ("Base (RGB)", 2D) = "white" {}
fX ("fX", Float) = 0.5 // you can feed mouse xpos here with script: var mpos:Vector3 = Camera.main.ScreenToViewportPoint(Input.mousePosition); renderer.material.SetFloat( "fX", mpos.x);
fY ("fY", Float) = 0.5 // mouse ypos
fExposure ("fExposure", Float) = 0.6
fDecay ("fDecay", Float) = 0.93
fDensity ("fDensity", Float) = 0.96
using UnityEngine;
using System.Collections;
/// <summary>
/// Quality setting manager.
/// To change the quality of graphics at runtime which will
/// increase quality and power consumption and may decrease framerate vice versa
/// </summary>
public class QualitySettingManager : MonoBehaviour {
@nipundavid
nipundavid / Matte Shadow.shader
Created November 30, 2016 05:24
Shader to show the shadow on transparent gameobject, very usefull in Augmented Reality (Vuforia)
Shader "FX/Matte Shadow" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
Blend Zero SrcColor
@nipundavid
nipundavid / SavWav.cs
Created November 10, 2016 05:10 — forked from darktable/SavWav.cs
Unity3D: script to save an AudioClip as a .wav file.
// Copyright (c) 2012 Calvin Rien
// http://the.darktable.com
//
// This software is provided 'as-is', without any express or implied warranty. In
// no event will the authors be held liable for any damages arising from the use
// of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
using UnityEngine;
using System.Collections;
public class SwipeScript : MonoBehaviour {
private float fingerStartTime = 0.0f;
private Vector2 fingerStartPos = Vector2.zero;
private bool isSwipe = false;
@nipundavid
nipundavid / Levitate.cs
Created September 12, 2016 04:35
This scripts levitate game object in 3 axis.
using UnityEngine;
using System.Collections;
public class Levitate : MonoBehaviour {
public float amplitude = 0.1f;
public Vector3 speed;
private Vector3 tempVal;
private Vector3 tempPos;
void Start ()
@nipundavid
nipundavid / CustomShader_Texture.shader
Last active September 9, 2016 04:43
A simple shader, which wraps a texture around a 3D model
Shader "Unlit/CustomShader_Texture"
{
Properties {
// Texture field in inspector where we assign texture to the model
_MainTexture("Main Texture",2D) = "white"{}
}
SubShader {
PASS {
CGPROGRAM