// Update is called once per frame void Update() { if (Input.GetButtonDown(pickDropButton)) { pickableDetector.RefreshOrder(); var objectToPickUp = pickableDetector.ObjectToPick; if (pickedUpObject) { m_animator.SetFloat(m_holdingParam, 0); pickableDetector.Clear(); pickedUpObject.HandleDropped(this); pickedUpObject = null; Destroy(pickableJoint); AudioSource.PlayClipAtPoint(pickDropClip, transform.position); } else if (objectToPickUp && objectToPickUp.CanPickUp(this)) { m_animator.SetFloat(m_holdingParam, 1); pickedUpObject = objectToPickUp; objectToPickUp.HandlePickedUp(this, pickableDetector.PickupPoint); objectToPickUp = null; var pickedUpObjectRb = pickedUpObject.GetComponent <Rigidbody>(); pickableJoint = gameObject.AddComponent <FixedJoint>(); pickableJoint.connectedBody = pickedUpObjectRb; startAnchor = pickableJoint.anchor; pickableJoint.autoConfigureConnectedAnchor = false; m_animator.SetFloat(m_holdingUpParam, 0f); AudioSource.PlayClipAtPoint(pickDropClip, transform.position); } } if (Input.GetButtonDown(liftButton) && pickedUpObject) { pickedUpObject.HandleLiftTapped(this); } if (Input.GetButtonDown(dashButton) && !pickedUpObject && dashAvailableTime < Time.timeSinceLevelLoad) { dashEndTime = Time.timeSinceLevelLoad + dashTime; dashAvailableTime = Time.timeSinceLevelLoad + dashCooldown; AudioSource.PlayClipAtPoint(dashClip, transform.position); } if (Input.GetButtonDown(furniturePreviewButton)) { FurniturePreview.ShowPreview(true); } else if (Input.GetButtonUp(furniturePreviewButton)) { FurniturePreview.ShowPreview(false); } }
/// <summary> /// Fills the scrollview with the available choices. /// </summary> private void PopulateList() { previews = new FurniturePreview[list.Pairs.Length]; for (int i = 0; i < list.Pairs.Length; i++) { FurniturePreview furniturePreview = Instantiate(furniturePreviewPrefab, furniturePreviewParent).GetComponent <FurniturePreview>(); previews[i] = furniturePreview; furniturePreview.SetData(list.Pairs[i].Thumbnail, i); furniturePreview.onSelectedEvent += OnFurnitureSelected; } previews[0].Select(); }
void Awake() { Instance = this; }