Hot answers tagged

2

I would recommend you to use the same class for generation and for usage of the Grid, because, firstly, it is the same objects you are working with, secondly, because you can avoid usage of Update() for now: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Grid : MonoBehaviour { public GameObject gridPrefab; ...


1

Did you mean GetComponentInChildren, without the "s"? When you use the plural, you're saying "give me ALL the cameras you find," so it has to return an array Camera[] to hold potentially multiple cameras. When you use the singular, you're saying "give me the FIRST camera you find," so it's able to return either a single valid ...


1

This should work: private void Test() { for (int x = 0; x < gridHeight; x++) { for (int y = 0; y < gridWidth; y++) { blocksX.Add(x.ToString()); blocksY.Add(y.ToString()); int index = y + x * gridWidth; texts[index].text = x.ToString() + ", " + y.ToString(); } ...


1

You could add inside the CreateGrid(): if (Random.Range(0,2)==0){ var blockRenderer=GridBlocks[0,Random.Range(0,GridHeight)].GetComponent<Renderer>(); blockRenderer.material.SetColor("_Color", Color.blue); blockRenderer = GridBlocks[GridWidth-1,Random.Range(0,GridHeight)].GetComponent<Renderer>(); ...


1

I found a solution. I don't think it would be the best but it works for now. With the new input system I subscribe A function (OnTransferKey) to a Key Press void OnEnable() { uI_Manager.uIInputManager.Inventory.OnTransfer.performed += OnTransferKey; } void OnDisable() { uI_Manager.uIInputManager.Inventory.OnTransfer.performed -= OnTransferKey; } ...


Only top voted, non community-wiki answers of a minimum length are eligible