Skip to content

Commit

Permalink
Added on/off button to switch models on and off.
Browse files Browse the repository at this point in the history
  • Loading branch information
realkushagrakhare authored and shreyasiyer14 committed Jul 26, 2017
1 parent e33c329 commit 574e887
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
Binary file modified .vs/AR6June/v15/.suo
Binary file not shown.
Binary file modified Assets/Scenes/VuforiaVariantScene.unity
Binary file not shown.
36 changes: 36 additions & 0 deletions Assets/Scripts/ImageTargetDetector.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;

public class ImageTargetDetector : MonoBehaviour,
ITrackableEventHandler
{
private TrackableBehaviour mTrackableBehaviour;
public Transform emptyTrans;
public GameObject currentsModels;
private GameObject target;
void Start()
{
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
target = gameObject;
if (mTrackableBehaviour)
{
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
}

public void OnTrackableStateChanged(
TrackableBehaviour.Status previousStatus,
TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED ||
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
// Play audio when target is found
currentsModels.transform.SetParent(target.transform);
currentsModels.transform.localPosition = Vector3.zero;
}
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/ImageTargetDetector.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/Switch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;

public class Switch : MonoBehaviour {
[SerializeField] private Button switchButton;
public bool isOn = false;

public void switchTrigger ()
{
if (!isOn)
{
isOn = true;
switchButton.transform.GetChild(0).gameObject.GetComponent<Text>().text = "OFF";
}
else if (isOn)
{
isOn = false;
switchButton.transform.GetChild(0).gameObject.GetComponent<Text>().text = "ON";
}
gameObject.SetActive(isOn);
}
}
12 changes: 12 additions & 0 deletions Assets/Switch.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 574e887

Please sign in to comment.