private void Start() { arrow = transform.FindChild("Arrow").gameObject; obj = GetComponent<VRTK_InteractableObject>(); }
private void Start() { arrow = this.transform.FindChild("Arrow").gameObject; obj = this.GetComponent <VRTK_InteractableObject>(); }
void Awake() { io = GetComponent <VRTK_InteractableObject> (); rb = GetComponent <Rigidbody> (); }
protected virtual bool IsObjectUsable(GameObject obj) { VRTK_InteractableObject objScript = obj.GetComponent <VRTK_InteractableObject>(); return(interactTongTouch != null && interactTongTouch.IsObjectInteractable(obj) && objScript != null && (objScript.isUsable || objScript.PerformSecondaryAction())); }
protected virtual bool ScriptValidUse(VRTK_InteractableObject objectToUseScript) { return(objectToUseScript != null && objectToUseScript.grabAttachMechanicScript != null && objectToUseScript.grabAttachMechanicScript.ValidGrab(controllerTongAttachPoint)); }
/// <summary> /// Controller Io Unused /// </summary> public static IObservable <Tuple <object, InteractableObjectEventArgs> > OnIoUnusedAsObservable(this VRTK_InteractableObject io) { var component = GetOrAddComponent <ObservableOnIoUnusedTrigger>(io.gameObject); component.ob = io; io.InteractableObjectUnused += component.OnIoUnused; return(component.OnIoUnusedAsObservable()); }
//開始 protected override void Start() { arrow = transform.Find("Arrow").gameObject; RegistEvent(); obj = GetComponent <VRTK_InteractableObject>(); }
// Update is called once per frame void Update() { if (!StaticData.isTapeAttachBothHands() && StaticData.getIsCut()) { setControllerHighlight(CurState.singleAttach); } // after attach to both hands, show the first hint if (StaticData.isTapeAttachBothHands() && cur == 0) { // TODO: modify to handle different model // turn on the hint of trail renderer string modelName = StaticData.getTargetNumName(); // GameObject.Find("fcum").transform.GetChild(0).gameObject.SetActive(true); GameObject.Find(modelName).transform.GetChild(0).gameObject.SetActive(true); // turn on step buttons hint[cur].GetComponent <MeshRenderer>().enabled = true; ParticleSystem particleSystem = hint[cur].GetComponent <ParticleSystem>(); if (!particleSystem.isPlaying) { particleSystem.Play(); } // turn on tooltips hint[cur].transform.GetChild(0).gameObject.SetActive(true); // turn on audio hint if (!audioHint[cur]) { hint[cur].GetComponent <AudioSource>().Play(0); audioHint[cur] = true; } // set up highlighter setControllerHighlight(CurState.leftStep); } if (StaticData.isTapeAttachBothHands() && cur < hint.Length) { // set up highlighter if (cur < hint.Length - 1) { setControllerHighlight(CurState.leftStep); } else { setControllerHighlight(CurState.rightStep); } VRTK_InteractableObject stickBtn = hint[cur].GetComponent <VRTK_InteractableObject>(); if (stickBtn.IsTouched()) { ParticleSystem particleSystem = hint[cur].GetComponent <ParticleSystem>(); if (!particleSystem.isStopped) { particleSystem.Stop(); } MeshRenderer color = stickBtn.GetComponent <MeshRenderer>(); color.material = Resources.Load("activeBtn") as Material; } else { ParticleSystem particleSystem = hint[cur].GetComponent <ParticleSystem>(); if (!particleSystem.isPlaying) { particleSystem.Play(); } MeshRenderer color = stickBtn.GetComponent <MeshRenderer>(); color.material = Resources.Load("orange") as Material; } if (stickBtn != null && stickBtn.IsUsing()) { // fix current position GameObject handler = getCurHandler(); handler.transform.SetParent(stickPos[cur].transform); handler.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f); if (cur != hint.Length - 1) { handler.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f)); } handler.GetComponent <ObiParticleHandle>().enabled = true; // move on to next position leftController = GameObject.Find("left_hand"); leftCollider.enabled = true; ObiPinConstraints pinConstraints = obiCloth.GetComponent <ObiPinConstraints>(); ObiPinConstraintBatch pinConstraintBatch = pinConstraints.GetFirstBatch(); pinConstraints.RemoveFromSolver(null); // remove previous position constraints first // if (cur == 0) // { // do nothing // no constraint at the left hand side // } if (cur == 1) { pinConstraintBatch.RemoveConstraint(3); pinConstraintBatch.RemoveConstraint(2); } if (cur == 2) { pinConstraintBatch.RemoveConstraint(3); pinConstraintBatch.RemoveConstraint(2); } if (cur == 3) { pinConstraintBatch.RemoveConstraint(1); pinConstraintBatch.RemoveConstraint(0); } // add next position constraint if (cur == 0 || cur == 1) { pinConstraintBatch.AddConstraint(leftAttachNode[cur * 2], leftCollider, offset, restDarboux, 1); pinConstraintBatch.AddConstraint(leftAttachNode[cur * 2 + 1], leftCollider, offsetNeg, restDarboux, 1); } pinConstraints.AddToSolver(null); // turn off the current hint hint[cur].GetComponent <MeshRenderer>().enabled = false; ParticleSystem ps = hint[cur].GetComponent <ParticleSystem>(); if (!ps.isStopped) { ps.Stop(); } hint[cur].transform.GetChild(0).gameObject.SetActive(false); ++cur; StaticData.setCurTapingStep(cur); // set up last step highlight if (cur == hint.Length - 1) { setControllerHighlight(CurState.rightStep); } // turn on the next hint if (cur < hint.Length) { hint[cur].GetComponent <MeshRenderer>().enabled = true; ParticleSystem particleSystem = hint[cur].GetComponent <ParticleSystem>(); if (!particleSystem.isPlaying) { particleSystem.Play(); } // turn on tooltip hint[cur].transform.GetChild(0).gameObject.SetActive(true); // turn on audio hint if (!audioHint[cur]) { hint[cur].GetComponent <AudioSource>().Play(0); audioHint[cur] = true; } } // Last step: use right hand to attach if (cur == hint.Length - 1) { // set lefthand gesture unhold setHandUnhold("[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/LeftController/VRTK_BasicHand/LeftHand"); rightHandler = GameObject.Find("right_hand"); rightController = VRTK_DeviceFinder.GetControllerRightHand(); } } } else if (StaticData.isTapeAttachBothHands() && cur >= hint.Length) { // finish all steps // clear highlighter setControllerHighlight(CurState.finished); // set rightHand gesture unhold setHandUnhold("[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (right)/RightController/VRTK_BasicHand/RightHand"); // count 5 secs to reload main scene timeRemaining -= Time.deltaTime; if (timeRemaining <= 0) { Debug.Log("finish taping"); SceneManager.LoadScene("testMain"); } } }
void Awake() { io = GetComponent <VRTK_InteractableObject>(); }
void Awake() { interactableObject = GetComponent <VRTK_InteractableObject>(); GetHelpManager(); }
void Start() { vio = gameObject.GetComponent <VRTK_InteractableObject> (); cScript = gameObject.GetComponent <FracturedChunk>(); vio.isGrabbable = false; }
// Use this for initialization void Start() { v_io = GetComponent <VRTK_InteractableObject>(); }
// Use this for initialization void Start() { im = GetComponent <Image>(); scriptio = GetComponent <VRTK_InteractableObject>(); }
public override void OnInspectorGUI() { serializedObject.Update(); VRTK_InteractableObject targ = (VRTK_InteractableObject)target; GUILayout.Space(10); GUIStyle guiStyle = EditorStyles.foldout; FontStyle previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewTouch = EditorGUILayout.Foldout(viewTouch, "Touch Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewTouch) { EditorGUI.indentLevel++; targ.highlightOnTouch = EditorGUILayout.Toggle("Highlight on Touch:", targ.highlightOnTouch); if (targ.highlightOnTouch) { targ.touchHighlightColor = EditorGUILayout.ColorField("Touch Highlight Color:", targ.touchHighlightColor); } GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Rumble on Touch:"); EditorGUI.indentLevel--; GUILayout.Label("Strength", GUILayout.MinWidth(49f)); float x = EditorGUILayout.FloatField(targ.rumbleOnTouch.x, GUILayout.MinWidth(10f)); GUILayout.Label("Duration", GUILayout.MinWidth(50f)); float y = EditorGUILayout.FloatField(targ.rumbleOnTouch.y, GUILayout.MinWidth(10f)); targ.rumbleOnTouch = new Vector2(y, x); EditorGUI.indentLevel++; GUILayout.EndHorizontal(); targ.allowedTouchControllers = (VRTK_InteractableObject.AllowedController)EditorGUILayout.EnumPopup("Allowed Touch Controllers:", targ.allowedTouchControllers); targ.hideControllerOnTouch = (VRTK_InteractableObject.ControllerHideMode)EditorGUILayout.EnumPopup("Hide Controller On Touch:", targ.hideControllerOnTouch); EditorGUI.indentLevel--; } //Grab Layout GUILayout.Space(10); targ.isGrabbable = EditorGUILayout.Toggle("Is Grabbable:", targ.isGrabbable); if (targ.isGrabbable) { guiStyle = EditorStyles.foldout; previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewGrab = EditorGUILayout.Foldout(viewGrab, "Grab Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewGrab) { EditorGUI.indentLevel++; targ.isDroppable = EditorGUILayout.Toggle("Is Droppable:", targ.isDroppable); targ.isSwappable = EditorGUILayout.Toggle("Is Swappable:", targ.isSwappable); targ.holdButtonToGrab = EditorGUILayout.Toggle("Hold Button To Grab:", targ.holdButtonToGrab); targ.grabOverrideButton = (VRTK_ControllerEvents.ButtonAlias)EditorGUILayout.EnumPopup("Grab Override Button:", targ.grabOverrideButton); GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Rumble on Grab:"); EditorGUI.indentLevel--; GUILayout.Label("Strength", GUILayout.MinWidth(49f)); float x = EditorGUILayout.FloatField(targ.rumbleOnGrab.x, GUILayout.MinWidth(10f)); GUILayout.Label("Duration", GUILayout.MinWidth(50f)); float y = EditorGUILayout.FloatField(targ.rumbleOnGrab.y, GUILayout.MinWidth(10f)); targ.rumbleOnGrab = new Vector2(y, x); EditorGUI.indentLevel++; GUILayout.EndHorizontal(); targ.allowedGrabControllers = (VRTK_InteractableObject.AllowedController)EditorGUILayout.EnumPopup("Allowed Controllers:", targ.allowedGrabControllers); targ.precisionSnap = EditorGUILayout.Toggle("Precision Snap:", targ.precisionSnap); if (!targ.precisionSnap) { targ.rightSnapHandle = EditorGUILayout.ObjectField("Right Snap Handle:", targ.rightSnapHandle, typeof(Transform), true) as Transform; targ.leftSnapHandle = EditorGUILayout.ObjectField("Left Snap Handle:", targ.leftSnapHandle, typeof(Transform), true) as Transform; } targ.hideControllerOnGrab = (VRTK_InteractableObject.ControllerHideMode)EditorGUILayout.EnumPopup("Hide Controller On Grab:", targ.hideControllerOnGrab); targ.stayGrabbedOnTeleport = EditorGUILayout.Toggle("Stay Grabbed on Teleport:", targ.stayGrabbedOnTeleport); targ.grabAttachMechanic = (VRTK_InteractableObject.GrabAttachType)EditorGUILayout.EnumPopup("Grab Attach Mechanic:", targ.grabAttachMechanic); if (targ.grabAttachMechanic == VRTK_InteractableObject.GrabAttachType.Fixed_Joint || targ.grabAttachMechanic == VRTK_InteractableObject.GrabAttachType.Spring_Joint || targ.grabAttachMechanic == VRTK_InteractableObject.GrabAttachType.Track_Object || targ.grabAttachMechanic == VRTK_InteractableObject.GrabAttachType.Rotator_Track) { targ.detachThreshold = EditorGUILayout.FloatField("Detach Threshold:", targ.detachThreshold); if (targ.grabAttachMechanic == VRTK_InteractableObject.GrabAttachType.Spring_Joint) { targ.springJointStrength = EditorGUILayout.FloatField("Spring Joint Strength:", targ.springJointStrength); targ.springJointDamper = EditorGUILayout.FloatField("Spring Joint Damper:", targ.springJointDamper); } } targ.throwMultiplier = EditorGUILayout.FloatField("Throw Multiplier:", targ.throwMultiplier); targ.onGrabCollisionDelay = EditorGUILayout.FloatField("On Grab Collision Delay:", targ.onGrabCollisionDelay); EditorGUI.indentLevel--; } } GUILayout.Space(10); targ.isUsable = EditorGUILayout.Toggle("Is Usable:", targ.isUsable); if (targ.isUsable) { guiStyle = EditorStyles.foldout; previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewUse = EditorGUILayout.Foldout(viewUse, "Use Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewUse) { EditorGUI.indentLevel++; targ.useOnlyIfGrabbed = EditorGUILayout.Toggle("Use Only If Grabbed: ", targ.useOnlyIfGrabbed); targ.holdButtonToUse = EditorGUILayout.Toggle("Hold Button To Use: ", targ.holdButtonToUse); targ.useOverrideButton = (VRTK_ControllerEvents.ButtonAlias)EditorGUILayout.EnumPopup("Use Override Button:", targ.useOverrideButton); targ.pointerActivatesUseAction = EditorGUILayout.Toggle("Pointer Activates Use Action: ", targ.pointerActivatesUseAction); GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Rumble on Use:"); EditorGUI.indentLevel--; GUILayout.Label("Strength", GUILayout.MinWidth(49f)); float x = EditorGUILayout.FloatField(targ.rumbleOnUse.x, GUILayout.MinWidth(10f)); GUILayout.Label("Duration", GUILayout.MinWidth(50f)); float y = EditorGUILayout.FloatField(targ.rumbleOnUse.y, GUILayout.MinWidth(10f)); targ.rumbleOnUse = new Vector2(y, x); EditorGUI.indentLevel++; GUILayout.EndHorizontal(); targ.allowedUseControllers = (VRTK_InteractableObject.AllowedController)EditorGUILayout.EnumPopup("Allowed Use Controllers:", targ.allowedUseControllers); targ.hideControllerOnUse = (VRTK_InteractableObject.ControllerHideMode)EditorGUILayout.EnumPopup("Hide Controller On Use:", targ.hideControllerOnUse); EditorGUI.indentLevel--; } } if (targ.GetComponent <VRTK_InteractableObject>().GetType().IsSubclassOf(typeof(VRTK_InteractableObject))) { GUILayout.Space(10); guiStyle = EditorStyles.foldout; previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewCustom = EditorGUILayout.Foldout(viewCustom, "Custom Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewCustom) { DrawPropertiesExcluding(serializedObject, new string[] { "hideControllerOnUse", "allowedUseControllers", "rumbleOnUse", "pointerActivatesUseAction", "useOverrideButton", "holdButtonToUse", "useOnlyIfGrabbed", "throwMultiplier", "onGrabCollisionDelay", "springJointDamper", "springJointStrength", "detachThreshold", "grabAttachMechanic", "stayGrabbedOnTeleport", "hideControllerOnGrab", "leftSnapHandle", "rightSnapHandle", "precisionSnap", "allowedGrabControllers", "rumbleOnGrab", "grabOverrideButton", "holdButtonToGrab", "isSwappable", "isDroppable", "isGrabbable", "hideControllerOnTouch", "allowedTouchControllers", "rumbleOnTouch", "touchHighlightColor", "highlightOnTouch", "isUsable" }); } } serializedObject.ApplyModifiedProperties(); }
void Start() { interactable = GetComponent <VRTK_InteractableObject>(); interactable.SubscribeToInteractionEvent(VRTK_InteractableObject.InteractionType.Grab, Leave); }
private void Awake() { interactableObject = GetComponent <VRTK_InteractableObject>(); interactableObject.InteractableObjectUngrabbed += InteractableObjectUngrabbed; }
public void AllowUse(VRTK_InteractableObject interactableObject) { interactableObject.isUsable = true; }
protected virtual void OnEnable() { clockHandInteraction = this.GetComponent <VRTK_InteractableObject>(); clockHandInteraction.InteractableObjectGrabbed += InteractableObjectGrabbed; clockHandInteraction.InteractableObjectUngrabbed += InteractableObjectUngrabbed; }
// Use this for initialization void Start() { vr = GetComponent <VRTK_InteractableObject>(); StartCoroutine(starting()); }
private void Start() { // arrow = transform.Find("Arrow").gameObject; obj = GetComponent <VRTK_InteractableObject>(); }
private void Start() { m_InteractableObject = GetComponent <VRTK_InteractableObject>(); }
// Use this for initialization void Awake() { interactableObject = GetComponent <VRTK_InteractableObject>(); interactableObject.InteractableObjectUsed += new InteractableObjectEventHandler(Used); interactableObject.InteractableObjectGrabbed += new InteractableObjectEventHandler(Grabbed); }
protected override void InitSecondaryGrab(VRTK_InteractableObject currentUsedObject) { influencingGrabbedObject = true; currentUsedObject.Grabbed(this); }
void OnEnable() { next = this.gameObject.GetComponent <VRTK_InteractableObject>(); next.InteractableObjectUsed += InteractableObjectUsed; next.InteractableObjectUnused += InteractableObjectUnused; }
private void InitVar() { interactableObject = GetComponent <VRTK_InteractableObject>(); }
void Start() { canSpawn = true; interactableObject = GetComponent <VRTK_InteractableObject> (); interactableObject.InteractableObjectTouched += new InteractableObjectEventHandler(InstantiatePrefab); }
protected virtual void OnEnable() { interactableObject = GetComponent <VRTK_InteractableObject>(); interactableObject.InteractableObjectUsed += InteractableObjectUsed; interactableObject.InteractableObjectUnused += InteractableObjectUnused; }
/// <summary> /// The Initalise method is used to set up the state of the secondary action when the object is initially grabbed by a secondary controller. /// </summary> /// <param name="currentGrabbdObject">The Interactable Object script for the object currently being grabbed by the primary controller.</param> /// <param name="currentPrimaryGrabbingObject">The Interact Grab script for the object that is associated with the primary controller.</param> /// <param name="currentSecondaryGrabbingObject">The Interact Grab script for the object that is associated with the secondary controller.</param> /// <param name="primaryGrabPoint">The point on the object where the primary controller initially grabbed the object.</param> /// <param name="secondaryGrabPoint">The point on the object where the secondary controller initially grabbed the object.</param> public override void Initialise(VRTK_InteractableObject currentGrabbdObject, VRTK_InteractGrab currentPrimaryGrabbingObject, VRTK_InteractGrab currentSecondaryGrabbingObject, Transform primaryGrabPoint, Transform secondaryGrabPoint) { base.Initialise(currentGrabbdObject, currentPrimaryGrabbingObject, currentSecondaryGrabbingObject, primaryGrabPoint, secondaryGrabPoint); initialScale = currentGrabbdObject.transform.localScale; }
public override void Initialise(VRTK_InteractableObject currentGrabbdObject, VRTK_InteractGrab currentPrimaryGrabbingObject, VRTK_InteractGrab currentSecondaryGrabbingObject, Transform primaryGrabPoint, Transform secondaryGrabPoint) { base.Initialise(currentGrabbdObject, currentPrimaryGrabbingObject, currentSecondaryGrabbingObject, primaryGrabPoint, secondaryGrabPoint); grabbedObject.GetComponent <InteractableObj>().SecondGrabbed(); }
protected virtual void OnEnable() { iceCubeInteraction = this.GetComponent <VRTK_InteractableObject>(); iceCubeInteraction.InteractableObjectGrabbed += InteractableObjectGrabbed; iceCubeInteraction.InteractableObjectUngrabbed += InteractableObjectUngrabbed; }
private void Start() { bowAnimation = GetComponent<BowAnimation>(); handle = GetComponentInChildren<BowHandle>(); interact = GetComponent<VRTK_InteractableObject>(); interact.InteractableObjectGrabbed += new InteractableObjectEventHandler(DoObjectGrab); }
void Start() { interactScript = GetComponent <VRTK_InteractableObject>(); interactScript.InteractableObjectGrabbed += new InteractableObjectEventHandler(ObjectGrabbed); interactScript.InteractableObjectUngrabbed += new InteractableObjectEventHandler(ObjectUngrabbed); }