/// <summary> /// Update method called once per frame /// </summary> void Update() { leftInventoryItems = leftInventory.GetComponent <inventory>().inventoryList; rightInventoryItems = rightInventory.GetComponent <inventory>().inventoryList; if (Input.GetButtonUp("Show Inventory")) { // Toggle inventory display showInventory = !showInventory; // Turn off crosshair when crafting menu is shown Crosshair.DisplayCrosshair(!showInventory); // Turn off main item selection control when crafting menu is shown MainItemSelection.SwitchMainItemSelection(!showInventory); } this.leftCircle.SetActive(showInventory); this.rightCircle.SetActive(showInventory); this.craftResultBox.SetActive(showInventory); if (showInventory) { // Display items in slots // NOTE* this could be changed to only grabbed the images on initialize and add // Left items used for crafting materials for (int index = 0; index < leftInventoryItems.Count; index++) { Image imageComponent = leftItemSlots[index].transform.GetChild(0).GetComponent <Image>(); if (leftInventoryItems[index] != new item()) { item selectedItem = leftInventoryItems[index]; if (selectedItem != new item()) { imageComponent.sprite = selectedItem.icon.sprite; imageComponent.enabled = true; } else { imageComponent.enabled = false; } } else { imageComponent.enabled = false; } } // Left items used for primative materials for (int index = 0; index < rightInventoryItems.Count; index++) { Image imageComponent = rightItemSlots[index].transform.GetChild(0).GetComponent <Image>(); if (rightInventoryItems[index] != new item()) { item selectedItem = rightInventoryItems[index]; if (selectedItem != new item()) { imageComponent.sprite = selectedItem.icon.sprite; imageComponent.enabled = true; } else { imageComponent.enabled = false; } } else { imageComponent.enabled = false; } } // Rotate slots based on the previous angle and current angle (to maintain orientation) float leftRingCurrentAngle = leftRingTransform.rotation.eulerAngles.z; foreach (Image itemSlot in leftItemSlots) { itemSlot.rectTransform.Rotate(Vector3.forward, leftRingPreviousAngle - leftRingCurrentAngle); } leftRingPreviousAngle = leftRingCurrentAngle; float rightRingCurrentAngle = rightRingTransform.rotation.eulerAngles.z; foreach (Image itemSlot in rightItemSlots) { itemSlot.rectTransform.Rotate(Vector3.forward, rightRingPreviousAngle - rightRingCurrentAngle); } rightRingPreviousAngle = rightRingCurrentAngle; // Mouse wheel control if (Input.GetAxis("Secondary Item") == 1) { // Rotate left wheel leftMouseScrollWheel = Input.GetAxis("Mouse ScrollWheel"); rightMouseScrollWheel = 0; } else { // Rotate right wheel rightMouseScrollWheel = Input.GetAxis("Mouse ScrollWheel"); leftMouseScrollWheel = 0; } // Right scroll wheel rotation if (rightMouseScrollWheel >= 0.1f && rightMouseScrollWheel != 0) { if (this.rightInitialRotate == true) { // Initially, we want to rotate a value greater than the stopGap so it does not get stuck this.rightAngleToRotate = this.angleStopGap + 0.01f; this.rightInitialRotate = false; } else { this.rightAngleToRotate = this.rotateSpeed + this.deltaTimeSpeedAdjustment * Time.deltaTime; } } else if (rightMouseScrollWheel <= -0.1f && rightMouseScrollWheel != 0) { if (this.rightInitialRotate == true) { this.rightAngleToRotate = -1 * (this.angleStopGap + 0.01f); this.rightInitialRotate = false; } else { this.rightAngleToRotate = -this.rotateSpeed + -this.deltaTimeSpeedAdjustment * Time.deltaTime; } } // Left scroll wheel rotation if (leftMouseScrollWheel >= 0.1f && leftMouseScrollWheel != 0) { if (this.leftInitialRotate == true) { this.leftAngleToRotate = this.angleStopGap + 0.01f; this.leftInitialRotate = false; } else { this.leftAngleToRotate = this.rotateSpeed + this.deltaTimeSpeedAdjustment * Time.deltaTime; } } else if (leftMouseScrollWheel <= -0.1f && leftMouseScrollWheel != 0) { if (this.leftInitialRotate == true) { this.leftAngleToRotate = -1 * (this.angleStopGap + 0.01f); this.leftInitialRotate = false; } else { this.leftAngleToRotate = -this.rotateSpeed + -this.deltaTimeSpeedAdjustment * Time.deltaTime; } } } // Right scroll wheel stop and physical rotation // NOTE* The stop operations should still occur when the wheels are not shown if (Math.Abs(rightRingTransform.rotation.eulerAngles.z % 45) < this.angleStopGap && rightMouseScrollWheel == 0) { this.rightAngleToRotate = -1 * rightRingTransform.rotation.eulerAngles.z % 45; this.rightRingTransform.Rotate(Vector3.forward, rightAngleToRotate); this.rightAngleToRotate = 0; this.rightInitialRotate = true; } else { if (this.invertCraftingWheelRotation) { this.rightRingTransform.Rotate(Vector3.forward, -rightAngleToRotate); } else { this.rightRingTransform.Rotate(Vector3.forward, rightAngleToRotate); } } // Left scroll wheel stop if (Math.Abs(leftRingTransform.rotation.eulerAngles.z % 45) < this.angleStopGap && leftMouseScrollWheel == 0) { this.leftAngleToRotate = -1 * leftRingTransform.rotation.eulerAngles.z % 45; this.leftRingTransform.Rotate(Vector3.forward, leftAngleToRotate); this.leftAngleToRotate = 0; this.leftInitialRotate = true; } else { if (this.invertCraftingWheelRotation) { this.leftRingTransform.Rotate(Vector3.forward, -leftAngleToRotate); } else { this.leftRingTransform.Rotate(Vector3.forward, leftAngleToRotate); } } }