void Awake() { anim = GetComponentInChildren <Animator>(); audioSource = GetComponent <AudioSource>(); twoHandGrabInteractable = GetComponent <TwoHandGrabInteractable>(); socketInteractor.selectEntered.AddListener(AddMagazine); socketInteractor.selectExited.AddListener(RemoveMagazine); twoHandGrabInteractable.activated.AddListener(StartFire); twoHandGrabInteractable.deactivated.AddListener(EndFire); delay = Time.time; recoil = data.Recoil; originRecoil = data.Recoil; }
protected override void OnSelectEntered(SelectEnterEventArgs args) { // Once select has occured, scale object to size var temp = args.interactable; if (temp is TwoHandGrabInteractable) { two = temp.GetComponent <TwoHandGrabInteractable>(); two.canTakeByOther = true; if (temp.GetComponentInChildren <XRSimpleInteractable>()) { simple = temp.GetComponentInChildren <XRSimpleInteractable>(); simple.enabled = false; } } else if (temp is XRItemGrabInteractable) { item = temp.GetComponent <XRItemGrabInteractable>(); if (item.GetComponent <DamageSystem>()) { ds = item.GetComponent <DamageSystem>(); ds.enabled = false; } item.canTakeByOther = true; } if (temp.GetComponentInChildren <XROffsetGrabInteractable>()) { offsetGrab = temp.GetComponentInChildren <XROffsetGrabInteractable>(); offsetGrab.enabled = false; } if (temp.GetComponentInChildren <XRSocketInteractorWithName>()) { socket = temp.GetComponentInChildren <XRSocketInteractorWithName>(); if (socket.selectTarget) { var mag = socket.selectTarget.GetComponent <Magazine>(); player.ammoCount += mag.ammoCount; player.SetText(mag.ammoCount, 1); Destroy(mag.gameObject); } socket.showInteractableHoverMeshes = false; socket.enabled = false; } base.OnSelectEntered(args); TweenSizeToSocket(temp); }
protected override void OnSelectExited(SelectExitEventArgs args) { // Once the user has grabbed the object, scale to original size if (two) { two.canTakeByOther = false; two = null; if (simple) { simple.enabled = true; simple = null; } } else if (item) { item.canTakeByOther = false; if (ds) { ds.enabled = true; ds = null; } item = null; } if (offsetGrab) { offsetGrab.enabled = true; offsetGrab = null; } if (socket) { socket.showInteractableHoverMeshes = true; socket.enabled = true; } base.OnSelectExited(args); SetOriginalScale(args.interactable); }
public override void OnInspectorGUI() { TwoHandGrabInteractable off = (TwoHandGrabInteractable)target; DrawDefaultInspector(); }
public void Setup(TwoHandGrabInteractable handle) { this.handle = handle; }