Android Restart Button Tutorial 20151

Advertisemen

Android Restart Button Tutorial 20151





























DIRECT DOWNLOAD HERE












THIS IS BACKUP  IN TEXT FORM AndroidRestartButton

1. Create New C# and name it : AndroidRestartButton1

2. Copy & Past this text and save C# :
----------------------------------------­­­­­------------------------------------­-­-­-­-­-


using UnityEngine;
using System.Collections;

public class AndroidRestartButton1 : MonoBehaviour {

public Texture2D button1;
public Texture2D button2;





// Use this for initialization
void Start ()
{
guiTexture.texture = button1;
}

// Update is called once per frame
void Update ()
{
foreach (Touch touch in Input.touches)
{
if (guiTexture.HitTest(touch.position) && touch.phase != TouchPhase.Ended)
{
guiTexture.texture = button2;

Application.LoadLevel("level1");


}
else if (guiTexture.HitTest(touch.position) && touch.phase == TouchPhase.Ended)
{
guiTexture.texture = button1;
}
}
}
}




----------------------------------------­­­­­------------------------------------­-­-­-­-­-












THIS IS BACKUP  IN TEXT FORM GUIrescaler

1. Create New JAVA  and name it : GUIrescaler

2. Copy & Past this text and save JAVA:
----------------------------------------­­­­­------------------------------------­-­-­-­-­-



#pragma strict

//here is a special gui rescaler that automatically rescales GUIText and GUITextures so they're not stretched.

private var getTxt:Component;
private var getTxtr:Component;
private var resX:float;
private var resY:float;
private var origResX:float;
private var origResY:float;
private var txtrX:float;
private var txtrY:float;
private var txtX:float;
private var txtY:float;

function Start () {
getTxt = transform.GetComponent(GUIText);
getTxtr = transform.GetComponent(GUITexture);
if(getTxtr == null && getTxt == null){
print("No GUIText or GUITexture exists on: " + transform.gameObject.name);
}

}

function Update () {

if(Screen.width != origResX || Screen.height != origResY){

origResX = Screen.width;
origResY = Screen.height;

if(getTxt != null){
resX = Screen.width;
resY = Screen.height;
txtX = transform.localScale.x;
txtY = transform.localScale.y;
transform.localScale.y = (transform.localScale.x*(resX/resY));
}
if(getTxtr != null){
resX = Screen.width;
resY = Screen.height;
txtrX = transform.guiTexture.texture.width;
txtrY = transform.guiTexture.texture.height;
transform.localScale.y = (transform.localScale.x*(resX/resY))/(txtrX/txtrY);
}
}

}







----------------------------------------­­­­­------------------------------------­-­-­-­-­-










Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D