using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ARMenu : MonoBehaviour {
public GUISkin guiSkin;
private float guiRatio;
private float sWidth;
private Vector3 GUIsF;
public GameObject sphere;
public float kecepatanRotasi = 50f;
bool statusRotasi = false;
public Texture navAtas, navBawah, navKanan, navKiri;
void Awake(){
sWidth = Screen.width;
guiRatio = sWidth / 1920;
GUIsF = new Vector3 (guiRatio, guiRatio, 1);
}
void OnGUI(){
GUI.skin = guiSkin;
//Letakkan fungsi disini
CaptureRotasi();
Navigasi ();
}
void CaptureRotasi(){
GUI.matrix = Matrix4x4.TRS (new Vector3 (Screen.width - 258 * GUIsF.x, GUIsF.y, 0), Quaternion.identity, GUIsF);
if (statusRotasi == false) {
if (GUI.Button (new Rect (-208, 10, 238, 59), "Rotasi")) {
statusRotasi = true;
}
} else {
if (GUI.Button (new Rect (-208, 10, 238, 59), "Rotasi")) {
statusRotasi = false;
}
}
//Disini untuk meletakkan fungsi tombol capture
if (GUI.Button (new Rect (-458, 10, 238, 59), "Capture")) {
Application.CaptureScreenshot ("C:/Hasil Capture/Capture.png");
}
if (GUI.Button(new Rect(40,10,208,59),"Keluar")) {
Application.Quit ();
}
}
void Update(){
if (statusRotasi == true) {
sphere.transform.Rotate (Vector3.up, kecepatanRotasi * Time.deltaTime);
}
}
void Navigasi(){
GUI.matrix = Matrix4x4.TRS (new Vector3 (Screen.width - 258 * GUIsF.x, Screen.height - 89 * GUIsF.y, 0), Quaternion.identity, GUIsF);
if (GUI.RepeatButton (new Rect (-30, 0, 80, 80), navKiri)) {
//Navigasi kiri
sphere.transform.Translate (Vector3.left *kecepatanRotasi *Time.deltaTime);
}
if (GUI.RepeatButton (new Rect (60, 0, 80, 80), navBawah)) {
//Navigasi bawah
sphere.transform.Translate (Vector3.back *kecepatanRotasi *Time.deltaTime);
}
if (GUI.RepeatButton (new Rect (60, -90, 80, 80), navAtas)) {
//Navigasi atas
sphere.transform.Translate (Vector3.forward *kecepatanRotasi *Time.deltaTime);
}
if (GUI.RepeatButton (new Rect (150, 0, 80, 80), navKanan)) {
//Navigasi kanan
sphere.transform.Translate (Vector3.right *kecepatanRotasi *Time.deltaTime);
}
}
}