programmazione

JS Redirection – IOS – Android

JS Redirection – IOS – Android

Create in the same folder:
– mobile-detector.html
It this the javascript that detects the device type
– ios.html
The page for IOS devices
– android.html
The page for Android devices
– error.html
An Error page

mobile-detector.html


<!DOCTYPE html>
<html>
<head>
 
<script type="text/javascript">
// #######################################################
// Mobile JS Redirect
// Don't Break My b***s - Gimme Code! Project                                           
// Author: Andrea Tonin - http://blog.lucedigitale.com                                 
// This code come with absolutely no warranty                                            
// If you use this code in your project please give a link to http://blog.lucedigitale.com 
// Thanks in advance                                                                       
// #######################################################
 
var isMobile = {
        Android: function() {
            return navigator.userAgent.match(/Android/i);
        },
        BlackBerry: function() {
            return navigator.userAgent.match(/BlackBerry/i);
        },
        iOS: function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
        },
        Opera: function() {
            return navigator.userAgent.match(/Opera Mini/i);
        },
        Windows: function() {
            return navigator.userAgent.match(/IEMobile/i);
        },
        any: function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
        }

    };



if ( isMobile.Android() ) {
        document.location.href = "android.html";
    }
else if(isMobile.iOS())
	{
	document.location.href="ios.html";
	}
else
    {
    document.location.href="error.html";
    }
 
</script>
 
</head>
 
<body>
<center>
<br>
<b><h1>You are being redirected to other site.</h1>
<br>
<br>
<h1>If you are not redirected within 4 seconds</h1></b>
<br>
<h1><a href="android.html">ANDROID HERE</h1></a>
<h1><a href="ios.html">IOS HERE</h1></a>
</center>
</body>
 
</html>

ios.html


<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body>
<!-- Questo è un commento, non viene renderizzato dal browser -->
<h1>IOS!</h1>
</body>
 
</html>

android.html


<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body>
<!-- Questo è un commento, non viene renderizzato dal browser -->
<h1>Android!</h1>
</body>
 
</html>

error.html


<!DOCTYPE html>
<html>
 
<head>
</head>
 
<body>
<!-- Questo è un commento, non viene renderizzato dal browser -->
You need an Android or IOS device!
</body>
 
</html>

By |JavaScript, Web Design|Commenti disabilitati su JS Redirection – IOS – Android

Unity 3D Game Engine – Android – Tap Single – Counter Increase – JavaScript

Unity 3D Game Engine – Android – Tap Single – Counter Increase – JavaScript

This script it is a simple Tap Counter, if you Tap over the objects in the scene counter value will increase.

Inside Hierarchy create the game Objects:

– Sphere (GameObject)
– GUI Text (GameObject)
– Main Camera, attach the ‘TapCounter.js’:

TapCounter.js


#pragma strict

    // Only ANDROID NOT PC NOT IOS
    // Attach this script to the Main Camera
    
// Hierarchy DRAG E DROP over var GUI Text in Inspector
var scoreText : GUIText;
// touch counter, private because the users is not be able to change this value
private  var score : int;

// Ray Cast Setup
var speed : float = 4;
var hit = new RaycastHit();

function Start () {
        // The counter initial value is 0
        score = 0;
        scoreText.text = "No Touch:";
}

function Update () {

	// se c'è un tocco Input.touchCount AND la fase del tocco è quella iniziale TouchPhase.Began
	if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) {
	// traccia i raggi dalla Camera dal punto del tocco
	var ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);

		// se raycast colpisce l'oggetto
		if (Physics.Raycast (ray, hit)) {
		// fai partire la funzione che incrementa il contatore
		UpdateScore ();
		}

	}
}

function UpdateScore () {
    // score var increment of +1
    score += 1;
    // scoreText in assigned inside Inspector on GUI Text
    // change .text property and write it on the display 
    scoreText.text = "Touched: "  + score;
}

Hierarchy> Main Camera> Inspector> TapCounter.js DRAG AND DROP ‘GUI Text’ (GameObject) over var scoreText

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D Game Engine – Android – Tap Single – Counter Increase – JavaScript

Unity 3D Game Engine – Android – Tap Single – Destroy Object – JS

Unity 3D Game Engine – Android – Tap Single – Destroy Object – JS

With this JS Script you will destroy objects if you tap them.

Inside Hierarchy create the structure:

– Ball (Game Object)
– Main Camera, attach the script ‘TouchDestroy.js’

TouchDestroy.js


#pragma strict

    // ONLY ANDROID NOT PC NOT IOS
    // Attach this script to the Main Camera
    // It raycasts from camera and destroies objects if you will touch them

var speed : float = 4;
var hit = new RaycastHit();

function Update () {

	// se c'è un tocco Input.touchCount AND la fase del tocco è quella iniziale TouchPhase.Began
	if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) {
	// traccia i raggi dalla Camera dal punto del tocco
	var ray = Camera.main.ScreenPointToRay (Input.GetTouch(0).position);

		// se raycast colpisce l'oggetto
		if (Physics.Raycast (ray, hit)) {
		// distruggi l'oggetto colpito
		Destroy(hit.transform.gameObject);
		}

	}
}

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D Game Engine – Android – Tap Single – Destroy Object – JS

