// Use this for initialization void Start() { m_planeManagerA = ARContentA.GetComponentInChildren <PlaneManager>(); m_planeManagerB = ARContentB.GetComponentInChildren <PlaneManager>(); m_anchorInputListenerBehaviourA = ARContentA.GetComponentInChildren <AnchorInputListenerBehaviour>(); m_anchorInputListenerBehaviourB = ARContentB.GetComponentInChildren <AnchorInputListenerBehaviour>(); m_planeFinderBehaviourA = ARContentA.GetComponentInChildren <PlaneFinderBehaviour>(); m_planeFinderBehaviourB = ARContentB.GetComponentInChildren <PlaneFinderBehaviour>(); m_contentPositioningBehaviourA = ARContentA.GetComponentInChildren <ContentPositioningBehaviour>(); m_contentPositioningBehaviourB = ARContentB.GetComponentInChildren <ContentPositioningBehaviour>(); m_anchorBehaviourA = ARContentA.GetComponentInChildren <AnchorBehaviour>(); m_anchorBehaviourB = ARContentB.GetComponentInChildren <AnchorBehaviour>(); m_productPlacementA = ARContentA.GetComponentInChildren <ProductPlacement>(); m_productPlacementB = ARContentB.GetComponentInChildren <ProductPlacement>(); m_touchHandlerA = ARContentA.GetComponentInChildren <TouchHandler>(); m_touchHandlerB = ARContentB.GetComponentInChildren <TouchHandler>(); TurnOffBehaviour(false); TurnOffBehaviour(true); TurnOffBehaviour(false); }
private void Start() { m_nowState = GameState.AddingMarkers; //TODO: Initalise the class members and event listeners. GameObject myPlaneFinder = GameObject.FindGameObjectWithTag("Plane"); myLineRend = GameObject.FindGameObjectWithTag("Lines"); myTextMesh = GameObject.FindGameObjectWithTag("Text"); m_ClearBttn = Button.FindObjectOfType <Button>(); m_AnchorInputLstnrBhvr = myPlaneFinder.GetComponent <AnchorInputListenerBehaviour>(); m_ContentPositioningBhvr = myPlaneFinder.GetComponent <ContentPositioningBehaviour>(); m_LineRenderer = myLineRend.GetComponent <LineRenderer>(); m_DistanceTextHldr = myTextMesh.GetComponent <TextMesh>(); m_ContentPositioningBhvr.OnContentPlaced.AddListener(SpawnNewMarker); m_ClearBttn.onClick.AddListener(Clear); Debug.Log("count=" + count); }
/* * private bool IsPointerOverGameObject(int fingerId) * { * EventSystem eventSystem = EventSystem.current; * return (eventSystem.IsPointerOverGameObject(fingerId) * && eventSystem.currentSelectedGameObject != null); * } */ // Use this for initialization void Start() { planeManager = transform.GetComponentInParent <PlaneManager>(); anchorInputListenerBehaviour = transform.GetComponent <AnchorInputListenerBehaviour>(); contentPositioningBehaviour = transform.GetComponent <ContentPositioningBehaviour>(); }
} //END Start //------------------------// private void CheckIfVuforiaComponentsAreConnected() //------------------------// { #if VUFORIA //Grab the VuforiaBehaviour component, if it doesn't exist then create it if( vuforiaBehaviour == null ) { if( GetComponent<VuforiaBehaviour>() == null ) { gameObject.AddComponent<VuforiaBehaviour>(); } vuforiaBehaviour = GetComponent<VuforiaBehaviour>(); } //Grab the DefaultInitializationError component, if it doesn't exist then create it if( defaultInitializationErrorHandler == null ) { if( GetComponent<DefaultInitializationErrorHandler>() == null ) { gameObject.AddComponent<DefaultInitializationErrorHandler>(); } defaultInitializationErrorHandler = GetComponent<DefaultInitializationErrorHandler>(); } //Grab the Plane finder child gameObject, if it doesn't exist then create it if( planeFinderGameObject == null ) { if( this.GetComponentInChildren<Transform>() == null ) { planeFinderGameObject = new GameObject( "Plane Finder" ); planeFinderGameObject.transform.parent = this.transform; } else { planeFinderGameObject = this.GetComponentInChildren<Transform>().gameObject; } } //If the scripts don't exist, grab them. If they're completely missing, then add them now if( anchorInputListenerBehaviour == null ) { if( this.GetComponentInChildren<AnchorInputListenerBehaviour>() != null ) { anchorInputListenerBehaviour = this.GetComponentInChildren<AnchorInputListenerBehaviour>(); } else { anchorInputListenerBehaviour = planeFinderGameObject.AddComponent<AnchorInputListenerBehaviour>(); } } if( planeFinderBehaviour == null ) { if( this.GetComponentInChildren<PlaneFinderBehaviour>() != null ) { planeFinderBehaviour = this.GetComponentInChildren<PlaneFinderBehaviour>(); } else { planeFinderBehaviour = planeFinderGameObject.AddComponent<PlaneFinderBehaviour>(); } } //Link the AnchorInputListener's OnInputRecieved event to the PlaneFinder HitTest if that link is missing if ( anchorInputListenerBehaviour.OnInputReceivedEvent != null && ( anchorInputListenerBehaviour.OnInputReceivedEvent.GetPersistentEventCount() == 0 || anchorInputListenerBehaviour.OnInputReceivedEvent.GetPersistentTarget( 0 ) != planeFinderBehaviour ) ) { //Add a Non-Persistent listener to this event. This will work but it won't be visible in the editor and won't be linked to the event after play mode ends anchorInputListenerBehaviour.OnInputReceivedEvent.AddListener( planeFinderBehaviour.PerformHitTest ); } //Link the planeFinderBehaviour's OnInteractiveHitTest and OnAutomaticHitTest to this script if that linkage is missing if( planeFinderBehaviour.OnAutomaticHitTest != null && ( planeFinderBehaviour.OnAutomaticHitTest.GetPersistentEventCount() == 0 || planeFinderBehaviour.OnAutomaticHitTest.GetPersistentTarget( 0 ) != this ) ) { planeFinderBehaviour.OnInteractiveHitTest.AddListener( OnInteractiveHitTest ); } if( planeFinderBehaviour.OnInteractiveHitTest != null && ( planeFinderBehaviour.OnInteractiveHitTest.GetPersistentEventCount() == 0 || planeFinderBehaviour.OnInteractiveHitTest.GetPersistentTarget( 0 ) != this ) ) { planeFinderBehaviour.OnAutomaticHitTest.AddListener( OnAutomaticHitTest ); } #endif } //END CheckIfVuforiaComponentsAreConnected