Pemanfaatan Augmented Reality Pada Aplikasi Home Seekers 3D Sebagai Strategi Marketing Penjualan Rumah

1

LoadSceneonClick.js
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadSceneOnClick : MonoBehaviour {
public void LoadByIndex(int sceneIndex)
{
SceneManager.LoadScene(sceneIndex);
}
}

showPanel.js
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class panelscript : MonoBehaviour {

public GameObject Panel;
public void showPanel()
{
Panel.gameObject.SetActive (true);
}
}

hidePanel.js
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

Universitas Sumatera Utara

2

public class panelscript : MonoBehaviour {
public GameObject Panel;
public void hidePanel()

{
Panel.gameObject.SetActive (false);
}
}

Motor.js
using UnityEngine;
using System.Collections;
public class Motor : MonoBehaviour
{
public float moveSpeed = 5.0f;
public float drag = 0.5f;
public float terminalRotationSpeed = 25.0f;
public VirtualJoystick moveJoystick;
private Rigidbody controller;
private Transform camTransform;
private void Start ()
{
controller = GetComponent ();
controller.maxAngularVelocity = terminalRotationSpeed;

controller.drag = drag;
camTransform = Camera.main.transform;
}
private void Update()
{
Vector3 dir = Vector3.zero;
dir.x = Input.GetAxis ("Horizontal");
dir.z = Input.GetAxis ("Vertical");
if (dir.magnitude > 1)
dir.Normalize ();
if (moveJoystick.InputDirection != Vector3.zero)

Universitas Sumatera Utara

3

{
dir = moveJoystick.InputDirection;
}
Vector3 rotatedDir = camTransform.TransformDirection (dir);

rotatedDir = new Vector3 (rotatedDir.x, 0, rotatedDir.z);
rotatedDir = rotatedDir.normalized * dir.magnitude;
controller.AddForce (rotatedDir * moveSpeed);
}
}

CameraMotor.js
using UnityEngine;
using System.Collections;
public class CameraMotor : MonoBehaviour
{
public Transform lookAt;
private Vector3 desiredPosition;
private Vector3 offset;
private float smoothSpeed = 7.5f;
private float distance = 5.0f;
private float yOffset = 3.5f;
private void Start()
{
offset = new Vector3 (0, yOffset, -1f * distance);

}
private void Update()
{
if (Input.GetKeyDown (KeyCode.LeftArrow))
SlideCamera (true);
else if (Input.GetKeyDown (KeyCode.RightArrow))
SlideCamera (false);
desiredPosition = lookAt.position + offset;
transform.position = Vector3.Lerp (transform.position,
desiredPosition, smoothSpeed * Time.deltaTime);
transform.LookAt (lookAt.position + Vector3.up);

Universitas Sumatera Utara

4

}
private void SlideCamera(bool left)
{
if (left)

offset = Quaternion.Euler (0, 90, 0) * offset;
else
offset = Quaternion.Euler (0, -90, 0) * offset;
}
}

VirtualJoystick.js
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections;
public

class

VirtualJoystick

:

MonoBehaviour,


IDragHandler,

IPointerUpHandler, IPointerDownHandler
{
private Image bgImg;
private Image joystickImg;
public Vector3 InputDirection { set; get;}
private void Start()
{
bgImg = GetComponent ();
joystickImg = transform.GetChild(0).GetComponent ();
InputDirection = Vector3.zero;
}
public virtual void OnDrag(PointerEventData ped)
{
Vector2 pos = Vector2.zero;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle
(bgImg.rectTransform,
ped.position,

ped.pressEventCamera,
out pos))
{
pos.x = (pos.x / bgImg.rectTransform.sizeDelta.x);

Universitas Sumatera Utara

5

pos.y = (pos.y / bgImg.rectTransform.sizeDelta.y);
float x = (bgImg.rectTransform.pivot.x == 1) ? pos.x * 2
+ 1 : pos.x * 2 - 1;
float y = (bgImg.rectTransform.pivot.y == 1) ? pos.y * 2
+ 1 : pos.y * 2 - 1;
InputDirection = new Vector3 (x, 0, y);
InputDirection

=

(InputDirection.magnitude


>

1)

?

InputDirection.normalized : InputDirection;
joystickImg.rectTransform.anchoredPosition =
new Vector3
(InputDirection.x*(bgImg.rectTransform.sizeDelta.x / 3)
, InputDirection.z * (bgImg.rectTransform.sizeDelta.y
/ 3));
}
}
public virtual void OnPointerDown(PointerEventData ped)
{
OnDrag (ped);
}
public virtual void OnPointerUp(PointerEventData ped)

{
InputDirection = Vector3.zero;
joystickImg.rectTransform.anchoredPosition = Vector3.zero;
}
}

QuitonClick.js
using System.Collections;
using UnityEngine;
public class QuitOnClick : MonoBehaviour {
public void Quit ()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false ;

Universitas Sumatera Utara

6

#else

Application.Quit();
#endif
}
}

Universitas Sumatera Utara

Universitas Sumatera Utara

Universitas Sumatera Utara

Universitas Sumatera Utara

Universitas Sumatera Utara

Universitas Sumatera Utara