Europart Showcase Game

Last Updated On – 7/JAN/2019
Development Duration – September 2018 to December 2018
Team – 5Force Team of J&F projects Gmbh
My Role – Team Lead and Game Developer
Current Status – iOS Pre-Alpha Stage
Project Short Brief – Europart Gmbh, a German major automotive spare parts manufacturer and now one of the biggest trucks and buses workshop operators, needed an iPAD game-app for showcasing all their products in 3D world space with interactivity. We created a fully functional and server-linked 3D game where live assets are showcased and interacted with.
Technologies Used:
1. Unity 3D Game Engine
2. Adobe Photoshop
3. Visual Studio for C-Sharp Coding.
4. XCode for iOS Game Authoring.

Europart Truck World Gameplay Recording

Scripts

1. Main Touch Camera Controller

This controller manages the state of main camera and its animation controller’s states.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using DG.Tweening;
using Talkd.Game;
using UnityEngine.UI;
using Talkd.Game.EuroPart.Managers;
public class CameraTouchMainTruck : MonoBehaviour {
public float rotateSpeed = 20.0f;
public float angleMax = 20.0f;
public float angleMin = 20.0f;
public Transform target;
float fp;
float lp;
private Vector3 initialVector = Vector3.forward;
Vector3 MainCameraTransPos;
Vector3 MainCameraTransRot;
Vector3 PosAfterTouchRemove;
Vector3 RotAfterTouchRemove;
Vector3 HalfDist;
public static CameraTouchMainTruck cammain;
private float _currentDeltaTime;
private Quaternion _mainCamOriginalRot;
public bool _snapCamPos = false;
private bool _snapCamToRight = true;
private float _t = 0f;
private float _moveSpeed = 0f;
public AnimationCurve curve;
private Vector3 _camPosCache;
private Vector3 _camRotCache;
private Quaternion _camQuatCache;
public float duration = 2.0F;
private float factor;
private float startTime;
public float perspectiveZoomSpeed = 0.5f;
public float distance = 5.0f;
public float xSpeed = 80.0f;
public float ySpeed = 80.0f;
public float yMinLimit = -20f;
public float yMaxLimit = 80f;
public float distanceMin = .5f;
public float distanceMax = 15f;
public GameObject uicamera;
public GameObject mainCamera;
public static CameraState currentCameraState;
public Transform targetObjectfortween;
public Transform moveableObject;
public Transform parentpos;
public Transform CameraMain;
public GameObject lastPos;
public GameObject lastRot;
float x;
float y;
private bool _isFirstTime = true;
// Use this for initialization
void Start() {
cammain = this;
currentCameraState = CameraState.Idle;
MainCameraTransPos = transform.localPosition;
MainCameraTransRot = transform.localEulerAngles;
_mainCamOriginalRot = transform.localRotation;
if(target != null) {
initialVector = transform.position - target.position;
initialVector.y = 0;
}
startTime = Time.time;
}
public enum CameraState {
Idle,
Moving
}
// Update is called once per frame
void Update() {
if(DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene){
if (_snapCamPos)
{
//transform.LookAt(AnimationController.ac.followcubelist[AnimationController.hotspotvalue].transform);
}
_currentDeltaTime = Time.deltaTime;
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)
{
if (EventSystem.current.IsPointerOverGameObject())
{
//Debug.Log("Clicked on the UI");
if (currentCameraState == CameraState.Idle)
{
}
if (currentCameraState == CameraState.Moving)
{
}
}
else
{
if (currentCameraState == CameraState.Idle || currentCameraState == CameraState.Moving)
{
//PanelSlider.instance._gameCameradisable.enabled = false;
Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit raycastHit;
if (Physics.Raycast(raycast, out raycastHit))
{
//Debug.Log("Something Hit");
if (raycastHit.collider.tag == "06_AssetW")
{
Debug.Log("clicked on 06_AssetW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 64;
AnimationController.hotspotvalue = 64;
AnimationController.valueforhotspotfocus = 6;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[6].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "13_AssetsW")
{
Debug.Log("clicked on 13_AssetsW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 65;
AnimationController.hotspotvalue = 65;
AnimationController.valueforhotspotfocus = 7;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[7].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "21_AssetsW")
{
Debug.Log("clicked on 21_AssetsW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 66;
AnimationController.hotspotvalue = 66;
AnimationController.valueforhotspotfocus = 8;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[8].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "11_Assets")
{
Debug.Log("clicked on 11_Assets");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 67;
AnimationController.hotspotvalue = 67;
AnimationController.valueforhotspotfocus = 9;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[9].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "01_Asset")
{
Debug.Log("clicked on 01_Asset");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 68;
AnimationController.hotspotvalue = 68;
AnimationController.valueforhotspotfocus = 10;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[10].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "10_AssetsW")
{
Debug.Log("clicked on 10_AssetsW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 69;
AnimationController.hotspotvalue = 69;
AnimationController.valueforhotspotfocus = 11;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[11].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "09_AssetW")
{
Debug.Log("clicked on 09_AssetW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 70;
AnimationController.hotspotvalue = 70;
AnimationController.valueforhotspotfocus = 12;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[12].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "39_Tool box")
{
Debug.Log("clicked on 39_Tool box");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 39;
AnimationController.hotspotvalue = 39;
AnimationController.valueforhotspotfocus = 13;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[13].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "53_StopBlocks(Chocks)")
{
Debug.Log("clicked on 53_StopBlocks(Chocks)");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 53;
AnimationController.hotspotvalue = 53;
AnimationController.valueforhotspotfocus = 14;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[14].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "52_Universal LED rear lamps")
{
Debug.Log("clicked on 52_Universal LED rear lamps");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 52;
AnimationController.hotspotvalue = 52;
AnimationController.valueforhotspotfocus = 15;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[15].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "58_OUTLINE MARKER LIGHT")
{
Debug.Log("clicked on 58_OUTLINE MARKER LIGHT");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 58;
AnimationController.hotspotvalue = 58;
AnimationController.valueforhotspotfocus = 16;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[16].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "55_SIDE MARKING LIGHTS001")
{
Debug.Log("clicked on 55_SIDE MARKING LIGHTS001");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 55;
AnimationController.hotspotvalue = 55;
AnimationController.valueforhotspotfocus = 17;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[17].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "40_Mud flap012")
{
Debug.Log("clicked on 540_Mud flap0121");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 71;
AnimationController.hotspotvalue = 71;
AnimationController.valueforhotspotfocus = 18;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[18].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "41_Rear skirt")
{
Debug.Log("clicked on 41_Rear skirt");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.isnewasset = true;
AnimationController.ac.ValueGet = 41;
AnimationController.hotspotvalue = 41;
AnimationController.valueforhotspotfocus = 19;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[19].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
}
}
if (currentCameraState == CameraState.Moving)
{
PanelSlider.instance.mainGameData._gameCameradisable.enabled = false;
//Debug.Log("checking");
Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit raycastHit;
if (Physics.Raycast(raycast, out raycastHit))
{
//Debug.Log("Something Hit");
if (raycastHit.collider.tag == "start battery")
{
Debug.Log("clicked on battery");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
transform.DOMove(AnimationController.ac.hotspotlist[1].transform.position, 3f);
AnimationController.ac.Hotspotcheck();
AnimationController.ac.ValueGet = 31;
AnimationController.hotspotvalue = 31;
AnimationController.valueforhotspotfocus = 1;
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "brake disc")
{
Debug.Log("clicked on brake disc");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.ValueGet = 11;
AnimationController.hotspotvalue = 11;
AnimationController.valueforhotspotfocus = 0;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[0].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "working spotlight")
{
Debug.Log("clicked on working spotlight");
AnimationController.ac.ValueGet = 32;
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.hotspotvalue = 32;
AnimationController.valueforhotspotfocus = 2;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[2].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "airfilter")
{
Debug.Log("clicked on airfilter");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.ValueGet = 29;
AnimationController.hotspotvalue = 29;
AnimationController.valueforhotspotfocus = 3;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[3].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "enginecooler")
{
Debug.Log("clicked on enginecooler");
AnimationController.ac.ValueGet = 19;
AnimationController.hotspotvalue = 19;
AnimationController.valueforhotspotfocus = 4;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[4].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "turbocharger")
{
Debug.Log("clicked on turbocharger");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
AnimationController.ac.ValueGet = 22;
AnimationController.hotspotvalue = 22;
AnimationController.valueforhotspotfocus = 5;
AnimationController.ac.Hotspotcheck();
transform.DOMove(AnimationController.ac.hotspotlist[5].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
}
}
}
}
if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
Touch touchZero = Input.GetTouch(0);
Touch touchOne = Input.GetTouch(1);
Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;
float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
float touchDeltaMag = (touchZero.position - touchOne.position).magnitude;
float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;
Camera.main.fieldOfView += deltaMagnitudeDiff * perspectiveZoomSpeed;
Camera.main.fieldOfView = Mathf.Clamp(Camera.main.fieldOfView, 40f, 60f);
}
else if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.currentCameraState = AnimationController.CameraState.Moving;
AnimationController.ac.ischeckingforidlestate = false;
}
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.ischeckingforidlestate = false;
}
currentCameraState = CameraState.Moving;
uicamera.GetComponent<Camera>().enabled = false;
x += Input.GetTouch(0).deltaPosition.x * Time.deltaTime;
y -= Input.GetTouch(0).deltaPosition.y * Time.deltaTime;
y = ClampAngle(y, yMinLimit, yMaxLimit);
Quaternion rotation;
if (_isFirstTime)
{
//rotation = Quaternion.Euler(0f, 0f, 0f);
_isFirstTime = false;
return;
}
else
{
rotation = Quaternion.Euler(y, x, 0f);
}
Vector3 negDistance = new Vector3(0f, 0f, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
}
else if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
PanelSlider.instance.mainGameData._gameCameradisable.enabled = true;
lastPos.transform.position = gameObject.transform.position;
lastRot.transform.rotation = gameObject.transform.rotation;
if (DataManager.instance.webDataSO.talkdGameData.isLoggedIn)
{
PanelSlider.instance.gameObject.GetComponent<Image>().enabled = true;
PanelSlider.instance.commonDataValues.arrowImage.GetComponent<Image>().enabled = true;
}
}
}
if(DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene){
if (_snapCamPos)
{
//transform.LookAt(AnimationController.ac.followcubelist[AnimationController.hotspotvalue].transform);
}
_currentDeltaTime = Time.deltaTime;
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)
{
if (EventSystem.current.IsPointerOverGameObject())
{
//Debug.Log("Clicked on the UI");
if (currentCameraState == CameraState.Idle)
{
}
if (currentCameraState == CameraState.Moving)
{
}
}
else
{
//PanelSlider.instance._gameCameradisable.enabled = false;
Ray raycast = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit raycastHit;
if (Physics.Raycast(raycast, out raycastHit))
{
//Debug.Log("Something Hit");
if (raycastHit.collider.tag == "06_AssetW")
{
Debug.Log("clicked on 06_AssetW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 64;
BusUIController.hotspotvalue = 64;
BusUIController.valueforhotspotfocus = 6;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[6].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "13_AssetsW")
{
Debug.Log("clicked on 13_AssetsW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 65;
BusUIController.hotspotvalue = 65;
BusUIController.valueforhotspotfocus = 7;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[7].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "21_AssetsW")
{
Debug.Log("clicked on 21_AssetsW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.isnewasset = true;
BusUIController.instance.ValueGet = 66;
BusUIController.hotspotvalue = 66;
BusUIController.valueforhotspotfocus = 8;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[8].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "11_Assets")
{
Debug.Log("clicked on 11_Assets");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.isnewasset = true;
BusUIController.instance.ValueGet = 67;
BusUIController.hotspotvalue = 67;
BusUIController.valueforhotspotfocus = 9;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[9].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "01_Asset")
{
Debug.Log("clicked on 01_Asset");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.isnewasset = true;
BusUIController.instance.ValueGet = 68;
BusUIController.hotspotvalue = 68;
BusUIController.valueforhotspotfocus = 10;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[10].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "10_AssetsW")
{
Debug.Log("clicked on 10_AssetsW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.isnewasset = true;
BusUIController.instance.ValueGet = 69;
BusUIController.hotspotvalue = 69;
BusUIController.valueforhotspotfocus = 11;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[11].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "09_AssetW")
{
Debug.Log("clicked on 09_AssetW");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.isnewasset = true;
BusUIController.instance.ValueGet = 70;
BusUIController.hotspotvalue = 70;
BusUIController.valueforhotspotfocus = 12;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[12].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "53_StopBlocks(Chocks)")
{
Debug.Log("clicked on 53_StopBlocks(Chocks)");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.isnewasset = true;
BusUIController.instance.ValueGet = 53;
BusUIController.hotspotvalue = 53;
BusUIController.valueforhotspotfocus = 14;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[14].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "52_Universal LED rear lamps")
{
Debug.Log("clicked on 52_Universal LED rear lamps");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.isnewasset = true;
BusUIController.instance.ValueGet = 52;
BusUIController.hotspotvalue = 52;
BusUIController.valueforhotspotfocus = 15;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[15].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
}
PanelSlider.instance.mainGameData._gameCameradisable.enabled = false;
if (Physics.Raycast(raycast, out raycastHit))
{
Debug.Log("Something Hit");
if (raycastHit.collider.tag == "start battery")
{
Debug.Log("clicked on battery");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
transform.DOMove(BusUIController.instance.hotspotlist[1].transform.position, 3f);
BusUIController.instance.Hotspotcheck();
BusUIController.instance.ValueGet = 31;
BusUIController.hotspotvalue = 31;
BusUIController.valueforhotspotfocus = 1;
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "brake disc")
{
Debug.Log("clicked on brake disc");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 11;
BusUIController.hotspotvalue = 11;
BusUIController.valueforhotspotfocus = 0;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[0].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "enginecooler")
{
Debug.Log("clicked on enginecooler");
BusUIController.instance.ValueGet = 19;
BusUIController.hotspotvalue = 19;
BusUIController.valueforhotspotfocus = 4;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[4].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if(raycastHit.collider.tag == "30_Interior filter")
{
Debug.Log("clicked on turbocharger");
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 30;
BusUIController.hotspotvalue = 30;
BusUIController.valueforhotspotfocus = 16;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[16].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "28_Fuel filter")
{
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 28;
BusUIController.hotspotvalue = 28;
BusUIController.valueforhotspotfocus = 17;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[17].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "18_Water pump")
{
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 18;
BusUIController.hotspotvalue = 18;
BusUIController.valueforhotspotfocus = 18;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[18].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "45_Wiper blade")
{
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 45;
BusUIController.hotspotvalue = 45;
BusUIController.valueforhotspotfocus = 19;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[19].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "04_Steering rod")
{
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 4;
BusUIController.hotspotvalue = 4;
BusUIController.valueforhotspotfocus = 20;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[20].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "01_Air spring bellows001")
{
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 1;
BusUIController.hotspotvalue = 1;
BusUIController.valueforhotspotfocus = 21;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[21].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
if (raycastHit.collider.tag == "15_Brake drum002")
{
gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
BusUIController.instance.ValueGet = 15;
BusUIController.hotspotvalue = 15;
BusUIController.valueforhotspotfocus = 22;
BusUIController.instance.Hotspotcheck();
transform.DOMove(BusUIController.instance.hotspotlist[22].transform.position, 3f);
StartCoroutine(Waitforfocus());
}
}
}
}
if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
Touch touchZero = Input.GetTouch(0);
Touch touchOne = Input.GetTouch(1);
Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;
float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
float touchDeltaMag = (touchZero.position - touchOne.position).magnitude;
float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;
Camera.main.fieldOfView += deltaMagnitudeDiff * perspectiveZoomSpeed;
Camera.main.fieldOfView = Mathf.Clamp(Camera.main.fieldOfView, 40f, 60f);
}
else if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.currentCameraState = AnimationController.CameraState.Moving;
AnimationController.ac.ischeckingforidlestate = false;
}
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.ischeckingforidlestate = false;
}
currentCameraState = CameraState.Moving;
uicamera.GetComponent<Camera>().enabled = false;
x += Input.GetTouch(0).deltaPosition.x * Time.deltaTime;
y -= Input.GetTouch(0).deltaPosition.y * Time.deltaTime;
y = ClampAngle(y, yMinLimit, yMaxLimit);
Quaternion rotation;
if (_isFirstTime)
{
//rotation = Quaternion.Euler(0f, 0f, 0f);
_isFirstTime = false;
return;
}
else
{
rotation = Quaternion.Euler(y, x, 0f);
}
Vector3 negDistance = new Vector3(0f, 0f, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
}
else if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
PanelSlider.instance.mainGameData._gameCameradisable.enabled = true;
lastPos.transform.position = gameObject.transform.position;
lastRot.transform.rotation = gameObject.transform.rotation;
if (DataManager.instance.webDataSO.talkdGameData.isLoggedIn)
{
PanelSlider.instance.gameObject.GetComponent<Image>().enabled = true;
PanelSlider.instance.commonDataValues.arrowImage.GetComponent<Image>().enabled = true;
}
}
}
}
public void MoveTweenActive() {
if(currentCameraState == CameraState.Idle) {
transform.DOMove(targetObjectfortween.position, 3f);
}
if(currentCameraState == CameraState.Moving) {
moveableObject = AnimationController.ac.Moveablegameobjectlist[AnimationController.hotspotvalue].transform;
uicamera.GetComponent<Camera>().enabled = true;
transform.DOMove(moveableObject.position, 3f);
_snapCamPos = true;
StartCoroutine(Waitforscriptoff());
}
}
IEnumerator Waitforscriptoff() {
yield return new WaitForSeconds(2.1f);
transform.GetComponent<CameraTouchMainTruck>().enabled = false;
}
public static float ClampAngle(float angle, float min, float max) {
if(angle < -360F)
angle += 360F;
if(angle > 360F)
angle -= 360F;
return Mathf.Clamp(angle, min, max);
}
IEnumerator Waitforfocus() {
yield return new WaitForSeconds(.7f);
if(DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene){
AnimationController.ac.ischeckingforhotsopt = true;
}
if(DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene){
BusUIController.instance.ischeckingforhotsopt = true;
}
}
}

2. Camera Smooth Utility

Used to maintain smooth and in-bound movement of the showcase camera.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
/*===============================================================
Product:    EuroPart Workshop
Company:    Talkd
Date:       06-06-2018 15:29
Copyright:  Copyright @ Talkd 2018-2019
================================================================*/
namespace Talkd.Game {
public class CameraSmooth : MonoBehaviour {
#region Public Variables.
public Transform target;
public float distance = 5.0f;
public float xSpeed = 80.0f;
public float ySpeed = 80.0f;
public float yMinLimit = -20f;
public float yMaxLimit = 80f;
public float distanceMin = .5f;
public float distanceMax = 15f;
public Transform Object1;
#endregion
#region Private Variables.
private new Rigidbody rigidbody;
Transform lastPos;
float x = 0.0f;
float y = 0.0f;
#endregion
#region Unity Methods.
// Use this for initialization
void Start () {
DOTween.Init(true, true, LogBehaviour.Verbose).SetCapacity(200, 10);
Vector3 angles = transform.eulerAngles;
x = angles.y;
y = angles.x;
rigidbody = GetComponent<Rigidbody>();
// Make the rigid body not change rotation
if (rigidbody != null)
{
rigidbody.freezeRotation = true;
}
}
void LateUpdate()
{
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
//Ray ray = Camera.main.ScreenPointToRay (Input.GetTouch (0).position);
////Debug.Log(ray.origin);
//RaycastHit hit;
//if (Physics.Raycast (ray, out hit)) {
//	//Debug.Log("Ray Catsed");
//	if (hit.collider != null && hit.collider.name == "Quad") {
//		Debug.Log ("enter valur for the hotspot");
//                 AnimationController.ac.HotSpotPoints.SetActive(false);
//                 //rotateSpeed = 0f;
//                 //					isTouchableArea = true;
//                 gameObject.GetComponent<CameraTouchMainTruck>().enabled = false;
//	}
x += Input.GetTouch(0).deltaPosition.x * Time.deltaTime;
//y -= Input.GetTouch(0).deltaPosition.y * ySpeed * 0.01f;
//y = ClampAngle(y, yMinLimit, yMaxLimit);
Quaternion rotation = Quaternion.Euler(y, x, 0);
//distance = Mathf.Clamp(distance - Input.GetTouch(0).deltaPosition.x * 5, distanceMin, distanceMax);
//Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit hit;
if (Physics.Linecast(target.position, transform.position, out hit))
{
distance -= hit.distance;
}
Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
Vector3 position = rotation * negDistance + target.position;
transform.rotation = rotation;
transform.position = position;
}
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
//Debug.Log("Ray Catsed");
if (hit.collider != null && hit.collider.tag == "Quad")
{
//Debug.Log("enter valur for the hotspot");
ClickAsset();
}
}
}
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
lastPos = transform;
//transform.DOMove(new Vector3(15f, 5f, 0f), 1f, false);
}
}
#endregion
#region Custom Methods.
public static float ClampAngle(float angle, float min, float max)
{
if (angle < -360F)
angle += 360F;
if (angle > 360F)
angle -= 360F;
return Mathf.Clamp(angle, min, max);
}
public void ClickAsset()
{
//Debug.Log("enter");
transform.DOMove(Object1.position, 2f, false);
transform.DORotate(Object1.eulerAngles, 1f);
}       
#endregion
}
}

3. Canvas Switch Controller

This controller is used to dynamically switch between main menu and assets menu in the world UI space.

using System.Collections;
using System.Collections.Generic;
using Talkd.Game.EuroPart.Managers;
using UnityEngine;
using UnityEngine.UI;
public class CanvasSwitch : MonoBehaviour {
public GameObject[] MenuCanvas;
public static CanvasSwitch canvasswitch;
bool ischeckingforpanel = false;
// Use this for initialization
void Start() {
canvasswitch = this;
for(int i = 0; i < MenuCanvas.Length; i++) {
MenuCanvas[i].SetActive(false);
}
}
IEnumerator WaitforColorChange() {
yield return new WaitForSeconds(.001f);
MainMenuButton.mb.MainMenuButtons[3].transform.GetChild(0).GetComponent<Text>().color = Color.black;
}
public void SearchMenu(int i) {
if(i == 1) {
MenuCanvas[2].SetActive(false);
if(!MenuCanvas[0].activeInHierarchy) {
//Debug.Log("enter");
MenuCanvas[0].SetActive(true);
CameraTouchMainTruck.cammain.enabled = false;
if(DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene){
AnimationController.ac.HotSpotPoints.SetActive(false);
AnimationController.ac.maingameobject.SetActive(false);
}
else if(DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(false);
BusUIController.instance.maingameobject.SetActive(false);
}
} else {
//Debug.Log("enter1");
MenuCanvas[0].SetActive(false);
CameraTouchMainTruck.cammain.enabled = true;
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.ac.HotSpotPoints.SetActive(true);
AnimationController.ac.maingameobject.SetActive(true);
}
else if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(true);
BusUIController.instance.maingameobject.SetActive(true);
}
}
MenuCanvas[1].SetActive(false);
} else if(i == 2) {
MenuCanvas[0].SetActive(false);
MenuCanvas[1].SetActive(false);
MainMenuButton.mb.ischeckingforbool = true;
MainMenuButton.mb.MainMenuButtons[3].transform.GetChild(0).GetComponent<Text>().color = Color.white;
StartCoroutine(WaitforColorChange());
if(!MenuCanvas[2].activeInHierarchy) {
//Debug.Log("enter");
CameraTouchMainTruck.cammain.enabled = false;
MenuCanvas[2].SetActive(true);
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.ac.HotSpotPoints.SetActive(false);
AnimationController.ac.maingameobject.SetActive(false);
}
else if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(false);
BusUIController.instance.maingameobject.SetActive(false);
}
} else {
//Debug.Log("enter1");
MenuCanvas[2].SetActive(false);
CameraTouchMainTruck.cammain.enabled = true;
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.ac.HotSpotPoints.SetActive(true);
AnimationController.ac.maingameobject.SetActive(true);
}
else if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(true);
BusUIController.instance.maingameobject.SetActive(true);
}
}
} else if(i == 3) {
//Debug.Log (MenuCanvas [1].activeInHierarchy);
MenuCanvas[0].SetActive(false);
MenuCanvas[2].SetActive(false);
if(!MenuCanvas[1].activeInHierarchy) {
//Debug.Log ("enter");
CameraTouchMainTruck.cammain.enabled = false;
MenuCanvas[1].SetActive(true);
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.ac.HotSpotPoints.SetActive(false);
AnimationController.ac.maingameobject.SetActive(false);
}
else if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(false);
BusUIController.instance.maingameobject.SetActive(false);
}
} else {
//Debug.Log ("enter1");
MenuCanvas[1].SetActive(false);
CameraTouchMainTruck.cammain.enabled = true;
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.ac.HotSpotPoints.SetActive(true);
AnimationController.ac.maingameobject.SetActive(true);
}
else if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(true);
BusUIController.instance.maingameobject.SetActive(true);
}
}
} else if(i == 4) {
MenuCanvas[0].SetActive(false);
MenuCanvas[1].SetActive(false);
MainMenuButton.mb.ischeckingforbool = false;
MainMenuButton.mb.MainMenuButtons[3].transform.GetChild(0).GetComponent<Text>().color = Color.white;
StartCoroutine(WaitforColorChange());
//for (int j = 0; j < MainMenuButton.mb.SubPartMenu.Length; j++) {
//  MainMenuButton.mb.SubPartMenu [j].SetActive (false);
//}
//for (int j = 0; j < MainMenuButton.mb.MainPartMenu.Length; j++) {
//  MainMenuButton.mb.MainPartMenu [j].SetActive (false);
//}
if(!MenuCanvas[2].activeInHierarchy) {
//Debug.Log("enter");
CameraTouchMainTruck.cammain.enabled = false;
MenuCanvas[2].SetActive(true);
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.ac.HotSpotPoints.SetActive(false);
}
else if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(false);
}
} else {
//Debug.Log("enter1");
MenuCanvas[2].SetActive(false);
CameraTouchMainTruck.cammain.enabled = false;
if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.TruckGameScene)
{
AnimationController.ac.HotSpotPoints.SetActive(false);
}
else if (DataManager.instance.webDataSO.talkdGameData.currentSceneType == Talkd.Game.SalesTool.API.Scriptables.SceneType.BusGameScene)
{
BusUIController.instance.HotSpotPoints.SetActive(false);
}
}
}
}
public void ClickForLanguageButton() {
MenuCanvas[0].SetActive(false);
MenuCanvas[1].SetActive(false);
MainMenuButton.mb.MainMenuButtons[3].transform.GetChild(0).GetComponent<Text>().color = Color.white;
StartCoroutine(WaitforColorChange());
//for (int j = 0; j < MainMenuButton.mb.SubPartMenu.Length; j++) {
//	MainMenuButton.mb.SubPartMenu [j].SetActive (false);
//}
//for (int j = 0; j < MainMenuButton.mb.MainPartMenu.Length; j++) {
//	MainMenuButton.mb.MainPartMenu [j].SetActive (false);
//}
if(!MenuCanvas[2].activeInHierarchy) {
//Debug.Log("enter");
CameraTouchMainTruck.cammain.enabled = false;
MenuCanvas[2].SetActive(true);
//AnimationController.ac.HotSpotPoints.SetActive(false);
} else {
if(ischeckingforpanel) {
//Debug.Log("enter1");
MenuCanvas[2].SetActive(false);
CameraTouchMainTruck.cammain.enabled = true;
//AnimationController.ac.HotSpotPoints.SetActive(true);
}
}
}
public void ToggleGameObject(GameObject target) {
target.SetActive(!target.activeInHierarchy);
}
}