- Sort Posts
- 5 replies
- Last post
What does the 'Turn Off Behaviour' script do?
What does the 'Turn Off Behaviour' script do?
Hey Jim,
Sorry for the delayed response here, I was making sure it was okay to share the source for this. The source is the following:
/*============================================================================== Copyright (c) 2010-2014 Qualcomm Connected Experiences, Inc. All Rights Reserved. Confidential and Proprietary - Protected under copyright and other laws. ==============================================================================*/ using UnityEngine; namespace Vuforia { /// <summary> /// A utility behaviour to disable rendering of a game object at run time. /// </summary> public class TurnOffBehaviour : TurnOffAbstractBehaviour { #region UNITY_MONOBEHAVIOUR_METHODS void Awake() { if (VuforiaRuntimeUtilities.IsVuforiaEnabled()) { // We remove the mesh components at run-time only, but keep them for // visualization when running in the editor: MeshRenderer targetMeshRenderer = this.GetComponent<MeshRenderer>(); Destroy(targetMeshRenderer); MeshFilter targetMesh = this.GetComponent<MeshFilter>(); Destroy(targetMesh); } } #endregion // UNITY_MONOBEHAVIOUR_METHODS } }
The reasoning behind this script is to remove the Image Target texture from the scene. This is shown in the Unity scene when the app isn't running as a visual aid so you can more easily set up how your augmentation will look in relation to the target, but when you actually run the app you don't want to render this as it is ultimately a representation of the target in the real world that you'll be detecting with your camera to augment.
Let me know if you have any additional questions about this.
Thanks,
-Vuforia Support
What does the 'Turn Off Behaviour' script do?
HI Strasza
Thanks so much for the reply.
Would it be possible to get the source in this instance? I imagine its fairly simple to recreate in my custom handler script but would like to make sure I'm not missing anything.
And so I'm clear about the reasoning behind having this functionality. Is it for performance reasons and so that its not visible when viewing other game objects using image targets?
Thanks again
Jim
Thanks very much Strasza, its really useful to have.