Unity 3D Game Engine – Camera – 2D Platform – Smooth Follow

Unity 3D Game Engine – Camera – 2D Platform – Smooth Follow

1. Inside Hierarchy create the structure:

– Player (parent)
— CameraTarget (Empty Object) (child)

– Main Camera

2. Select ‘Main Camera’ and create ‘CameraController.js’

CameraController.js


#pragma strict
 
var cameraTarget : GameObject; // Inspector> Assign the Camera Target NON è il target della camera ma la posizione che vuole raggiungere la camera

var smoothTime : float = 0.1;              // Delay in seconds to follow Player
var cameraFollowX : boolean = true;        // Inspector> if is checked -> The Camera will follow X position of cameraTarget
var cameraFollowY : boolean = true;        // Inspector> if is checked -> The Camera will follow Y position of cameraTarget
var cameraFollowHeight : boolean = false;  // if true the Camera Y Position = cameraHeight
var cameraHeight : float = 2.5;            // cameraHeight
var velocity : Vector2;
private var thisTransform : Transform;    

function Start ()
{
  thisTransform = transform;
}

function Update () 
{

if (cameraFollowX) // if cameraFollowX = true = Inspector is checked
{
  thisTransform.position.x = Mathf.SmoothDamp (thisTransform.position.x, cameraTarget.transform.position.x, velocity.x, smoothTime);
}

if (cameraFollowY) // if cameraFollowY = true = Inspector is checked
{
  thisTransform.position.y = Mathf.SmoothDamp (thisTransform.position.y, cameraTarget.transform.position.y, velocity.y, smoothTime);
}

if (!cameraFollowY && cameraFollowHeight)     // if cameraFollowY = false = Inspector is unchecked AND cameraFollowHeight = true = Inspector is checked
{
  camera.transform.position.y = cameraHeight; // The Camera Y position = cameraHeight
}

}

Main Camera> Inspector> LookAt.js> DRAG AND DROP over:
– var Camera Target -> CameraTarget (Empty Object)
– var Player -> Player (Game Object)
– var Smoot Time -> Delay time to reach final position

a. Camera Follow X check | Camera Follow Y check | Camera Follow Height uncheck | Camera Height
-> follow X and Y of cameraTarget

b. Camera Follow X uncheck | Camera Follow Y check | Camera Follow Height uncheck | Camera Height
-> follow Y of cameraTargetr the X value is the current X position in the viewport

c. Camera Follow X check | Camera Follow Y uncheck | Camera Follow Height check | Camera Height
-> follow X of cameraTarget and Y Camera Height value

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D Game Engine – Camera – 2D Platform – Smooth Follow

Unity 3D Game Engine – Best Resources

Unity 3D Game Engine – Best Resources

Official Unity Web Site

Start Here! Download the software, beginners tutorials, asset store.

http://unity3d.com/

Official Wiki

Thousands of scripts ready to use, tips and more, REALLY GREAT!

http://wiki.unity3d.com/

Organized tutorial list

Video Tutorials from Unity

List of Tutorials & Resources on UnityAnswsers:
http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html

List of Tutorials & Resources from “Unity Support” on this forum
http://forum.unity3d.com/threads/28867-Learning-Resources-for-Unity

Walker Boys
http://forum.unity3d.com/threads/69938-Unity-3-Video-Training-Course-(FREE)-Walker-Boys

InsurgentX
http://forum.unity3d.com/threads/107593-InsurgentX-s-Unity-Advanced-Tutorials

TornadoTwins
http://www.youtube.com/user/TornadoTwins

BurgZergArcade
http://www.burgzergarcade.com/

BurgZerg RPG Tutorials
http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial

Catlikecoding: Unity Tutorials
http://catlikecoding.com/unity/tutorials/

Buy Dame Assets

Free

http://www.3dvalley.com/
http://www.3dsmodels.com/
http://3dmagicmodels.com/
http://archive3d.net/
http://opengameart.org/
http://www.katorlegaz.com/3d_models/index.php
http://www.sharecg.com/
http://e2-productions.com/repository/modules/PDdownloads/
http://www.morguefile.com/
http://www.sxc.hu/
http://www.texturemate.com/
http://www.publicdomainpictures.net/
http://www.public-domain-photos.com/
http://www.public-domain-image.com/
http://creativity103.com/
http://www.openclipart.org
http://www.fromoldbooks.org/
http://www.gfxplace.com/

Free/Paid

http://www.3drt.com/
http://bunbun.com.au/
http://activeden.net/category/unity-3d
http://www.unitymagic.com/shop/
http://www.thegamecreators.com/
http://www.the3dstudio.com/
http://www.3dmagicmodels.com/
http://www.dexsoft-games.com/
http://www.creativecrash.com/
http://www.turbosquid.com/
http://www.gametextures.com/
Unity Asset Store (Inside Unity)

Paid Only

http://www.indiegamemarket.com/
http://visualconduct.com/shop/
http://www.arteria3d.com/
http://www.3dmedia.be/
http://developer.daz3d.com/
http://www.nekotika.com/
http://www.unitydevs.com/
http://www.unityprefabs.com/
http://www.frogames.net/
http://www.gamesprites.com/

By |Unity3D, Video Games Development|Commenti disabilitati su Unity 3D Game Engine – Best Resources