// Use this for initialization void Start() { interactGrab = GetComponent <VRTK_InteractGrab> (); interactGrab.ControllerGrabInteractableObject += Grab; interactGrab.ControllerUngrabInteractableObject += Ungrab; autoGrab = GetComponent <VRTK_ObjectAutoGrab> (); }
/// <summary> /// Observable ObjectAutoGrabCompleted event /// </summary> /// <param name="events"></param> /// <returns></returns> public static IObservable <Object> ObjectAutoGrabCompletedAsObservable(this VRTK_ObjectAutoGrab events) { return(Observable.FromEvent <ObjectAutoGrabEventHandler, Object>( h => h.Invoke, h => events.ObjectAutoGrabCompleted += h, h => events.ObjectAutoGrabCompleted -= h)); }
// Use this for initialization void Start() { lgrab = LController.GetComponent <VRTK_InteractGrab>(); rgrab = RController.GetComponent <VRTK_InteractGrab>(); autograb = RController.GetComponent <VRTK_ObjectAutoGrab>(); arrowSpawner.SetActive(false); isItASword = true; swordscript = sword.GetComponent <Sword>(); swordscript.LController = LController; swordscript.RController = RController; }
public void SpawnItem(ISpawnableItem item) { itemInstance = item.Spawn(); itemInstance.transform.SetPositionAndRotation(transform.position, transform.rotation); // Snap item to grab position VRTK_ObjectAutoGrab autograb = GetComponent <VRTK_ObjectAutoGrab>(); if (autograb == null) { autograb = gameObject.AddComponent <VRTK_ObjectAutoGrab>(); } autograb.objectToGrab = itemInstance.GetComponent <VRTK_InteractableObject>(); // Disable UI pointer on spawn to avoid dragging menu gameObject.GetComponent <VRTK_UIPointer>().enabled = false; Destroy(autograb, 0.1f); }
private void Awake() { if (GetComponent <VRTK_ControllerEvents>() == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same")); return; } GetComponent <VRTK_ControllerEvents>().TriggerPressed += new ControllerInteractionEventHandler(SnapobjectToController); GetComponent <VRTK_ControllerEvents>().TriggerReleased += new ControllerInteractionEventHandler(UnSnapObject); GetComponent <VRTK_ControllerEvents>().TouchpadPressed += new ControllerInteractionEventHandler(UIPointerPressed); GetComponent <VRTK_ControllerEvents>().TouchpadReleased += new ControllerInteractionEventHandler(UIPointerReleased); GetComponent <VRTK_InteractTouch>().ControllerTouchInteractableObject += new ObjectInteractEventHandler(onGrabbedTouched); GetComponent <VRTK_InteractTouch>().ControllerUntouchInteractableObject += new ObjectInteractEventHandler(onGrabbedUntouched); GetComponent <VRTK_InteractGrab>().ControllerGrabInteractableObject += GrabThrowable_ControllerGrabInteractableObject; autoGrab = GetComponent <VRTK_ObjectAutoGrab>(); autoGrab.enabled = false; Menu = LeftController.GetComponent <ThrowableMenuController>(); if (Menu == null) { Debug.LogError("Error loading menu controller"); } formulaController = GetComponent <FormulaController>(); if (formulaController == null) { Debug.LogError("Error loading FormulaController controller"); } sliderHandler = LeftController.GetComponent <SliderHandler>(); if (sliderHandler == null) { Debug.LogWarning("Error fetching SliderHandler from left controller"); } if (GC == null) { throw new NotImplementedException("Please attach the garbage collector Object to the grab throwable Script in Right controller"); } }
void HandleClick() { if (fs == null) { Debug.LogError("File system not found!"); } else if (!isDirectory) { if (fileAbsoluteDirectory.Contains(".prefab")) { Debug.Log("Prefab directory: " + fileRelativeDirectory); Object targetObject = (GameObject)AssetDatabase.LoadAssetAtPath <Object>(fileRelativeDirectory); GameObject target = Instantiate(targetObject) as GameObject; target.AddComponent <VRTK_InteractableObject>(); target.GetComponent <VRTK_InteractableObject>().isGrabbable = true; target.AddComponent <VRTK_AxisScaleGrabAction>(); inspector.SetTarget(target); VRTK_ObjectAutoGrab objectAutoGrab = inspector.controller.GetComponent <VRTK_ObjectAutoGrab>(); grabManager.SetAutoGrab(true); objectAutoGrab.objectToGrab = target.GetComponent <VRTK_InteractableObject>(); objectAutoGrab.enabled = true; panelManager.ChangePanelTo("inspector"); } else if (fileAbsoluteDirectory.Contains(".unity")) { Debug.Log("Path: " + fileRelativeDirectory); sceneManager.LoadScene(fileRelativeDirectory); //sceneManager.LoadScene("VR_Interior_Design"); } else { Debug.LogError("Can't open file or directory!"); } } else { fs.ChangeDirectory(fileAbsoluteDirectory); } }
private void Awake() { autoGrab = GetComponent <VRTK_ObjectAutoGrab>(); }
public void ResetAutoGrab(VRTK_ObjectAutoGrab autoGrab) { Debug.Log("RE"); //autoGrab.ClearPreviousClone(); //autoGrab.enabled = false; }