Skip to content

Instantly share code, notes, and snippets.

View jcguarinpenaranda's full-sized avatar
😀

Juan Camilo Guarin Peñaranda jcguarinpenaranda

😀
View GitHub Profile
using UnityEngine;
using System.Collections;
public class DontDestroy : MonoBehaviour {
// Use this for initialization
void Awake () {
DontDestroyOnLoad(gameObject);
@jcguarinpenaranda
jcguarinpenaranda / SimpleAds.cs
Last active August 29, 2015 14:26
Show Ads when Unity game starts
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class SimpleAds : MonoBehaviour
{
//Change to your gameID code in
//unityads.unity3d.com
string gameID = "33675";
@jcguarinpenaranda
jcguarinpenaranda / AdManager.cs
Created August 8, 2015 22:41
AdManager is a script copied from Unity Technologies which allows you to add Ads integration very easy
using UnityEngine;
using System.Collections;
using UnityEngine.Advertisements;
public class AdManager : MonoBehaviour
{
//Important: Change the gameID to your game's
//id in the unityads.unity3d.com dashboard
[SerializeField] string gameID = "33675";
@jcguarinpenaranda
jcguarinpenaranda / LoadLevelAdditive.cs
Created August 8, 2015 22:45
Load a level Additively in Unity 3d
using UnityEngine;
using System.Collections;
public class LoadAdditive : MonoBehaviour {
public void LoadAddOnClick(int level)
{
Application.LoadLevelAdditive(level);
}
}
@jcguarinpenaranda
jcguarinpenaranda / ClickToLoadAsync.cs
Created August 8, 2015 22:51
Load a level asynchronously in Unity3d
//From: http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/creating-a-scene-menu
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ClickToLoadAsync : MonoBehaviour {
//The slider that is going to be affected
public Slider loadingBar;
@jcguarinpenaranda
jcguarinpenaranda / LoadScene.cs
Created August 8, 2015 22:52
Load a scene in Unity 3d
using UnityEngine;
using System.Collections;
public class LoadScene : MonoBehaviour {
public GameObject loadingImage;
public void LoadScene(int level)
{
loadingImage.SetActive(true);
@jcguarinpenaranda
jcguarinpenaranda / PinchZoom.cs
Created August 8, 2015 23:29
Pinch to zoom camera in Unity 3d
using UnityEngine;
public class PinchZoom : MonoBehaviour
{
public float perspectiveZoomSpeed = 0.5f; // The rate of change of the field of view in perspective mode.
public float orthoZoomSpeed = 0.5f; // The rate of change of the orthographic size in orthographic mode.
void Update()
{
@jcguarinpenaranda
jcguarinpenaranda / Notify in android statusbar
Created September 26, 2015 18:11
Notify in android statusbar method
private void notifyStatusBar(String title, String text){
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);
Notification n = new NotificationCompat.Builder(this)
@jcguarinpenaranda
jcguarinpenaranda / Angular JS http post fix
Created October 1, 2015 01:33
Angular JS http post fix
.config(['$httpProvider', function ($httpProvider) {
// Intercept POST requests, convert to standard form encoding
$httpProvider.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
$httpProvider.defaults.transformRequest.unshift(function (data, headersGetter) {
var key, result = [];
if (typeof data === "string")
return data;
for (key in data) {
@jcguarinpenaranda
jcguarinpenaranda / angular-socket.js
Created October 20, 2015 04:22
Angular js socket io factory
app.factory('socket', function ($rootScope) {
var socket = io.connect();
return {
on: function (eventName, callback) {
socket.on(eventName, function () {
var args = arguments;
$rootScope.$apply(function () {
callback.apply(socket, args);
});
});