Virexa
HomeAIProgrammingCloudSecurityOpen SourceGamesMobile GamesDeveloper Hub
Sign InSign Up
Virexa
Sign InSign Up
AIProgrammingCloudSecurityOpen SourceGamesMobile GamesDeveloper Hub
Virexa

Modern AI news aggregation and newsletter platform covering technology, business, AI, games and world news.

Categories

  • AI
  • Programming
  • Cloud
  • Security
  • Open Source
  • Developer Hub

Company

  • About
  • Contact
  • Advertise

Resources

  • RSS Feed
  • API
  • Privacy Policy
  • Terms of Service

© 2026 Virexa. All rights reserved.

Virexa
HomeAIProgrammingCloudSecurityOpen SourceGamesMobile GamesDeveloper Hub
Sign InSign Up
Virexa
Sign InSign Up
AIProgrammingCloudSecurityOpen SourceGamesMobile GamesDeveloper Hub
Home›News Explorer

Explore

News Explorer

Browse every article collected by VIREXA. Newest articles appear first.

Filters

6,933 results • Page 41 of 578

Newbie stumped with an inventory bug
Mobile GamesTutorial

Newbie stumped with an inventory bug

So, I’ll include the code down below as well, and if I missed anything. I had a video but because I’m a new user it won’t let me. I’m relatively new to unity. I’ve got experience with programming, but this is my first ‘game’ in 10 years. So I decided to go through a tutorial to re-familiarise myself with things, and learn the basics of the system. However, the tutorial I used was for an earlier version of Unity, and it’s possible I also made a mistake somewhere. Either way, for some reason the Dragable script, which I forgot to show in the video, doesn’t seem to detect the leftmost row in the inventory UI slots. I’ll link the files below, and all of that. It’s not a big huge thing since this is more for learning, but it’s been bugging me for two weeks now because I can’t figure out what’s causing this. Thanks for the help! ItemDragable: using UnityEngine; using UnityEngine.EventSystems; public class ItemDragable : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler { Transform originalParent; CanvasGroup canvasGroup; public float minDropDistance = 2f; public float maxDropDistance = 3f; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { canvasGroup = GetComponent (); } public void OnBeginDrag(PointerEventData eventData) { originalParent = transform.parent; // Save Original Parent transform.SetParent(transform.root); //I think this means 'make item on top' canvasGroup.blocksRaycasts = false; // makes it clickable. In this case: You're already clicking. canvasGroup.alpha = 0.6f; // Semi transparrent during drag. } public void OnDrag(PointerEventData eventData) { transform.position = eventData.position; //Item moves where dragged. Could be useful for coding follower. } public void OnEndDrag(PointerEventData eventData) { canvasGroup.blocksRaycasts = true; // makes it clickable. In this case: so you can drag again. canvasGroup.alpha = 1f; Slot dropSlot = eventData.pointerEnter?.GetComponent (); // Question mark makes a variable able to be null. Useful! Slot originalSlot = originalParent.GetComponent (); if (dropSlot == null) { GameObject dropItem = eventData.pointerEnter; if (dropItem!=null) { dropSlot = dropItem.GetComponentInParent (); // Gets the item below's slot. Because something something grabbing the raycast? } } if (dropSlot != null) { if(dropSlot.currentItem != null) { dropSlot.currentItem.transform.SetParent(originalSlot.transform); originalSlot.currentItem = dropSlot.currentItem; dropSlot.currentItem.GetComponent ().anchoredPosition = Vector2.zero; // If there's an item in the slot, move the item to the previous slot. } else { originalSlot.currentItem = null; // If there isn't an item...empty old slot of item. } transform.SetParent(dropSlot.transform); dropSlot.currentItem = gameObject; //hotbarController.SetHotbarItem(saveData.InventorySaveData); // Moves the dragged item to the new slot. } else { //If where we're dropping is outside the menu, drop the item. if (!IsWithinInventory(eventData.position)) { DropItem(originalSlot); } else { transform.SetParent(originalParent); // Return to old slot. } } GetComponent ().anchoredPosition = Vector2.zero; // Center } bool IsWithinInventory(Vector2 mousePosition) { RectTransform inventoryRect = originalParent.parent.GetComponent (); return RectTransformUtility.RectangleContainsScreenPoint(inventoryRect, mousePosition); } ///throw new System.NotImplementedException(); void DropItem(Slot originalSlot) { originalSlot.currentItem = null; // Find player Transform playerTransform = GameObject.FindGameObjectWithTag("Player")?.transform; if (playerTransform == null) { Debug.LogError("Missing 'Player' tag."); return; } // Random drop position Vector2 dropOffset = Random.insideUnitCircle.normalized * Random.Range(minDropDistance, maxDropDistance); Vector2 dropPosition = (Vector2)playerTransform.position + dropOffset; //instantiate drop item and bounce GameObject dropItem = Instantiate(gameObject, dropPosition, Quaternion.identity); dropItem.GetComponent ().StartBounce(); //destroy the ui one Destroy(gameObject); } } Slot: using UnityEngine; public class Slot : MonoBehaviour { public GameObject currentItem; //The item that's held in this slot. } InventoryController: using UnityEngine; using System.Collections; using System.Collections.Generic; public class InventoryController : MonoBehaviour { private ItemDictionary itemDictionary; private ItemDragable itemdraggable; public GameObject inventoryPanel; public GameObject hotbarPanel; public GameObject slotPrefab; public int slotCount; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { //itemDictionary = FindObjectOfType (); itemDictionary = Object.FindAnyObjectByType (); // Creates the inventory slots. Removed as it's now done in SetInventoryItems. /* for (int i = 0; i (); if (i ().anchoredPosition = Vector2.zero; slot.currentItem = item; } } */ } public bool AddItem(GameObject itemPrefab) { foreach (Transform slotTransform in inventoryPanel.transform) { // For each slot in the inventory menu Slot slot = slotTransform.GetComponent (); if (slot != null && slot.currentItem == null) { GameObject newItem = Instantiate(itemPrefab, slotTransform); newItem.GetComponent ().anchoredPosition = Vector2.zero; slot.currentItem = newItem; return true; } } Debug.Log("Inventory is Full!"); return false; } public List GetInventoryItems() { List invData = new List (); foreach (Transform slotTransform in inventoryPanel.transform) { Slot slot = slotTransform.GetComponent (); if (slot.currentItem != null) { Item item = slot.currentItem.GetComponent (); invData.Add(new InventorySaveData {itemID = item.ID, slotIndex = slotTransform.GetSiblingIndex() }); } } return invData; } public void SetInventoryItem(List inventorySaveData) { // Clear the empty slots made on game start to make way for the new data. foreach (Transform child in inventoryPanel.transform) { Destroy(child.gameObject); } //Create New data slots for (int i = 0; i (); if (itemPrefab != null) { GameObject item = Instantiate(itemPrefab, slot.transform); item.GetComponent ().anchoredPosition = Vector2.zero; slot.currentItem = item; } } else { Debug.LogWarning($"Inventory amount {data.slotIndex} does not fit in slot amount."); } } } } And just in case, Item, and Item dictionary: using UnityEngine; using UnityEngine.UI; public class Item : MonoBehaviour { public int ID; public string Name; public int Amount = 1; public virtual void UseItem() { Debug.Log($"Using item {Name}."); } public virtual void Pickup() { Sprite itemIcon = GetComponent ().sprite; if (ItemPickupUIController.Instance != null) { //Stops it crashing if an item doesn't exist. ItemPickupUIController.Instance.ShowItemPickup(Name, itemIcon); } } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class ItemDictionary : MonoBehaviour { public List itemPrefabs; private Dictionary itemDictionary; private void Awake() { itemDictionary = new Dictionary (); //Loads all items into the dictionary for (int i = 0; i 4 posts - 2 participants Read full topic

← Previous1…3940414243…578Next →
🔥

Developer Pulse

What developers are discussing today

  • GPT-5.5 API↗9.4K
  • Next.js 16↗6.2K
  • Claude Code↗5.8K
  • Kubernetes→3.4K
  • Rust↗2.7K
Unity Discussions·August 20, 2026·5 min read
Waymo’s self-driving cars get Gemini integration, so you have someone to talk to
MobileNews

Waymo’s self-driving cars get Gemini integration, so you have someone to talk to

A new "Zen mode" is coming to Waymo cars as well.

Android Authority·August 20, 2026·1 min read
Google is getting tougher on Android apps that use too much memory
MobileNews

Google is getting tougher on Android apps that use too much memory

More Android phones will soon be able to rein in memory-hungry apps.

Android Authority·August 20, 2026·1 min read
Qualcomm just teased two new Snapdragon 8 Elite chips
MobileNews

Qualcomm just teased two new Snapdragon 8 Elite chips

Qualcomm has officially started teasing two next-gen flagship processors.

Android Authority·August 20, 2026·1 min read
Founder of collapsed Chinese property giant Evergrande sentenced to life in prison
WorldNews

Founder of collapsed Chinese property giant Evergrande sentenced to life in prison

Hui's sentencing marks a key moment in the fallout from Evergrande's collapse, which shook China's property sector.

BBC·August 20, 2026·1 min read
Elementor Pro Flaw Could Let Unauthenticated Attackers Upload PHP and Execute Code
SecuritySecurity Advisory

Elementor Pro Flaw Could Let Unauthenticated Attackers Upload PHP and Execute Code

Cybersecurity researchers have disclosed details of a critical flaw in the Elementor Pro WordPress plugin that, if successfully exploited, could lead to remote code execution. The vulnerability, tracked as CVE-2026-32475, carries a CVSS score of 9.0 out of 10.0. It has been described as a case of unrestricted upload of a file with a dangerous type. "The flaw lives in the Forms module's File

The Hacker News·August 20, 2026·1 min read
Missing teen hiker found dead in Australian bush after eight-day search
WorldNews

Missing teen hiker found dead in Australian bush after eight-day search

The state premier initially said Lily Hooper had been found alive before police confirmed her death.

BBC·August 20, 2026·1 min read
Zoo boss calls pipeline plan on site 'unacceptable'
ScienceNews

Zoo boss calls pipeline plan on site 'unacceptable'

Proposals for a pipeline to transport carbon emissions to the coast would cut through the zoo.

BBC·August 20, 2026·1 min read
Captured Ukrainian-born soldiers tell BBC why they fought for Russia
WorldNews

Captured Ukrainian-born soldiers tell BBC why they fought for Russia

Men born in Ukraine who fought for Russia are tried for treason, but at a prisoner of war camp in western Ukraine, many believe they were defending their homeland.

BBC·August 20, 2026·1 min read
iRobot Promo Code: 15% Off
TechnologyNews

iRobot Promo Code: 15% Off

Save on iRobot products, including robot vacuums and mops designed to handle pet hair, daily messes, and hands-free cleaning with smart home integration.

Wired·August 20, 2026·1 min read
20% Off Samsung Promo Code | August 2026
TechnologyNews

20% Off Samsung Promo Code | August 2026

Save 30% or 10% with Samsung coupon codes, up to $1,000 on appliances, plus limited-time deals on the Galaxy Z Fold7, Flip7, and S25.

Wired·August 20, 2026·1 min read
H&R Block Coupon: 25% Off DIY + Tax Pro Assist
TechnologyNews

H&R Block Coupon: 25% Off DIY + Tax Pro Assist

Save over 25% when you opt for H&R Block’s free online offering, plus a tax pro review.

Wired·August 20, 2026·1 min read
Zero-Day
↘2K
💬

Top Discussion

HN

Hacker News

“GPT-5.5's API pricing is reshaping how startups build AI products”

14.1K932 comments
View discussion→

Filters

Time
Categories
Sources
Content Type