C
C#17mo ago
ju_siolive

❔ Help with a unity Inventory

im making an Inventory for my unity game and im getting this CS1061 error, i Know what the error is, but i can´t find whats wrong, if someone could help me, i can screenshot the unity or send the code, thanks
11 Replies
ju_siolive
ju_siolive17mo ago
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class InventoryController : MonoBehaviour { public Objects[] slots; public Image[] slotImage; public int[] slotAmount; void Start() {
} void Update() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width/ 2, Screen.height / 2)); if(Physics.Raycast(ray, out hit, 5f)) { if(hit.collider.tag == "Object") { if(Input.GetKeyDown(KeyCode.E)) { for(int i = 0; i < slots.Lenght; i++) { if (slots[i] == null || slots[i].name == hit.transform.GetComponent<ObjectType>().objectType.name) { slots[i] = hit.transform.GetComponent<ObjectType>().objectType; slotAmount[i]++; slotImage[i].sprite = slots[i].itemSprite; Destroy(hit.transform.gameObject); break; } } } } } } } Assets\Inventory\InventoryController.cs(29,46): error CS1061: 'Objects[]' does not contain a definition for 'Lenght' and no accessible extension method 'Lenght' accepting a first argument of type 'Objects[]' could be found (are you missing a using directive or an assembly reference?)
Yawnder
Yawnder17mo ago
@ju_siolive Length, not Lenght.
ju_siolive
ju_siolive17mo ago
Sorry i dont get it
Yawnder
Yawnder17mo ago
The message explicitly states "Objects[]' does not contain a definition for 'Lenght' " You're trying to call a property Lenght. That's not how you write that word. In your IDE, you should have a big squiggly red line under that word too.
ju_siolive
ju_siolive17mo ago
i sware im trynna to understand, is Lenght wrong ? how do i write that then
Saber
Saber17mo ago
they literally told you
ju_siolive
ju_siolive17mo ago
im using vscode but its not showing me the error
Yawnder
Yawnder17mo ago
CTRL-F the word spelt wrong, then replace it.
ju_siolive
ju_siolive17mo ago
Sorry for the bothering guys, it didnt work, im probly doing it wrong but thanks anyway for the help oh it worked thanks guys
Yawnder
Yawnder17mo ago
Great
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Running an awaitable async Task, but forcing it to run on a specific thread (main thread).Hi everyone, I'm doing some work in Unity and am having an issue where some of the code that I want ❔ Help connect VS-Code to Unity and Simplify running programI want to connect Unity and VS code Also ive done it before but i want to simplify how you run the ❔ Issue with unit testing and projects not startingI'm writing up tests for my controller, but I need to grab an access token for authorization to do a❔ Retrieve API data in C#What structure would you use if you want to create an API that retrieves data from another API and r❔ HttpRequestException: No Such Host is known. (url.com:443) using WorkerService issueGreetings! I'm getting this error when my Win Service attempts to connect to my endpoint. It throws ✅ api response 401hey, I'm trying to use nlpcloud to translate text there is curl example: ```cpp curl "https://api.nl✅ warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible.I'm doing some codes in visual code and I don't what's wrong exactly. So the thing is I did a localh❔ Is there any way to create a pointer to a C# generic classI have a script that uses a class "fogGrid<bool>". At the start of the script I want it to be able t❔ need help with homework (while loop)hey guys, I am a novice programmer I currently go to school for an MSIS degree I am learning c# I h❔ Recursion Method Psuedocodehow do i recursively sort both sublists at the bottom? in pseudocode they are written left:=MergeSo