-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added on/off button to switch models on and off.
- Loading branch information
1 parent
e33c329
commit 574e887
Showing
6 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.