public void LoadNow() { Debug.Log("filename " + filename); f = Resources.Load(filename); Transform oldChild = target.GetChild(0); GameObject o = Instantiate(f, oldChild.position, oldChild.rotation, target) as GameObject; Destroy(oldChild.gameObject); o.transform.SetParent(target); o.transform.SetAsFirstSibling(); changeColor.InitColors(); changeColor.EndMenu(); changeColor.ChangeSelectedObject(null, o); inputHandler.touchObject = o; TrackableBehaviour.Status status = target.gameObject.GetComponent <ImageTargetBehaviour>().CurrentStatus; if (!(status == TrackableBehaviour.Status.DETECTED || status == TrackableBehaviour.Status.TRACKED || status == TrackableBehaviour.Status.EXTENDED_TRACKED)) { foreach (MeshRenderer rend in o.GetComponentsInChildren <MeshRenderer>()) { rend.enabled = false; } } iface.SetActive(false); }
void Update() { RaycastHit hit; Ray cameraGaze = new Ray(cameraTransform.position, cameraTransform.forward); Physics.Raycast(cameraGaze, out hit, Mathf.Infinity); Focused = hit.collider && (hit.collider.gameObject == gameObject); if (mTriggered) { return; } UpdateMaterials(Focused); bool startAction = false || Input.GetMouseButtonUp(0); if (Focused) { // Update the "focused state" time mFocusedTime += Time.deltaTime; if ((mFocusedTime > activationTime) || startAction) { mTriggered = true; mFocusedTime = 0; // Activate transition from AR to VR or vice versa /*bool goingBackToAR = (triggerType == TriggerType.AR_TRIGGER); * mTransitionManager.Play(goingBackToAR); * StartCoroutine(ResetAfter(0.3f * mTransitionManager.transitionDuration));*/ //set selected target Debug.Log("parent " + transform.parent); Debug.Log("SIBLING" + transform.parent.GetChild(0)); changeColor.ChangeSelectedObject(this, transform.parent.GetChild(0).gameObject); genButtons.ChangeTarget(transform.parent); inputHandler.touchObject = transform.parent.GetChild(0).gameObject; } } else { // Reset the "focused state" time mFocusedTime = 0; } }